From dd43acecea45ac64f9cc080eb5cf4fa8a0ac5943 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Fri, 13 Apr 2018 23:20:57 +0700 Subject: [PATCH] Updates * Added VSCode settings to git repo. Now you can match yours with mine, if you want. * Added .jsbeautifyrc for js-beautify (to be used by VSCode's Beautify extension). * Refactored all instances of require('**/*.js') with require('**/*') wherever applicable (basically gotten rid of the .js extension). * Refactored path in all instances of require() wherever applicable. * Sorted instances of require() wherever applicable. * Fixed 500 HTTP error trying to load an error page for 505 HTTP error. * Removed special treatement of NoJS page from uploadsController.processFilesForDisplay(). * Updated version string of all static files. * Beautified all HTML, HANDLEBARS and CSS files. * Refactored the structure of footer links in homepage and No-JS uploader. This should now fix homepage going out-of-bound in smaller screens. * Added CSS prefixes wherever applicable. * Improved back-end side of No-JS uploader. This will now handle errors properly. * No-JS uploader will now show max file size. * No-JS uploader will now show a proper message when private mode is enabled and/or registration is disabled. --- .editorconfig | 4 + .gitignore | 1 - .jsbeautifyrc | 6 + .vscode/settings.json | 33 +++++ controllers/albumsController.js | 9 +- controllers/authController.js | 6 +- controllers/tokenController.js | 4 +- controllers/uploadController.js | 15 +-- controllers/utilsController.js | 8 +- database/migration.js | 2 +- lolisafe.js | 12 +- pages/album.html | 16 +-- pages/auth.html | 35 ++---- pages/dashboard.html | 36 +++--- pages/faq.html | 39 +++--- pages/home.html | 190 ++++++++++++++--------------- public/css/auth.css | 31 +++++ public/css/dashboard.css | 36 +++++- public/css/home.css | 167 +++++++++++++++++++++++++ public/css/style.css | 119 ------------------ public/js/home.js | 2 +- routes/album.js | 4 +- routes/api.js | 10 +- routes/nojs.js | 33 ++++- views/album.handlebars | 56 +++------ views/nojs.handlebars | 210 +++++++++++++++++--------------- 26 files changed, 607 insertions(+), 477 deletions(-) create mode 100644 .jsbeautifyrc create mode 100644 .vscode/settings.json create mode 100644 public/css/auth.css create mode 100644 public/css/home.css diff --git a/.editorconfig b/.editorconfig index 26e86bb..ce41ae1 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,3 +19,7 @@ insert_final_newline = false [./public/safe.fiery.me.sxcu] insert_final_newline = false + +[./.vscode/settings.json] +indent_size = 4 +insert_final_newline = false diff --git a/.gitignore b/.gitignore index 1604c07..2f20378 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,3 @@ migrate.js yarn.lock yarn-error.log package-lock.json -.vscode/ diff --git a/.jsbeautifyrc b/.jsbeautifyrc new file mode 100644 index 0000000..8c9721d --- /dev/null +++ b/.jsbeautifyrc @@ -0,0 +1,6 @@ +{ + "indent_size": 2, + "indent_char": " ", + "indent_inner_html": true, + "indent_handlebars": true +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..f4c4690 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,33 @@ +{ + "beautify.ignore": [ + "**/*.js" + ], + "beautify.language": { + "js": {}, + "css": [ + "css", + "scss" + ], + "html": [ + "htm", + "html", + "hbs", + "handlebars" + ] + }, + "discord.enabled": true, + "editor.formatOnPaste": false, + "editor.formatOnSave": true, + "editor.rulers": [ + 120 + ], + "editor.wordWrapColumn": 120, + "editor.wordWrap": "bounded", + "editor.wrappingIndent": "indent", + "eslint.enable": true, + "eslint.autoFixOnSave": true, + "javascript.format.enable": false, + "javascript.suggestionActions.enabled": false, + "javascript.validate.enable": false, + "npm-intellisense.importES6": false +} \ No newline at end of file diff --git a/controllers/albumsController.js b/controllers/albumsController.js index c9e8b11..b3416b5 100644 --- a/controllers/albumsController.js +++ b/controllers/albumsController.js @@ -1,10 +1,11 @@ -const config = require('../config.js') +const config = require('./../config') const db = require('knex')(config.database) -const randomstring = require('randomstring') -const utils = require('./utilsController.js') -const path = require('path') const fs = require('fs') +const path = require('path') +const randomstring = require('randomstring') +const utils = require('./utilsController') const Zip = require('jszip') + const albumsController = {} albumsController.list = async (req, res, next) => { diff --git a/controllers/authController.js b/controllers/authController.js index 6612e82..1137f06 100644 --- a/controllers/authController.js +++ b/controllers/authController.js @@ -1,8 +1,8 @@ -const config = require('../config.js') -const db = require('knex')(config.database) const bcrypt = require('bcrypt') +const config = require('./../config') +const db = require('knex')(config.database) const randomstring = require('randomstring') -const utils = require('./utilsController.js') +const utils = require('./utilsController') const authController = {} diff --git a/controllers/tokenController.js b/controllers/tokenController.js index 6e2249b..4386e65 100644 --- a/controllers/tokenController.js +++ b/controllers/tokenController.js @@ -1,7 +1,7 @@ -const config = require('../config.js') +const config = require('./../config') const db = require('knex')(config.database) const randomstring = require('randomstring') -const utils = require('./utilsController.js') +const utils = require('./utilsController') const tokenController = {} diff --git a/controllers/uploadController.js b/controllers/uploadController.js index 056f942..22014c6 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -1,11 +1,11 @@ -const config = require('../config.js') +const config = require('./../config') const path = require('path') const multer = require('multer') const randomstring = require('randomstring') const db = require('knex')(config.database) const crypto = require('crypto') const fs = require('fs') -const utils = require('./utilsController.js') +const utils = require('./utilsController') const uploadsController = {} @@ -450,17 +450,6 @@ uploadsController.processFilesForDisplay = async (req, res, files, existingFiles }) } - if (req.params.nojs) { - return res.render('nojs', { - layout: false, - files: mappedFiles.map(file => { - const exec = /.[\w]+(\?|$)/.exec(file.url) - file.image = exec && exec[0] && utils.imageExtensions.includes(exec[0].toLowerCase()) - return file - }) - }) - } - return res.json({ success: albumSuccess, description: albumSuccess ? null : 'Warning: Album may not have been properly updated.', diff --git a/controllers/utilsController.js b/controllers/utilsController.js index 109885f..f1ec01c 100644 --- a/controllers/utilsController.js +++ b/controllers/utilsController.js @@ -1,9 +1,9 @@ -const path = require('path') -const config = require('../config.js') +const config = require('./../config') +const db = require('knex')(config.database) +const ffmpeg = require('fluent-ffmpeg') const fs = require('fs') const gm = require('gm') -const ffmpeg = require('fluent-ffmpeg') -const db = require('knex')(config.database) +const path = require('path') const units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] diff --git a/database/migration.js b/database/migration.js index 73638a4..4b55d7f 100644 --- a/database/migration.js +++ b/database/migration.js @@ -1,4 +1,4 @@ -const config = require('../config.js') +const config = require('./../config') const db = require('knex')(config.database) const map = { diff --git a/lolisafe.js b/lolisafe.js index 98bd045..86e4df6 100644 --- a/lolisafe.js +++ b/lolisafe.js @@ -1,7 +1,7 @@ -const config = require('./config.js') -const api = require('./routes/api.js') -const album = require('./routes/album.js') -const nojs = require('./routes/nojs.js') +const config = require('./config') +const api = require('./routes/api') +const album = require('./routes/album') +const nojs = require('./routes/nojs') const express = require('express') const helmet = require('helmet') const bodyParser = require('body-parser') @@ -64,11 +64,11 @@ for (const page of config.pages) { // NOTE: Uses fiery.me branch of https://github.com/BobbyWibowo/HttpErrorPages safe.use((req, res, next) => { - res.status(404).sendFile('HTTP404.html', { root: '../HttpErrorPages/dist/' }) + res.status(404).sendFile('HTTP404.html', { root: './../HttpErrorPages/dist/' }) }) safe.use((error, req, res, next) => { console.error(error) - res.status(500).sendFile('HTTP505.html', { root: '../HttpErrorPages/dist/' }) + res.status(500).sendFile('HTTP500.html', { root: './../HttpErrorPages/dist/' }) }) safe.listen(config.port, () => console.log(`lolisafe started on port ${config.port}`)) diff --git a/pages/album.html b/pages/album.html index 70718c5..0999a67 100644 --- a/pages/album.html +++ b/pages/album.html @@ -1,5 +1,6 @@ + @@ -10,11 +11,11 @@ safe.fiery.me – A small safe worth protecting. - - - - - + + + + + @@ -42,10 +43,10 @@ - + - + @@ -68,4 +69,5 @@ + diff --git a/pages/auth.html b/pages/auth.html index 09b1c0d..366abfc 100644 --- a/pages/auth.html +++ b/pages/auth.html @@ -1,7 +1,7 @@ - + @@ -10,12 +10,13 @@ safe.fiery.me – A small safe worth protecting. - - - - - - + + + + + + + @@ -43,27 +44,15 @@ - + - + - - - - -
+
@@ -109,6 +98,6 @@
- + diff --git a/pages/dashboard.html b/pages/dashboard.html index 11d913e..99b4a7a 100644 --- a/pages/dashboard.html +++ b/pages/dashboard.html @@ -1,7 +1,7 @@ - + @@ -10,14 +10,14 @@ safe.fiery.me – A small safe worth protecting. - - - - - - - - + + + + + + + + @@ -45,18 +45,15 @@ - + - + - -
-

@@ -70,13 +67,10 @@

-
-
-

Dashboard

@@ -127,20 +121,18 @@
- -
- + diff --git a/pages/home.html b/pages/home.html index ddce68b..b1f2d31 100644 --- a/pages/home.html +++ b/pages/home.html @@ -1,7 +1,7 @@ - + @@ -10,14 +10,15 @@ safe.fiery.me – A small safe worth protecting. - - - - - - - - + + + + + + + + + @@ -45,41 +46,14 @@ - + - + - - - -
@@ -87,21 +61,23 @@

safe.fiery.me

-

A - modern self-hosted file upload service

+

+ A modern self-hosted file upload service +

-
+ +
-
+
- @@ -109,7 +85,7 @@
-
+
@@ -120,11 +96,11 @@

@@ -134,52 +110,74 @@

- +
+
+ +
+
- + diff --git a/public/css/auth.css b/public/css/auth.css new file mode 100644 index 0000000..3c27f07 --- /dev/null +++ b/public/css/auth.css @@ -0,0 +1,31 @@ +input { + background: rgba(0, 0, 0, 0); +} + +input, +a { + border-left: 0px; + border-top: 0px; + border-right: 0px; + border-radius: 0px; + -webkit-box-shadow: 0 0 0; + box-shadow: 0 0 0; +} + +.select-wrapper { + text-align: center; + margin-bottom: 10px; +} + +#login .input { + border-top: 0; + border-right: 0; + border-left: 0; + border-radius: 0; + padding-right: calc(0.75em + 1px); + padding-left: calc(0.75em + 1px); +} + +#login .control .button { + border-radius: 0; +} diff --git a/public/css/dashboard.css b/public/css/dashboard.css index 5053882..b1adc25 100644 --- a/public/css/dashboard.css +++ b/public/css/dashboard.css @@ -1,7 +1,7 @@ -/* ------------------ - COLORS BASED ON - KDE BREEZE DARK ------------------- */ +#auth, +#dashboard { + display: none +} .button.is-breeze { background-color: #2980b9; @@ -74,12 +74,16 @@ html { } .image-container { + display: -webkit-box; + display: -ms-flexbox; display: flex; width: 200px; height: 200px; margin: 9px; background-color: #31363b; overflow: hidden; + -webkit-box-align: center; + -ms-flex-align: center; align-items: center; position: relative; } @@ -102,6 +106,8 @@ html { } .image-container .controls { + display: -webkit-box; + display: -ms-flexbox; display: flex; position: absolute; top: .75rem; @@ -142,12 +148,14 @@ html { .no-touch .image-container .file-checkbox { opacity: .25; + -webkit-transition: opacity .25s; transition: opacity .25s; } .no-touch .image-container .controls, .no-touch .image-container .details { opacity: 0; + -webkit-transition: opacity .25s; transition: opacity .25s; } @@ -199,3 +207,23 @@ html { color: #eff0f1; height: 2.25em; } + +#modal .modal-content { + background-color: #31363b; + border-radius: 5px; + -webkit-box-shadow: 0 2px 3px rgba(10, 10, 10, .1), 0 0 0 1px rgba(10, 10, 10, .1); + box-shadow: 0 2px 3px rgba(10, 10, 10, .1), 0 0 0 1px rgba(10, 10, 10, .1); + padding: 20px; + width: auto; +} + +#modal .modal-content .image { + width: 200px; + height: 200px; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} diff --git a/public/css/home.css b/public/css/home.css new file mode 100644 index 0000000..db7e4f4 --- /dev/null +++ b/public/css/home.css @@ -0,0 +1,167 @@ +#b { + width: 200px; + height: 200px; + border-radius: 100%; + -webkit-animation-delay: 0.5s; + animation-delay: 0.5s; + -webkit-animation-duration: 1.5s; + animation-duration: 1.5s; + -webkit-animation-fill-mode: both; + animation-fill-mode: both; + -webkit-animation-name: floatUp; + animation-name: floatUp; + -webkit-animation-timing-function: cubic-bezier(0, 0.71, 0.29, 1); + animation-timing-function: cubic-bezier(0, 0.71, 0.29, 1); + border-radius: 24px; + display: inline-block; + height: 240px; + margin-bottom: 40px; + position: relative; + vertical-align: top; + width: 240px; + -webkit-box-shadow: 0 20px 60px rgba(10, 10, 10, 0.05), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); + box-shadow: 0 20px 60px rgba(10, 10, 10, 0.05), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); +} + +#dropzone { + border: 1px solid #dbdbdb; + background-color: rgba(0, 0, 0, 0); + border-color: #ff3860; + color: #ff3860; + display: none; + width: 100%; + border-radius: 3px; + -webkit-box-shadow: none; + box-shadow: none; + height: 2.5em; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + padding-left: .75em; + padding-right: .75em; + text-align: center; + cursor: pointer; +} + +#dropzone * { + pointer-events: none; +} + +#uploads, +#tokenContainer, +#panel { + display: none; +} + +#dropzone:hover { + background-color: #ff3860; + border-color: #ff3860; + color: #fff; +} + +#maxFileSize { + font-size: 1rem; +} + +img.logo { + max-height: 200px; + margin-top: 20px; +} + +.dz-preview .dz-details { + display: -webkit-box; + display: -ms-flexbox; + display: flex; +} + +.dz-preview .dz-details .dz-size, +.dz-preview .dz-details .dz-filename { + -webkit-box-flex: 1; + -ms-flex: 1; + flex: 1; +} + +.dz-preview img, +.dz-preview .dz-success-mark, +.dz-preview .dz-error-mark { + display: none; +} + +#uploads { + margin-bottom: 25px; +} + +@-webkit-keyframes floatUp { + 0% { + opacity: 0; + -webkit-box-shadow: 0 0 0 rgba(10, 10, 10, 0), 0 0 0 rgba(10, 10, 10, 0), 0 0 0 rgba(10, 10, 10, 0); + box-shadow: 0 0 0 rgba(10, 10, 10, 0), 0 0 0 rgba(10, 10, 10, 0), 0 0 0 rgba(10, 10, 10, 0); + -webkit-transform: scale(0.86); + transform: scale(0.86); + } + 25% { + opacity: 100; + } + 67% { + -webkit-box-shadow: 0 0 0 rgba(10, 10, 10, 0), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); + box-shadow: 0 0 0 rgba(10, 10, 10, 0), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); + -webkit-transform: scale(1); + transform: scale(1); + } + 100% { + -webkit-box-shadow: 0 20px 60px rgba(10, 10, 10, 0.05), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); + box-shadow: 0 20px 60px rgba(10, 10, 10, 0.05), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); + -webkit-transform: scale(1); + transform: scale(1); + } +} + +@keyframes floatUp { + 0% { + opacity: 0; + -webkit-box-shadow: 0 0 0 rgba(10, 10, 10, 0), 0 0 0 rgba(10, 10, 10, 0), 0 0 0 rgba(10, 10, 10, 0); + box-shadow: 0 0 0 rgba(10, 10, 10, 0), 0 0 0 rgba(10, 10, 10, 0), 0 0 0 rgba(10, 10, 10, 0); + -webkit-transform: scale(0.86); + transform: scale(0.86); + } + 25% { + opacity: 100; + } + 67% { + -webkit-box-shadow: 0 0 0 rgba(10, 10, 10, 0), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); + box-shadow: 0 0 0 rgba(10, 10, 10, 0), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); + -webkit-transform: scale(1); + transform: scale(1); + } + 100% { + -webkit-box-shadow: 0 20px 60px rgba(10, 10, 10, 0.05), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); + box-shadow: 0 20px 60px rgba(10, 10, 10, 0.05), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); + -webkit-transform: scale(1); + transform: scale(1); + } +} + +img[data-dz-thumbnail] { + max-width: 200px; +} + +.clipboard-mobile { + margin-top: 5px; +} + +#albumDiv .control { + text-align: inherit; +} + +#linksColumn { + margin-left: -0.25rem; + margin-right: -0.25rem; +} + +#linksColumn .column { + padding-left: 0.25rem; + padding-right: 0.25rem; +} diff --git a/public/css/style.css b/public/css/style.css index be36370..a6c0788 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -1,103 +1,3 @@ -/* ------------------ - HOME ------------------- */ - -section#home #b { - -webkit-animation-delay: 0.5s; - animation-delay: 0.5s; - -webkit-animation-duration: 1.5s; - animation-duration: 1.5s; - -webkit-animation-fill-mode: both; - animation-fill-mode: both; - -webkit-animation-name: floatUp; - animation-name: floatUp; - -webkit-animation-timing-function: cubic-bezier(0, 0.71, 0.29, 1); - animation-timing-function: cubic-bezier(0, 0.71, 0.29, 1); - border-radius: 24px; - display: inline-block; - height: 240px; - margin-bottom: 40px; - position: relative; - vertical-align: top; - width: 240px; - box-shadow: 0 20px 60px rgba(10, 10, 10, 0.05), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); -} - -section#home div#dropzone { - border: 1px solid #dbdbdb; - background-color: rgba(0, 0, 0, 0); - border-color: #ff3860; - color: #ff3860; - display: none; - width: 100%; - border-radius: 3px; - box-shadow: none; - height: 2.5em; - -webkit-box-align: center; - -ms-flex-align: center; - align-items: center; - user-select: none; - justify-content: center; - padding-left: .75em; - padding-right: .75em; - text-align: center; - cursor: pointer; -} - -section#home div#uploads, section#home p#tokenContainer, section#home a#panel { display: none; } -section#home div#dropzone:hover { background-color: #ff3860; border-color: #ff3860; color: #fff; } -section#home h3#maxFileSize { font-size: 14px; } -section#home h3#links span { padding-left: 5px; padding-right: 5px; } -section#home img.logo { height: 200px; margin-top: 20px; } -section#home .dz-preview .dz-details { display: flex; } -section#home .dz-preview .dz-details .dz-size, section#home .dz-preview .dz-details .dz-filename { flex: 1; } -section#home .dz-preview img, section#home .dz-preview .dz-success-mark, section#home .dz-preview .dz-error-mark { display: none; } -section#home div#uploads { margin-bottom: 25px; } - -@keyframes floatUp { - 0% { - opacity: 0; - box-shadow: 0 0 0 rgba(10, 10, 10, 0), 0 0 0 rgba(10, 10, 10, 0), 0 0 0 rgba(10, 10, 10, 0); - -webkit-transform: scale(0.86); - transform: scale(0.86); - } - 25% { opacity: 100; } - 67% { - box-shadow: 0 0 0 rgba(10, 10, 10, 0), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); - -webkit-transform: scale(1); - transform: scale(1); - } - 100% { - box-shadow: 0 20px 60px rgba(10, 10, 10, 0.05), 0 5px 10px rgba(10, 10, 10, 0.1), 0 1px 1px rgba(10, 10, 10, 0.2); - -webkit-transform: scale(1); - transform: scale(1); - } -} - -/* ------------------ - PANEL ------------------- */ - -section#auth, section#dashboard { display: none } -section#auth input { background: rgba(0, 0, 0, 0); } -section#auth input, section#auth a { - border-left: 0px; - border-top: 0px; - border-right: 0px; - border-radius: 0px; - box-shadow: 0 0 0; -} - -.select-wrapper { - text-align: center; - margin-bottom: 10px; -} - -/* ------------------ - COLORS BASED ON - KDE BREEZE DARK ------------------- */ - .hero { background-color: #232629; color: #eff0f1; @@ -123,29 +23,10 @@ a:hover { color: #3daee9; } -section#home #b { - width: 200px; - height: 200px; - border-radius: 100%; -} - hr { background-color: #898b8d; } -#login .input { - border-top: 0; - border-right: 0; - border-left: 0; - border-radius: 0; - padding-right: calc(0.75em + 1px); - padding-left: calc(0.75em + 1px); -} - -#login .control .button { - border-radius: 0; -} - .input.is-active, .input.is-focused, .input:active, diff --git a/public/js/home.js b/public/js/home.js index 5da1f0e..633a62c 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -114,7 +114,7 @@ upload.prepareUpload = () => { const div = document.createElement('div') div.id = 'dropzone' - div.className = 'button' + div.className = 'button is-unselectable' div.innerHTML = ` diff --git a/routes/album.js b/routes/album.js index b7d1318..186b38e 100644 --- a/routes/album.js +++ b/routes/album.js @@ -1,8 +1,8 @@ -const config = require('../config.js') +const config = require('./../config') const routes = require('express').Router() const db = require('knex')(config.database) const path = require('path') -const utils = require('../controllers/utilsController.js') +const utils = require('./../controllers/utilsController') routes.get('/a/:identifier', async (req, res, next) => { const identifier = req.params.identifier diff --git a/routes/api.js b/routes/api.js index a1e85bd..7ab8ed9 100644 --- a/routes/api.js +++ b/routes/api.js @@ -1,9 +1,9 @@ -const config = require('../config.js') +const config = require('./../config') 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') +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({ diff --git a/routes/nojs.js b/routes/nojs.js index be1a9cc..1f4d30c 100644 --- a/routes/nojs.js +++ b/routes/nojs.js @@ -1,12 +1,39 @@ +const config = require('./../config') const routes = require('express').Router() -const uploadController = require('../controllers/uploadController') +const uploadController = require('./../controllers/uploadController') + +const renderOptions = { + layout: false, + uploadDisabled: false, + maxFileSize: config.uploads.maxSize +} + +if (config.private) { + if (config.enableUserAccounts) { + renderOptions.uploadDisabled = 'Anonymous upload is disabled.' + } else { + renderOptions.uploadDisabled = 'Running in private mode.' + } +} routes.get('/nojs', async (req, res, next) => { - return res.render('nojs', { layout: false }) + return res.render('nojs', renderOptions) }) routes.post('/nojs', (req, res, next) => { - req.params.nojs = true + res._json = res.json + res.json = (...args) => { + const result = args[0] + + const _renderOptions = {} + Object.assign(_renderOptions, renderOptions) + + _renderOptions.errorMessage = result.success ? '' : (result.description || 'An unexpected error occurred.') + _renderOptions.files = result.files || [{}] + + return res.render('nojs', _renderOptions) + } + return uploadController.upload(req, res, next) }) diff --git a/views/album.handlebars b/views/album.handlebars index 377b021..0881fea 100644 --- a/views/album.handlebars +++ b/views/album.handlebars @@ -1,7 +1,7 @@ - + @@ -10,10 +10,10 @@ {{ title }} - - - - + + + + @@ -36,59 +36,35 @@ - + - + + - - - - - - -
- + +
-

{{ title }}

{{ count }} files

- {{#if enableDownload}} - Download Album + Download Album {{/if}} -
-
{{#each files}} - + {{/each}}
-
+
+ -
- - diff --git a/views/nojs.handlebars b/views/nojs.handlebars index 355b548..51a6940 100644 --- a/views/nojs.handlebars +++ b/views/nojs.handlebars @@ -1,7 +1,7 @@ - + @@ -10,9 +10,10 @@ safe.fiery.me – A small safe worth protecting. - - - + + + + @@ -40,33 +41,14 @@ - + - + - - - - + -
@@ -74,94 +56,128 @@

safe.fiery.me

-

A - modern self-hosted file upload service

+

+ A modern self-hosted file upload service +

-
+

+ Maximum upload size per file is {{ maxFileSize }} +

+ +
-
-
- -
-
- -
-
+

+ Files uploaded through this No-JS uploader will not be associated to your account, if you have any. +

-

Files uploaded through this No JS form will not be associated to your account, if you have any.

+ {{#if uploadDisabled }} + {{{ uploadDisabled }}} + {{else}} +
+
+ +
+
+ +
+
+ {{/if}}
{{#if files}} -
- {{#each files}} -
-
-
- {{#if this.image}} - - {{/if}} - -
-
+
+ {{#each files}} +
+
+
+ {{#if ./../errorMessage}} +

{{{ ./../errorMessage }}}

+ {{/if}} + {{#if this.url }} + + {{/if}} +
+
+
+ {{/each}}
- {{/each}} -
{{/if}} - - +
+
+ +
+
- +