From 8e4f1b7838e3c43320f2e25e691c1808ae3c4089 Mon Sep 17 00:00:00 2001 From: Pitu Date: Mon, 30 Sep 2019 07:06:22 +0000 Subject: [PATCH] feature: album links --- src/api/routes/albums/albumZipGET.js | 8 ++++++-- src/api/structures/Server.js | 2 +- src/site/components/grid/Grid.vue | 9 ++++++++- src/site/pages/a/_identifier.vue | 18 ++++-------------- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/api/routes/albums/albumZipGET.js b/src/api/routes/albums/albumZipGET.js index b2c9fa7..d1d3e16 100644 --- a/src/api/routes/albums/albumZipGET.js +++ b/src/api/routes/albums/albumZipGET.js @@ -17,9 +17,13 @@ class albumGET extends Route { Make sure it exists and it's enabled */ const link = await db.table('links') - .where({ identifier, enabled: true }) + .where({ + identifier, + enabled: true, + enableDownload: true + }) .first(); - if (!link) return res.status(400).json({ message: 'The identifier supplied could not be found' }); + if (!link) return res.status(400).json({ message: 'The supplied identifier could not be found' }); /* Same with the album, just to make sure is not a deleted album and a leftover link diff --git a/src/api/structures/Server.js b/src/api/structures/Server.js index f8c6ad1..50f6754 100644 --- a/src/api/structures/Server.js +++ b/src/api/structures/Server.js @@ -26,7 +26,7 @@ class Server { /* This bypasses the headers.accept for album download, since it's accesed directly through the browser. */ - if (req.url.includes('/api/album/') && req.url.includes('/zip') && req.method === 'GET') return next(); + if ((req.url.includes('/api/album/') || req.url.includes('/zip')) && req.method === 'GET') return next(); if (req.headers.accept && req.headers.accept.includes('application/vnd.lolisafe.json')) return next(); return res.status(405).json({ message: 'Incorrect `Accept` header provided' }); }); diff --git a/src/site/components/grid/Grid.vue b/src/site/components/grid/Grid.vue index 89ac125..07e5440 100644 --- a/src/site/components/grid/Grid.vue +++ b/src/site/components/grid/Grid.vue @@ -80,7 +80,8 @@ :gutterWidth="10" :gutterHeight="4"> - + @@ -157,6 +160,10 @@ export default { width: { type: Number, default: 150 + }, + enableSearch: { + type: Boolean, + default: true } }, data() { diff --git a/src/site/pages/a/_identifier.vue b/src/site/pages/a/_identifier.vue index d00ad85..923e8cc 100644 --- a/src/site/pages/a/_identifier.vue +++ b/src/site/pages/a/_identifier.vue @@ -34,7 +34,8 @@ + :width="200" + :enableSearch="false" /> @@ -65,7 +66,7 @@ export default { }, async asyncData({ app, params, error }) { try { - const data = await axios.get(`${app.store.state.config.baseURL}/album/${params.identifier}`); + const { data } = await axios.get(`${app.store.state.config.baseURL}/album/${params.identifier}`); const downloadLink = data.downloadEnabled ? `${app.store.state.config.baseURL}/album/${params.identifier}/zip` : null; return { name: data.name, @@ -74,6 +75,7 @@ export default { downloadLink }; } catch (err) { + console.log('Error when retrieving album', err); /* return { name: null, @@ -118,18 +120,6 @@ export default { { vmid: 'og:description', property: 'og:description', content: 'A modern and self-hosted file upload service that can handle anything you throw at it. Fast uploads, file manager and sharing capabilities all crafted with a beautiful user experience in mind.' } ] }; - }, - mounted() { - /* - if (this.error) { - if (this.error === 404) { - this.$toast.open('Album not found', true, 3000); - setTimeout(() => this.$router.push('/404'), 3000); - return; - } - this.$toast.open(`Error code ${this.error}`, true, 3000); - } - */ } };