mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2024-12-15 00:46:22 +00:00
5bb960756f
uploadController.js: * Fixed chunk uploads failing when "blockedExtensions" is missing from the config file. config.sample.js: * Renamed "blockedExtensions" to "extensionsFilter", and added a new option named "filterBlacklist". When "filterBlacklist" is set to 'true', all extensions in "extensionsFilter" array will be blacklisted, otherwise it will be a whitelist, so only files with those extensions that can be uploaded. * Renamed "uploads.chunkedUploads.maxSize" to "uploads.chunkedUploads.chunkSize". * Added "uploads.chunkedUploads.noJsMaxSize" which can be used to change the 'displayed' file size on the No-JS uploader page. * Some other phrases updates. _globals.njk: * Updated static files' version string since there is a small update to home.js. other files: * Regular code improvements/tweaks.
39 lines
1019 B
JavaScript
39 lines
1019 B
JavaScript
const config = require('./../config')
|
|
const routes = require('express').Router()
|
|
const uploadController = require('./../controllers/uploadController')
|
|
|
|
const renderOptions = {
|
|
uploadDisabled: false,
|
|
maxFileSize: config.uploads.chunkedUploads.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) => {
|
|
return res.render('nojs', { renderOptions })
|
|
})
|
|
|
|
routes.post('/nojs', (req, res, next) => {
|
|
res._json = res.json
|
|
res.json = (...args) => {
|
|
const result = args[0]
|
|
|
|
const options = { renderOptions }
|
|
|
|
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
|