mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-02-20 20:29:04 +00:00
Updated
Reduced album title max length from 280 to 70. Existing albums with longer titles will have their titles truncated in their public pages, but the original titles will still remain in db. "Load images for preview" will now properly display its saved value. Increased max parallel uploads to 10. "yarn develop" will now also restart safe if some Nunjuck templates are edited (_globals.njk, _layout.njk, and album.njk). Better meta tags generation. Bumped v1 version string.
This commit is contained in:
parent
e6d4d96693
commit
ea37e0b7d3
@ -12,7 +12,7 @@ const db = require('knex')(config.database)
|
||||
const self = {
|
||||
// Don't forget to update max length of text inputs in
|
||||
// home.js & dashboard.js when changing these values
|
||||
titleMaxLength: 280,
|
||||
titleMaxLength: 70,
|
||||
descMaxLength: 4000,
|
||||
|
||||
onHold: new Set()
|
||||
@ -21,7 +21,7 @@ const self = {
|
||||
const homeDomain = config.homeDomain || config.domain
|
||||
|
||||
const zipMaxTotalSize = parseInt(config.cloudflare.zipMaxTotalSize)
|
||||
const zipMaxTotalSizeBytes = config.cloudflare.zipMaxTotalSize * 1000000
|
||||
const zipMaxTotalSizeBytes = zipMaxTotalSize * 1e6
|
||||
const zipOptions = config.uploads.jsZipOptions
|
||||
|
||||
// Force 'type' option to 'nodebuffer'
|
||||
@ -32,8 +32,10 @@ if (zipOptions.streamFiles === undefined)
|
||||
zipOptions.streamFiles = true
|
||||
if (zipOptions.compression === undefined)
|
||||
zipOptions.compression = 'DEFLATE'
|
||||
if (zipOptions.compressionOptions === undefined || zipOptions.compressionOptions.level === undefined)
|
||||
zipOptions.compressionOptions = { level: 1 }
|
||||
if (zipOptions.compressionOptions === undefined)
|
||||
zipOptions.compressionOptions = {}
|
||||
if (zipOptions.compressionOptions.level === undefined)
|
||||
zipOptions.compressionOptions.level = 1
|
||||
|
||||
self.zipEmitters = new Map()
|
||||
|
||||
|
@ -76,7 +76,7 @@ const executeMulter = multer({
|
||||
delete req.body[key]
|
||||
}
|
||||
|
||||
if (req.body.chunkindex && !chunkedUploads)
|
||||
if (req.body.chunkindex !== undefined && !chunkedUploads)
|
||||
return cb('Chunked uploads are disabled at the moment.')
|
||||
else
|
||||
return cb(null, true)
|
||||
@ -111,8 +111,7 @@ const executeMulter = multer({
|
||||
return cb(null, name)
|
||||
}
|
||||
})
|
||||
}).array('files[]', {
|
||||
})
|
||||
}).array('files[]')
|
||||
|
||||
self.isExtensionFiltered = extname => {
|
||||
// If empty extension needs to be filtered
|
||||
@ -340,7 +339,7 @@ self.actuallyUploadUrls = async (req, res, user, albumid, age) => {
|
||||
})
|
||||
}
|
||||
|
||||
// If not errors found, clear cache of downloaded files
|
||||
// If no errors found, clear cache of downloaded files
|
||||
downloaded.length = 0
|
||||
|
||||
if (utils.clamd.scanner) {
|
||||
@ -467,6 +466,7 @@ self.actuallyFinishChunks = async (req, res, user) => {
|
||||
if (chunksData[file.uuid] !== undefined)
|
||||
// Continue even when encountering errors
|
||||
await self.cleanUpChunks(file.uuid).catch(logger.error)
|
||||
// Re-throw error
|
||||
throw error
|
||||
}
|
||||
}
|
||||
@ -492,8 +492,7 @@ self.combineChunks = async (destination, uuid) => {
|
||||
writeStream.end()
|
||||
|
||||
// Re-throw error
|
||||
if (errorObj)
|
||||
throw errorObj
|
||||
if (errorObj) throw errorObj
|
||||
}
|
||||
|
||||
self.cleanUpChunks = async (uuid) => {
|
||||
@ -700,8 +699,7 @@ self.list = async (req, res) => {
|
||||
const user = await utils.authorize(req, res)
|
||||
if (!user) return
|
||||
|
||||
// Headers is string-only, this seem to be the safest and lightest
|
||||
const all = req.headers.all === '1'
|
||||
const all = Boolean(req.headers.all)
|
||||
const filters = req.headers.filters
|
||||
const ismoderator = perms.is(user, 'moderator')
|
||||
if ((all || filters) && !ismoderator)
|
||||
|
@ -281,7 +281,7 @@ self.generateThumbs = async (name, extname, force) => {
|
||||
return false
|
||||
}
|
||||
} catch (error) {
|
||||
// Suppress error logging for errors these patterns
|
||||
// Suppress error logging for errors matching these patterns
|
||||
const errorString = error.toString()
|
||||
const suppress = [
|
||||
/Input file contains unsupported image format/,
|
||||
@ -683,7 +683,7 @@ self.stats = async (req, res, next) => {
|
||||
}
|
||||
|
||||
if (os.platform !== 'linux') {
|
||||
// If not Linux platform, rely on DB for total size
|
||||
// If not Linux platform, rely on DB for total size
|
||||
const uploads = await db.table('files')
|
||||
.select('size')
|
||||
stats.uploads.total = uploads.length
|
||||
|
2
dist/js/dashboard.js
vendored
2
dist/js/dashboard.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/dashboard.js.map
vendored
2
dist/js/dashboard.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/js/home.js
vendored
2
dist/js/home.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/home.js.map
vendored
2
dist/js/home.js.map
vendored
File diff suppressed because one or more lines are too long
@ -119,7 +119,10 @@ gulp.task('nodemon', done => {
|
||||
'config.js',
|
||||
'controllers/',
|
||||
'database/',
|
||||
'routes/'
|
||||
'routes/',
|
||||
'views/_globals.njk',
|
||||
'views/_layout.njk',
|
||||
'views/album.njk'
|
||||
],
|
||||
ext: 'js',
|
||||
done
|
||||
|
@ -86,7 +86,7 @@ const page = {
|
||||
isTriggerLoading: null,
|
||||
fadingIn: null,
|
||||
|
||||
albumTitleMaxLength: 280,
|
||||
albumTitleMaxLength: 70,
|
||||
albumDescMaxLength: 4000
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ const page = {
|
||||
imageExts: ['.webp', '.jpg', '.jpeg', '.bmp', '.gif', '.png', '.tiff', '.tif', '.svg'],
|
||||
videoExts: ['.webm', '.mp4', '.wmv', '.avi', '.mov', '.mkv'],
|
||||
|
||||
albumTitleMaxLength: 280,
|
||||
albumTitleMaxLength: 70,
|
||||
albumDescMaxLength: 4000
|
||||
}
|
||||
|
||||
@ -594,7 +594,7 @@ page.prepareUploadConfig = () => {
|
||||
|
||||
const numConfig = {
|
||||
chunkSize: { min: 1, max: 95 },
|
||||
parallelUploads: { min: 1, max: 8 }
|
||||
parallelUploads: { min: 1, max: 10 }
|
||||
}
|
||||
|
||||
document.querySelector('#chunkSizeDiv .help').innerHTML =
|
||||
@ -684,6 +684,7 @@ page.prepareUploadConfig = () => {
|
||||
}
|
||||
|
||||
page.previewImages = localStorage[lsKeys.previewImages] !== '0'
|
||||
if (!page.previewImages) document.querySelector('#previewImages').value = '0'
|
||||
|
||||
document.querySelector('#saveConfig').addEventListener('click', () => {
|
||||
if (!form.checkValidity())
|
||||
|
@ -15,7 +15,7 @@
|
||||
v3: CSS and JS files (libs such as bulma, lazyload, etc).
|
||||
v4: Renders in /public/render/* directories (to be used by render.js).
|
||||
#}
|
||||
{% set v1 = "iDzQ0dov5j" %}
|
||||
{% set v1 = "yUGjkyDjqU" %}
|
||||
{% set v2 = "hiboQUzAzp" %}
|
||||
{% set v3 = "iDzQ0dov5j" %}
|
||||
{% set v4 = "S3TAWpPeFS" %}
|
||||
|
@ -1,7 +1,17 @@
|
||||
{% import '_globals.njk' as globals %}
|
||||
{%- import '_globals.njk' as globals -%}
|
||||
|
||||
{# Set root domain here to inherit values from config file #}
|
||||
{% set root = config.homeDomain or config.domain %}
|
||||
{%- set root = config.homeDomain or config.domain -%}
|
||||
|
||||
{%- set title -%}
|
||||
{%- if metaTitle -%}
|
||||
{{ metaTitle + ' | ' + globals.name }}
|
||||
{%- else -%}
|
||||
{{ globals.name + ' – ' + globals.motto }}
|
||||
{%- endif %}
|
||||
{%- endset -%}
|
||||
|
||||
{%- set url = root + (metaUrl or '') -%}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
@ -12,11 +22,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
{% if title -%}
|
||||
<title>{{ title + ' | ' + globals.name }}</title>
|
||||
{%- else -%}
|
||||
<title>{{ globals.name + ' – ' + globals.motto }}</title>
|
||||
{%- endif %}
|
||||
<title>{{ title }}</title>
|
||||
|
||||
{% block stylesheets %}
|
||||
<!-- Stylesheets -->
|
||||
@ -26,10 +32,13 @@
|
||||
|
||||
{% block opengraph %}
|
||||
<!-- Open Graph tags -->
|
||||
<meta property="og:url" content="{{ root }}" />
|
||||
<meta property="og:url" content="{{ url }}" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="{{ globals.name }} – {{ globals.motto }}" />
|
||||
<meta property="og:description" content="{{ globals.description }}" />
|
||||
<meta property="og:title" content="{{ title }}" />
|
||||
<meta property="og:description" content="{{ metaDesc or globals.description }}" />
|
||||
{%- if metaImage %}
|
||||
<meta property="og:image" content="{{ metaImage }}" />
|
||||
{%- endif %}
|
||||
<meta property="og:image" content="{{ root }}/icons/600px.png?v={{ globals.v2 }}" />
|
||||
<meta property="og:image:width" content="600" />
|
||||
<meta property="og:image:height" content="600" />
|
||||
@ -40,9 +49,13 @@
|
||||
|
||||
<!-- Twitter Card tags -->
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="{{ globals.name }} – {{ globals.motto }}">
|
||||
<meta name="twitter:description" content="{{ globals.description }}">
|
||||
<meta name="twitter:title" content="{{ title }}">
|
||||
<meta name="twitter:description" content="{{ metaDesc or globals.description }}">
|
||||
{%- if metaImage %}
|
||||
<meta name="twitter:image" content="{{ metaImage }}">
|
||||
{% else %}
|
||||
<meta name="twitter:image" content="{{ root }}/icons/600px.png?v={{ globals.v2 }}">
|
||||
{%- endif %}
|
||||
{% endblock %}
|
||||
|
||||
<!-- Icons, configs, etcetera -->
|
||||
|
@ -1,7 +1,14 @@
|
||||
{% set title = album.name %}
|
||||
{% extends "_layout.njk" %}
|
||||
{% set metaTitle %}
|
||||
{{- album.name | truncate(60, true, '…') + ' – ' + files.length + ' file' + ('s' if files.length !== 1) -}}
|
||||
{% endset %}
|
||||
{% set metaDesc = album.description | truncate(200, true, '…') %}
|
||||
{% set metaUrl = '/' + album.url %}
|
||||
|
||||
{% set fileRoot = config.domain %}
|
||||
{% set metaImage = fileRoot + '/' + album.thumb %}
|
||||
|
||||
{% extends "_layout.njk" %}
|
||||
|
||||
{% set generateZips = config.uploads.generateZips %}
|
||||
{% set usingCdn = config.cloudflare and config.cloudflare.purgeCache %}
|
||||
|
||||
@ -22,22 +29,6 @@
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block opengraph %}
|
||||
<!-- Open Graph tags -->
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="{{ album.name | safe }} – {{ files.length }} files" />
|
||||
<meta property="og:url" content="{{ root }}/{{ album.url }}" />
|
||||
<meta property="og:description" content="{{ album.description }}" />
|
||||
<meta property="og:image" content="{{ fileRoot }}/{{ album.thumb }}" />
|
||||
<meta property="og:locale" content="en_US" />
|
||||
|
||||
<!-- Twitter Card tags -->
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="{{ album.name | safe }} – {{ files.length }} files">
|
||||
<meta name="twitter:description" content="{{ album.description }}">
|
||||
<meta name="twitter:image" content="{{ fileRoot }}/{{ album.thumb }}">
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ super() }}
|
||||
<section class="section">
|
||||
@ -46,7 +37,7 @@
|
||||
<div class="level-left">
|
||||
<div class="level-item">
|
||||
<h1 id="title" class="title">
|
||||
{{ album.name | safe }}
|
||||
{{ album.name | truncate(70, true, '…') }}
|
||||
</h1>
|
||||
</div>
|
||||
<div class="level-item">
|
||||
|
@ -1,4 +1,6 @@
|
||||
{% set title = "Auth" %}
|
||||
{% set metaTitle = "Auth" %}
|
||||
{% set metaUrl = '/auth' %}
|
||||
|
||||
{% extends "_layout.njk" %}
|
||||
|
||||
{% block stylesheets %}
|
||||
|
@ -1,4 +1,6 @@
|
||||
{% set title = "Dashboard" %}
|
||||
{% set metaTitle = "Dashboard" %}
|
||||
{% set metaUrl = '/dashboard' %}
|
||||
|
||||
{% extends "_layout.njk" %}
|
||||
|
||||
{% block stylesheets %}
|
||||
|
@ -1,4 +1,6 @@
|
||||
{% set title = "FAQ" %}
|
||||
{% set metaTitle = "FAQ" %}
|
||||
{% set metaUrl = '/faq' %}
|
||||
|
||||
{% extends "_layout.njk" %}
|
||||
|
||||
{% set noJsMaxSizeInt = config.cloudflare.noJsMaxSize | int %}
|
||||
|
@ -1,4 +1,6 @@
|
||||
{% set title = "No-JS uploader" %}
|
||||
{% set metaTitle = "No-JS uploader" %}
|
||||
{% set metaUrl = '/nojs' %}
|
||||
|
||||
{% extends "_layout.njk" %}
|
||||
|
||||
{% set private = config.private %}
|
||||
|
Loading…
Reference in New Issue
Block a user