diff --git a/controllers/forms.js b/controllers/forms.js index 5cf5d2b5..4094c29d 100644 --- a/controllers/forms.js +++ b/controllers/forms.js @@ -31,7 +31,7 @@ const express = require('express') limits: { totalSize: globalLimits.postFilesSize.max, fileSize: globalLimits.postFilesSize.max, - files: globalLimits.postFiles.max + //files: globalLimits.postFiles.max }, limitHandler: uploadLimitFunction, useTempFiles: true, diff --git a/controllers/forms/makepost.js b/controllers/forms/makepost.js index cced1325..8868684f 100644 --- a/controllers/forms/makepost.js +++ b/controllers/forms/makepost.js @@ -8,15 +8,15 @@ const makePost = require(__dirname+'/../../models/forms/makepost.js') module.exports = async (req, res, next) => { - res.locals.numFiles = Math.min(res.locals.numFiles, res.locals.board.settings.maxFiles) - const errors = []; // even if force file and message are off, the post must contain one of either. if ((!req.body.message || req.body.message.length === 0) && res.locals.numFiles === 0) { errors.push('Posts must include a message or file'); } - + if (res.locals.numFiles > res.locals.board.settings.maxFiles) { + errors.push(`Too many files. Max files per post ${res.locals.board.settings.maxFiles < globalLimits.postFiles.max ? 'on this board ' : ''}is ${res.locals.board.settings.maxFiles}`); + } // check file, subject and message enforcement according to board settings if (!req.body.subject || req.body.subject.length === 0) { if (!req.body.thread && res.locals.board.settings.forceThreadSubject) { diff --git a/gulp/res/css/style.css b/gulp/res/css/style.css index 0a9f81be..cc6f0420 100644 --- a/gulp/res/css/style.css +++ b/gulp/res/css/style.css @@ -261,6 +261,7 @@ p { padding: 5px; min-width: 220px; flex-grow: 1; + flex-direction: column; } .banposts .thread { diff --git a/gulp/res/js/progress.js b/gulp/res/js/progress.js index a49af2ae..44811e18 100644 --- a/gulp/res/js/progress.js +++ b/gulp/res/js/progress.js @@ -23,9 +23,10 @@ window.addEventListener('DOMContentLoaded', () => { const fileInput = document.getElementById('file'); const fileLabel = fileInput.previousSibling; + const fileLabelText = fileLabel.childNodes[0]; let files = []; - const removeFile = (name) => { + const removeFile = (name) => { //unused atm for(let i = 1; i < fileLabel.childNodes.length; i++) { const childNode = fileLabel.childNodes[i]; if (childNode.nodeValue === name) { @@ -39,9 +40,9 @@ window.addEventListener('DOMContentLoaded', () => { //show number of files on new label const updateFilesText = () => { if (files.length === 0) { - fileLabel.innerText = 'Upload/Drop/Paste file(s)'; + fileLabelText.nodeValue = 'Upload/Drop/Paste file(s)'; } else { - fileLabel.innerText = `${files.length} files selected`; + fileLabelText.nodeValue = `${files.length} files selected`; //window.URL.createObjectURL(file); //todo make x marks to remove each one with "removeFile" } @@ -88,7 +89,7 @@ window.addEventListener('DOMContentLoaded', () => { //add files to list instead of replacing when regular upload fileInput.onchange = () => { - fileLabel.innerText = `${fileInput.files.length} files selected`; + fileLabelText.nodeValue = `${fileInput.files.length} files selected`; const newFiles = fileInput.files; for (let i = 0; i < newFiles.length; i++) { files.push(newFiles[i]); diff --git a/gulp/res/js/themelist.js b/gulp/res/js/themelist.js index ef15872b..5c6e4f68 100644 --- a/gulp/res/js/themelist.js +++ b/gulp/res/js/themelist.js @@ -1 +1 @@ -const themes = ['chaos', 'choc', 'gurochan', 'lain', 'makaba', 'navy', 'rei-zero', 'sushi', 'tomorrow', 'tomorrow2', 'yotsuba b', 'yotsuba'];const codeThemes = ['a11y-dark', 'a11y-light', 'agate', 'an-old-hope', 'androidstudio', 'arduino-light', 'arta', 'ascetic', 'atelier-cave-dark', 'atelier-cave-light', 'atelier-dune-dark', 'atelier-dune-light', 'atelier-estuary-dark', 'atelier-estuary-light', 'atelier-forest-dark', 'atelier-forest-light', 'atelier-heath-dark', 'atelier-heath-light', 'atelier-lakeside-dark', 'atelier-lakeside-light', 'atelier-plateau-dark', 'atelier-plateau-light', 'atelier-savanna-dark', 'atelier-savanna-light', 'atelier-seaside-dark', 'atelier-seaside-light', 'atelier-sulphurpool-dark', 'atelier-sulphurpool-light', 'atom-one-dark-reasonable', 'atom-one-dark', 'atom-one-light', 'brown-paper', 'brown-papersq', 'codepen-embed', 'color-brewer', 'darcula', 'dark', 'darkula', 'default', 'docco', 'dracula', 'far', 'foundation', 'github-gist', 'github', 'gml', 'googlecode', 'grayscale', 'gruvbox-dark', 'gruvbox-light', 'hopscotch', 'hybrid', 'idea', 'ir-black', 'isbl-editor-dark', 'isbl-editor-light', 'kimbie.dark', 'kimbie.light', 'lightfair', 'magula', 'mono-blue', 'monokai-sublime', 'monokai', 'night-owl', 'nord', 'obsidian', 'ocean', 'paraiso-dark', 'paraiso-light', 'pojoaque', 'pojoaque', 'purebasic', 'qtcreator_dark', 'qtcreator_light', 'railscasts', 'rainbow', 'routeros', 'school-book', 'school-book', 'shades-of-purple', 'solarized-dark', 'solarized-light', 'sunburst', 'tomorrow-night-blue', 'tomorrow-night-bright', 'tomorrow-night-eighties', 'tomorrow-night', 'tomorrow', 'vs', 'vs2015', 'xcode', 'xt256', 'zenburn'] \ No newline at end of file +const themes = ['chaos', 'choc', 'gurochan', 'lain', 'makaba', 'navy', 'rei-zero', 'sushi', 'tomorrow', 'tomorrow2', 'yotsuba b', 'yotsuba'];const codeThemes = ['a11y-dark', 'a11y-light', 'agate', 'an-old-hope', 'androidstudio', 'arduino-light', 'arta', 'ascetic', 'atelier-cave-dark', 'atelier-cave-light', 'atelier-dune-dark', 'atelier-dune-light', 'atelier-estuary-dark', 'atelier-estuary-light', 'atelier-forest-dark', 'atelier-forest-light', 'atelier-heath-dark', 'atelier-heath-light', 'atelier-lakeside-dark', 'atelier-lakeside-light', 'atelier-plateau-dark', 'atelier-plateau-light', 'atelier-savanna-dark', 'atelier-savanna-light', 'atelier-seaside-dark', 'atelier-seaside-light', 'atelier-sulphurpool-dark', 'atelier-sulphurpool-light', 'atom-one-dark-reasonable', 'atom-one-dark', 'atom-one-light', 'brown-paper', 'brown-papersq', 'codepen-embed', 'color-brewer', 'darcula', 'dark', 'darkula', 'default', 'docco', 'dracula', 'far', 'foundation', 'github-gist', 'github', 'gml', 'googlecode', 'gradient-dark', 'grayscale', 'gruvbox-dark', 'gruvbox-light', 'hopscotch', 'hybrid', 'idea', 'ir-black', 'isbl-editor-dark', 'isbl-editor-light', 'kimbie.dark', 'kimbie.light', 'lightfair', 'magula', 'mono-blue', 'monokai-sublime', 'monokai', 'night-owl', 'nord', 'obsidian', 'ocean', 'paraiso-dark', 'paraiso-light', 'pojoaque', 'pojoaque', 'purebasic', 'qtcreator_dark', 'qtcreator_light', 'railscasts', 'rainbow', 'routeros', 'school-book', 'school-book', 'shades-of-purple', 'solarized-dark', 'solarized-light', 'sunburst', 'tomorrow-night-blue', 'tomorrow-night-bright', 'tomorrow-night-eighties', 'tomorrow-night', 'tomorrow', 'vs', 'vs2015', 'xcode', 'xt256', 'zenburn'] \ No newline at end of file diff --git a/models/forms/makepost.js b/models/forms/makepost.js index 04d43e68..dbf8103f 100644 --- a/models/forms/makepost.js +++ b/models/forms/makepost.js @@ -90,14 +90,6 @@ module.exports = async (req, res, next) => { }); } } - if (res.locals.numFiles > maxFiles) { - await deleteTempFiles(req).catch(e => console.error); - return dynamicResponse(req, res, 400, 'message', { - 'title': 'Bad request', - 'message': `Too many files. Max files per post is ${maxFiles}.`, - 'redirect': redirect - }); - } //filters if (res.locals.permLevel > 1) { //global staff bypass filters const allContents = req.body.name+req.body.message+req.body.subject+req.body.email diff --git a/views/includes/filelabel.pug b/views/includes/filelabel.pug index 1c2dff85..942a2176 100644 --- a/views/includes/filelabel.pug +++ b/views/includes/filelabel.pug @@ -1 +1,4 @@ -label.jsonly.postform-style.filelabel(for='file') Upload/Drop/Paste file(s) +label.jsonly.postform-style.filelabel(for='file') + | Select/Drop/Paste file(s) + if board != null + small (Max #{board.settings.maxFiles})