mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-13 07:56:23 +00:00
2b0969dc77
Updated keys for local storage. They're now using camel case. Not sure why I didn't use camel case in the first place. View type and selected files of Uploads and Manage uploads (your own uploads and all uploads, respectively) are now stored separately. Added "filter by username" in Manage uploads. Added "jump to page" in all uploads/users view. Updated fontello (added filter icon). Bumped v1 and v3 version string, due to dashboard.js and fontello respectively. Curly rule fix for routes/nojs.js.
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
const config = require('./../config')
|
|
const routes = require('express').Router()
|
|
const uploadController = require('./../controllers/uploadController')
|
|
|
|
const renderOptions = {
|
|
uploadDisabled: false,
|
|
maxFileSize: config.cloudflare.noJsMaxSize || 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) => {
|
|
const options = { renderOptions }
|
|
options.gitHash = req.app.get('git-hash')
|
|
|
|
return res.render('nojs', options)
|
|
})
|
|
|
|
routes.post('/nojs', (req, res, next) => {
|
|
// TODO: Support upload by URLs.
|
|
res._json = res.json
|
|
res.json = (...args) => {
|
|
const result = args[0]
|
|
|
|
const options = { renderOptions }
|
|
options.gitHash = req.app.get('git-hash')
|
|
|
|
options.errorMessage = result.success ? '' : (result.description || 'An unexpected error occurred.')
|
|
options.files = result.files || [{}]
|
|
|
|
return res.render('nojs', options)
|
|
}
|
|
|
|
return uploadController.upload(req, res, next)
|
|
})
|
|
|
|
module.exports = routes
|