From bc998988c2382a87747450689543fa1be4f6079d Mon Sep 17 00:00:00 2001 From: Jai A Date: Mon, 12 Oct 2020 22:33:56 -0700 Subject: [PATCH] Mod creation WIP --- components/GoogleAd.vue | 38 ------- components/ModResult.vue | 17 ++- nuxt.config.js | 8 +- pages/dashboard/projects.vue | 11 +- pages/mod/create.vue | 208 ++++++++++++++++++++++++++++++++--- pages/mods.vue | 5 +- pages/user/_id.vue | 23 +++- 7 files changed, 237 insertions(+), 73 deletions(-) delete mode 100644 components/GoogleAd.vue diff --git a/components/GoogleAd.vue b/components/GoogleAd.vue deleted file mode 100644 index 71fb337a..00000000 --- a/components/GoogleAd.vue +++ /dev/null @@ -1,38 +0,0 @@ - - - diff --git a/components/ModResult.vue b/components/ModResult.vue index 790d4a67..e635e1f8 100644 --- a/components/ModResult.vue +++ b/components/ModResult.vue @@ -5,7 +5,7 @@

{{ name }}

-

+

by {{ author }}

@@ -28,7 +28,7 @@ -

{{ downloads }}

+

{{ formatNumber(downloads) }}

@@ -47,7 +47,7 @@

{{ $dayjs(createdAt).fromNow() }}

-
+
diff --git a/nuxt.config.js b/nuxt.config.js index 3fc1aad0..f4c7489f 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -80,13 +80,7 @@ export default { 'https://fonts.googleapis.com/css2?family=Montserrat+Alternates:wght@600&display=swap', }, ], - script: [ - { - src: 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js', - 'data-ad-client': 'ca-pub-4800120742989028', - async: true, - }, - ], + script: [], }, vue: { diff --git a/pages/dashboard/projects.vue b/pages/dashboard/projects.vue index c6556698..f67dd770 100644 --- a/pages/dashboard/projects.vue +++ b/pages/dashboard/projects.vue @@ -41,11 +41,16 @@ import axios from 'axios' export default { async fetch() { try { - const res = await axios.get( - `https://api.modrinth.com/api/v1/${this.$auth.user.id}/mods` + let res = await axios.get( + `https://api.modrinth.com/api/v1/user/${this.$auth.user.id}/mods` ) - this.mods = res.data + if (res.data) { + res = await axios.get( + `https://api.modrinth.com/api/v1/mods?ids=${JSON.stringify(res.data)}` + ) + this.mods = res.data + } } catch (err) {} }, data() { diff --git a/pages/mod/create.vue b/pages/mod/create.vue index 6e19970c..a7beba69 100644 --- a/pages/mod/create.vue +++ b/pages/mod/create.vue @@ -1,16 +1,91 @@

Create Mod

- - - -
+
+

Initial Data

+
+
+ + + +
+
+ + + + + + +
+
+
+
+

Mod Body

+

+ You can type the of the long form of your description here. This editor + supports markdown. You can find the syntax + here. +

-
- - - + +
+

Versions

+
+
+

Extras

+
+ + + +
+
+
@@ -20,6 +95,7 @@ import axios from 'axios' export default { data() { return { + previewImage: null, name: '', namespace: '', description: '', @@ -30,6 +106,7 @@ export default { issues_url: null, source_url: null, wiki_url: null, + icon: null, } }, methods: { @@ -58,6 +135,9 @@ export default { }) ) + if (this.icon) + formData.append('icon', new Blob([this.icon]), this.icon.name) + try { const result = await axios({ url: 'https://api.modrinth.com/api/v1/mod', @@ -65,6 +145,7 @@ export default { data: formData, headers: { 'Content-Type': 'multipart/form-data', + Authorization: this.$auth.getToken('local'), }, }) @@ -75,23 +156,96 @@ export default { console.error(err) } }, - compileBody() { - // this.compiledBody = DomPurify.sanitize(marked(this.body)) + showPreviewImage(e) { + const reader = new FileReader() + this.icon = e.target.files[0] + reader.readAsDataURL(this.icon) + + reader.onload = (event) => { + this.previewImage = event.target.result + } }, }, } diff --git a/pages/mods.vue b/pages/mods.vue index 9933fff2..087785d7 100644 --- a/pages/mods.vue +++ b/pages/mods.vue @@ -63,7 +63,7 @@ :latest-version="result.versions[0]" :created-at="result.date_created" :updated-at="result.date_modified" - :downloads="formatNumber(result.downloads)" + :downloads="result.downloads.toString()" :icon-url="result.icon_url" :author-url="result.author_url" :page-url="result.page_url" @@ -469,9 +469,6 @@ export default { console.error(err) } }, - formatNumber(x) { - return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',') - }, toggleFiltersMenu() { const filters = document.getElementById('filters') const currentlyActive = filters.className === 'filters active' diff --git a/pages/user/_id.vue b/pages/user/_id.vue index 8de21915..5111fb10 100644 --- a/pages/user/_id.vue +++ b/pages/user/_id.vue @@ -1,14 +1,35 @@