diff options
| author | Pitu <[email protected]> | 2018-09-16 00:39:58 -0300 |
|---|---|---|
| committer | Pitu <[email protected]> | 2018-09-16 00:39:58 -0300 |
| commit | 868f4a64eca3fb38fbfa12e7b9a9d0d4a374f369 (patch) | |
| tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /routes | |
| parent | Merge pull request #149 from iilukas/patch-1 (diff) | |
| download | host.fuwn.me-868f4a64eca3fb38fbfa12e7b9a9d0d4a374f369.tar.xz host.fuwn.me-868f4a64eca3fb38fbfa12e7b9a9d0d4a374f369.zip | |
Begone!
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/album.js | 56 | ||||
| -rw-r--r-- | routes/api.js | 37 |
2 files changed, 0 insertions, 93 deletions
diff --git a/routes/album.js b/routes/album.js deleted file mode 100644 index 46f00d3..0000000 --- a/routes/album.js +++ /dev/null @@ -1,56 +0,0 @@ -const config = require('../config.js'); -const routes = require('express').Router(); -const db = require('knex')(config.database); -const path = require('path'); -const utils = require('../controllers/utilsController.js'); - -routes.get('/a/:identifier', async (req, res, next) => { - let identifier = req.params.identifier; - if (identifier === undefined) return res.status(401).json({ success: false, description: 'No identifier provided' }); - - const album = await db.table('albums').where({ identifier, enabled: 1 }).first(); - if (!album) return res.status(404).sendFile('404.html', { root: './pages/error/' }); - - const files = await db.table('files').select('name').where('albumid', album.id).orderBy('id', 'DESC'); - let thumb = ''; - const basedomain = config.domain; - - for (let file of files) { - file.file = `${basedomain}/${file.name}`; - - let ext = path.extname(file.name).toLowerCase(); - if (utils.imageExtensions.includes(ext) || utils.videoExtensions.includes(ext)) { - file.thumb = `${basedomain}/thumbs/${file.name.slice(0, -ext.length)}.png`; - - /* - If thumbnail for album is still not set, do it. - A potential improvement would be to let the user upload a specific image as an album cover - since embedding the first image could potentially result in nsfw content when pasting links. - */ - - if (thumb === '') { - thumb = file.thumb; - } - - file.thumb = `<img src="${file.thumb}"/>`; - } else { - file.thumb = `<h1 class="title">.${ext}</h1>`; - } - } - - - let enableDownload = false; - if (config.uploads.generateZips) enableDownload = true; - - return res.render('album', { - layout: false, - title: album.name, - count: files.length, - thumb, - files, - identifier, - enableDownload - }); -}); - -module.exports = routes; diff --git a/routes/api.js b/routes/api.js deleted file mode 100644 index 5a4d355..0000000 --- a/routes/api.js +++ /dev/null @@ -1,37 +0,0 @@ -const config = require('../config.js'); -const routes = require('express').Router(); -const uploadController = require('../controllers/uploadController'); -const albumsController = require('../controllers/albumsController'); -const tokenController = require('../controllers/tokenController'); -const authController = require('../controllers/authController'); - -routes.get('/check', (req, res, next) => { - return res.json({ - private: config.private, - maxFileSize: config.uploads.maxSize - }); -}); - -routes.post('/login', (req, res, next) => authController.verify(req, res, next)); -routes.post('/register', (req, res, next) => authController.register(req, res, next)); -routes.post('/password/change', (req, res, next) => authController.changePassword(req, res, next)); -routes.get('/uploads', (req, res, next) => uploadController.list(req, res, next)); -routes.get('/uploads/:page', (req, res, next) => uploadController.list(req, res, next)); -routes.post('/upload', (req, res, next) => uploadController.upload(req, res, next)); -routes.post('/upload/delete', (req, res, next) => uploadController.delete(req, res, next)); -routes.post('/upload/:albumid', (req, res, next) => uploadController.upload(req, res, next)); -routes.get('/album/get/:identifier', (req, res, next) => albumsController.get(req, res, next)); -routes.get('/album/zip/:identifier', (req, res, next) => albumsController.generateZip(req, res, next)); -routes.get('/album/:id', (req, res, next) => uploadController.list(req, res, next)); -routes.get('/album/:id/:page', (req, res, next) => uploadController.list(req, res, next)); -routes.get('/albums', (req, res, next) => albumsController.list(req, res, next)); -routes.get('/albums/:sidebar', (req, res, next) => albumsController.list(req, res, next)); -routes.post('/albums', (req, res, next) => albumsController.create(req, res, next)); -routes.post('/albums/delete', (req, res, next) => albumsController.delete(req, res, next)); -routes.post('/albums/rename', (req, res, next) => albumsController.rename(req, res, next)); -routes.get('/albums/test', (req, res, next) => albumsController.test(req, res, next)); -routes.get('/tokens', (req, res, next) => tokenController.list(req, res, next)); -routes.post('/tokens/verify', (req, res, next) => tokenController.verify(req, res, next)); -routes.post('/tokens/change', (req, res, next) => tokenController.change(req, res, next)); - -module.exports = routes; |