Previously album pages would still use utils.getPrettyBytes(), but one of the previous commits got rid of it in favor of client-side solution.
I forgot to update album pages to also use client-side solution, but this commit fixes it.
On a side note, I also switched all instances of consts to var in the function.
Moved page.prepareShareX() to a single JS file named sharex.js. It'll be loaded in home and dashboard pages, and both home.js and dashboard.js will rely on the function provided by it.
The generated ShareX config file will also properly support cases where the safe is being hosted in a subdir now (e.i. https://example.com/lolisafe).
Moved utils.getPrettyBytes() and utils.getPrettySize() to client's dashboard.js.
Thus, server will no longer return prettified size and date (it'll be prettified by the client instead).
To be honest, I don't even know why I had them in server-side, it's obviously better this way.
Add to album prompt will no longer ask for confirmation (i.e. Are you sure?), instead it will go directly to album selection. If you don't want to continue, you can always press Cancel.
Updated version string in _globals.njk.
* Added "ShareX user profile" menu item to administration sidebar. This do the same thing as the ShareX icon in the homepage, which is to download a ShareX config.
* Updated version string in _globals.njk. A few of the previous commits also modified some JS files, but I forgot to update the version string back then.
I can't remember why I extended the config with "eslint:recommended" instead of "standard" back then. I know I wanted to force an older ecmaversion, but even then it would still work just fine with standard.
I've fixed it now to use standard. I've also applied auto-fix to dashboard.js and home.js, which fixed some stray or missing whitespaces, as well as the indenting of case's inside switch statement.
* Downgraded ecma version of client-side scripts to v5. This change means no more backtick strings and some others.
* Massively modified auth.js, dashboard.js and home.js to support the downgrade (dashboard.js had the most changes).
* Removed enter key event handler from auth page. The previous code had some small issues. I'd rather not have the handler than let the issues persist. I'll eventually look into adding this again in the future.
* Updated uploadController.js to handle some invalid requests into /api/delete and /api/bulkdelete.
Experimental changes:
* No more elements with "onclick" attribute.
* Form can now be submitted with Enter button as long as both the user and the pass inputs are filled.
This commit is intended to downgrade codes in JS files used for browser to increase browsers compatibility.
This branch is still experimental and may require much more testing.
* Some structure updates to the homepage and the No-JS uploader form. Making them both somewhat look better, especially in terms of spacing.
* Upload URLs form will now show an error alert when there the form is empty or only filled with whitespaces.
* Upload URLs form will now automatically remove empty lines or lines that consist of only whitespaces when the upload button is pressed.
* Added globals.v3 to _globals.njk, which will be used for CSS/JS files of libs (bulma, lazyload, etc.). globals.v1 will now only be used for lolisafe's JS and CSS files.
Since CSS/JS files of libs receive much less updates than lolisafe's (mainly since I push updates a lot), this will decrease the amount of files that users need to re-fetch on every updates.
* Added public/js/album.js which will be used by album.njk (albums public link). I'm going to disable inline scripts in safe.fiery.me.
* Better FAQ. Some points will now dynamically changes depending on the settings you have in your config.js. It's not perfect but certainly much better than before.
* Cache selected album the exact moment "Upload URLs" button is pressed, so that any in progress requests will not have its album id altered.
* All URLs will now be displayed in the uploads list (the thing in between upload buttons and footer links) the moment "Upload URLs" button is pressed. Previously it would only show the URLs one by one after each finished request.
Brief video: https://i.fiery.me/AByv.mp4.
* Added upload by URLs. It has its own max size (config.uploads.urlMaxSize), make sure your config matches config.sample.js.
Here's a brief video showing it in action: https://i.fiery.me/CUhQ.mp4.
* /api/upload now supports uploading by URLs. Devs will only need to POST a JSON request containing a key named "urls", which is an array of the urls to upload.
* Added file extension filter to /api/upload/finishchunks.
* Added proper total chunks size check to /api/upload/finishchunks.
* Various code improvements.
NOTICE: Please update your config.js. Use config.sample.js as the template.
There were a couple of renames and restructures.
* Album zipper API route will now internally save its state when it's generating zip files, and any subsequent requests will silently be "postponed" until the first spawned task is finished. This will guarantee that there are no multiple zipping tasks for the same album. The method may seem a bit hackish though.
* All instances of console.log(error) were replaced with console.error(error). This will guarantee that any error goes to stderr instead of stdout.
* Deleting file by names will now properly remove successful files from the textarea. There was a logic flaw.
* Failure to generate thumbnails will no longer print the full stack, but instead only the error message. It will also then symlink a template image from /public/images/unavailable.png (it's only a simple image that says that it failed to generate thumbnail).
This haven't been tested in Windows machines, but it'll probably work fine.
I thought of adding a new column to files table which will store information whether the thumbnail generation is sucessful or not, but oh well, I'll go with this method for now.
* Added "create new album" button at homepage uploader. Due to this, albums list will always be shown even when you don't have any albums (and of course the list will be empty).
Preview: https://i.fiery.me/ITQ5.mp4 (ignore the fact that the prompt says "Edit album", it's been fixed before this commit goes live)
* Refactored various bits of the codes to use async/await instead of Promise.then. This will obviously cause the browser's requirement to raise but hell, it's the modern browsers age.
* Various other code improvements.
* Updated API route: /upload/bulkdelete.
It now accepts an additional property named "field". In it you can now enter either "id" or "name", which will set whether it will bulk delete by ids or names respectively. It also no longer accepts property named "ids", instead it has to be named "values" (which of course is an array of either ids or names). So yeah, now the API route can be used to bulk delete by ids and names.
In the future this will be expanded to bulk deleting files by username (only accessible by root of course).
* Added a form to bulk delete files by names for the hardcore user, like me (https://i.fiery.me/AHph.png).
* Some design update. Mainly forms restructuring aimed at tight screens.
* Changing file name length, requesting new token and setting new password will no longer reload the dashboard page on success. Instead it will simply silently reload the form.
* utils.bulkDeleteFilesByIds() replaced by utils.bulkDeleteFiles() which now can either by ids or names. This will be the one that will eventually be extended for deleting by username.
* Various other code improvements.
* View thumbnail button will now use SweetAlert instead of Bulma's modal (preview: https://i.fiery.me/HDwX.png). It can be made more pretty but this will do for now.
* Fixed a bug where "Copy link to clipboard" button in albums list would only copy its identifier instead of the full URL.
Some other code improvements:
* All instances of adding/removing class names with Element.className will now use Element.classList. So instead of appending and replacing the string, it will now use add/remove functions, thus making it much easier to understand.
* "onkeypress" in auth page moved into a single addEventListener, sort of.
* Removed VSCode's discord extension entry from workspace settings. Eh, I'll go with user settings for this one.
* A bunch of refactors in public JS files (home.js, dashboard.js, etcetera).
* Added lazyload to home page (for thumbs of uploaded images), dashboard (for thumbs view) and albums' public link.
Albums' public link will silently fallback to loading all thumbs at once if JavaScript is disabled.
* A bunch of others code improvements. Honestly I'm too lazy to track all the changes.
Bulk deleting files and adding/removing selected files from album will no longer refresh the current view to the first page. It will now instead try to refresh the current page. There will be cases where the current page ends up empty (when bulk deleting or moving files from the current album), but I figured that isn't much of an issue when compared with the advantages.
Improvements related to albums:
* Changed "rename album" option with a better "edit album" feature. With it you can also disable download or public link and even request a new public link (https://i.fiery.me/fz1y.png).
This also adds a new API route: /api/albums/edit.
The old API route, /api/albums/rename, is still available but will silently be using the new API in backend.
* Deleting album will now also delete its zip archive if exists.
* Renaming albums will also rename its zip archive if exists.
* Generating zip will use async fs.readFile instead of fs.readFileSync. This should improve generating speed somewhat.
* The codes that tries to generate random identifier for album will now check whether an album with the same identifier already exists. It will also rely on "uploads.maxTries" config option to limit how many times it will try to re-generate a new random identifier.
* Added a new config option "uploads.albumIdentifierLength" which sets the length of the randomly generated identifier.
* Added "download" and "public" columns to "albums" table in database/db.js.
Existing users can run "node database/migration.js" to add the columns.
Others:
* uploadsController.getUniqueRandomName will no longer accept 3 paramters (previously it would accept a callback in the third parameter). It will now instead return a Promise.
* Album name of disabled/deleted albums will no longer be shown in uploads list.
* Added "fileLength" column to "users" table in database/db.js.
* Renamed HTTP404.html and HTTP500.html in /pages/error to 404.html and 500.html respectively. I'm still using symlinks though.
* Added a new CSS named sweetalert.css which will be used in homepage, auth and dashboard. It will style all sweetalert modals with dark theme (matching the current color scheme used in this branch).
* Updated icons (added download icon).
* Some other improvements/tweaks here and there.
* Better thumbnails view in album page (it's now using the same styling as the one in dashboard, minus the on-hover effects and uploader/album names).
* Fixed unenclosed p tag in thumbs view at dashboard.js. It did not cause any issue because it's optional to enclose it, but oh well.
* Added "short_name" to manifest.json.
* Added 512px icon to manifest.json.
* Increased brightness of links to satisfy WCAG 2 AA standard.
* Added 'rel="noopener"' to all instances of a[target="_blank"].
* Added 'alt' to all instances of img.
* Updated static files' version string yet again.
* Added 'lang="en"' to html (_layout.njk).
* Dashboard will now display "N/A" when the file does not have an extension. Previously it would display the full name, which was of course a mistake.
* Updated static files' version string again.
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.
* Added Firefox extension link. For now this will simply link my fork of the Chrome extension. You will have to build the extension by your own.
* Updated icons (added Firefox).
* Tiny refactor in home.js, thus I had to update version string in _globals.njk as well.
* Main upload button will no longer be "loading" if an error occurs with the API check request.
* It will now show a message asking user to try out the No-JS uploader when JavaScript is disabled.
* 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.
* Refactored all instances of "failedIds" and "albumIds" to "failedids" and "albumids" respectively. Abandoning camel case for these ones.
* Refactored the way it looks into which albums the files are supposed to be added into.
For /api/upload/finishchunks, you can add "albumid" to each object in files[] to specify which album you want the finsihed chunks to be added into. Each object may have different album IDs.
For /api/upload, which is regular uploads, unfortunately you can only choose one album at a time (by adding "albumid" to the request headers, like usual). It uses the same function as the one used for finishchunks to add the files into album, so it shouldn't be hard to extend this ability to regular uploads, someday in the future.
* Fixed a bug in /api/upload/finishchunks. Previously you couldn't ever get it to work.
* Updated error message when successful uploads could not be added to album.
* "albumid" will no longer be added to request headers if they are chunked uploads. They'd have been ignored anyways.
* Updated eslint-plugin-import dev dependency.
* Added 2 new ESLint rules: "prefer-const" and "object-shorthand".
* Refactor all JS files to follow the new ESLint rules.
* Refactored all instances of for-i into for-of wherever applicable.
* New uploads that can NOT be added to an album, for whatever reason, will print out message that they can not be added to the said album, but their links will still also be shown underneath the message. Previously it would only print out the message but not the link.
* Improved uploadController.processFilesForDisplay(). Previously it would loop through all uploaded files and update album info for EVERY file, even though to begin with it was designed so that every call would only have to access ONE album. So yeah, this time it will only update album info ONCE no matter how many files are being processed in that session.