mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-31 07:11:33 +00:00
feat: expose utils to nunjucks templates
also fix nunjucks templates not adhering to env vars overrides for domains config options, because they attempted to read config directly
This commit is contained in:
parent
de54eb92f2
commit
b117fa9ad1
@ -954,7 +954,7 @@ self.sendUploadResponse = async (req, res, user, result) => {
|
|||||||
// If uploaded by user, add delete URL (intended for ShareX and its derivatives)
|
// If uploaded by user, add delete URL (intended for ShareX and its derivatives)
|
||||||
// Homepage uploader will not use this (use dashboard instead)
|
// Homepage uploader will not use this (use dashboard instead)
|
||||||
if (user) {
|
if (user) {
|
||||||
map.deleteUrl = `${config.homeDomain}/file/${file.name}?delete`
|
map.deleteUrl = `${utils.conf.homeDomain}/file/${file.name}?delete`
|
||||||
}
|
}
|
||||||
|
|
||||||
return map
|
return map
|
||||||
|
@ -288,14 +288,11 @@ safe.use('/api', api)
|
|||||||
safe.get(`/${page === 'home' ? '' : page}`, (req, res, next) => res.sendFile(customPage))
|
safe.get(`/${page === 'home' ? '' : page}`, (req, res, next) => res.sendFile(customPage))
|
||||||
} else if (page === 'home') {
|
} else if (page === 'home') {
|
||||||
safe.get('/', (req, res, next) => res.render(page, {
|
safe.get('/', (req, res, next) => res.render(page, {
|
||||||
config,
|
config, utils, versions: utils.versionStrings
|
||||||
versions: utils.versionStrings,
|
|
||||||
gitHash: utils.gitHash
|
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
safe.get(`/${page}`, (req, res, next) => res.render(page, {
|
safe.get(`/${page}`, (req, res, next) => res.render(page, {
|
||||||
config,
|
config, utils, versions: utils.versionStrings
|
||||||
versions: utils.versionStrings
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ routes.get('/a/:identifier', async (req, res, next) => {
|
|||||||
if (!utils.albumsCache[cacheid].cache && utils.albumsCache[cacheid].generating) {
|
if (!utils.albumsCache[cacheid].cache && utils.albumsCache[cacheid].generating) {
|
||||||
return res.render('album-notice', {
|
return res.render('album-notice', {
|
||||||
config,
|
config,
|
||||||
|
utils,
|
||||||
versions: utils.versionStrings,
|
versions: utils.versionStrings,
|
||||||
album,
|
album,
|
||||||
notice: 'This album\'s public page is still being generated. Please try again later.'
|
notice: 'This album\'s public page is still being generated. Please try again later.'
|
||||||
@ -81,6 +82,7 @@ routes.get('/a/:identifier', async (req, res, next) => {
|
|||||||
|
|
||||||
return res.render('album', {
|
return res.render('album', {
|
||||||
config,
|
config,
|
||||||
|
utils,
|
||||||
versions: utils.versionStrings,
|
versions: utils.versionStrings,
|
||||||
album,
|
album,
|
||||||
files,
|
files,
|
||||||
|
@ -7,8 +7,7 @@ routes.get([
|
|||||||
], async (req, res, next) => {
|
], async (req, res, next) => {
|
||||||
// Uploads identifiers parsing, etc., are strictly handled by client-side JS at src/js/file.js
|
// Uploads identifiers parsing, etc., are strictly handled by client-side JS at src/js/file.js
|
||||||
return res.render('file', {
|
return res.render('file', {
|
||||||
config,
|
config, utils, versions: utils.versionStrings
|
||||||
versions: utils.versionStrings
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ const config = require('./../config')
|
|||||||
routes.get('/nojs', async (req, res, next) => {
|
routes.get('/nojs', async (req, res, next) => {
|
||||||
return res.render('nojs', {
|
return res.render('nojs', {
|
||||||
config,
|
config,
|
||||||
versions: utils.versionStrings,
|
utils,
|
||||||
gitHash: utils.gitHash
|
versions: utils.versionStrings
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -17,8 +17,8 @@ routes.post('/nojs', (req, res, next) => {
|
|||||||
const result = args[0]
|
const result = args[0]
|
||||||
return res.render('nojs', {
|
return res.render('nojs', {
|
||||||
config,
|
config,
|
||||||
|
utils,
|
||||||
versions: utils.versionStrings,
|
versions: utils.versionStrings,
|
||||||
gitHash: utils.gitHash,
|
|
||||||
errorMessage: result.success ? '' : (result.description || 'An unexpected error occurred.'),
|
errorMessage: result.success ? '' : (result.description || 'An unexpected error occurred.'),
|
||||||
files: result.files || [{}]
|
files: result.files || [{}]
|
||||||
})
|
})
|
||||||
|
@ -8,8 +8,7 @@ routes.get([
|
|||||||
], async (req, res, next) => {
|
], async (req, res, next) => {
|
||||||
// Uploads identifiers parsing, etc., are strictly handled by client-side JS at src/js/player.js
|
// Uploads identifiers parsing, etc., are strictly handled by client-side JS at src/js/player.js
|
||||||
return res.render('player', {
|
return res.render('player', {
|
||||||
config,
|
config, utils, versions: utils.versionStrings
|
||||||
versions: utils.versionStrings
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{%- import '_globals.njk' as globals -%}
|
{%- import '_globals.njk' as globals -%}
|
||||||
|
|
||||||
{# Set root domain here to inherit values from config file #}
|
{# Set root domain here to inherit values from config file #}
|
||||||
{%- set root = config.homeDomain or config.domain -%}
|
{%- set root = utils.conf.homeDomain or utils.conf.domain -%}
|
||||||
|
|
||||||
{%- set title -%}
|
{%- set title -%}
|
||||||
{%- if metaTitle -%}
|
{%- if metaTitle -%}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{% set metaDesc = album.description | striptags | truncate(200, true, '…') %}
|
{% set metaDesc = album.description | striptags | truncate(200, true, '…') %}
|
||||||
{% set metaUrl = '/' + album.url %}
|
{% set metaUrl = '/' + album.url %}
|
||||||
|
|
||||||
{% set fileRoot = config.domain %}
|
{% set fileRoot = utils.conf.domain %}
|
||||||
{% set metaImage = fileRoot + '/' + album.thumb %}
|
{% set metaImage = fileRoot + '/' + album.thumb %}
|
||||||
|
|
||||||
{% extends "_layout.njk" %}
|
{% extends "_layout.njk" %}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{% set metaTitle = "File" %}
|
{% set metaTitle = "File" %}
|
||||||
|
|
||||||
{% set uploadRoot = config.domain %}
|
{% set uploadRoot = utils.conf.domain %}
|
||||||
{% set titleFormat = '%identifier% | ' + globals.name %}
|
{% set titleFormat = '%identifier% | ' + globals.name %}
|
||||||
|
|
||||||
{% extends "_layout.njk" %}
|
{% extends "_layout.njk" %}
|
||||||
|
@ -184,11 +184,11 @@
|
|||||||
|
|
||||||
{% include "_partial/links.njk" %}
|
{% include "_partial/links.njk" %}
|
||||||
|
|
||||||
{% if gitHash -%}
|
{% if utils.gitHash -%}
|
||||||
<div class="git-commit columns is-gapless">
|
<div class="git-commit columns is-gapless">
|
||||||
<div class="column is-hidden-mobile"></div>
|
<div class="column is-hidden-mobile"></div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<span>Git commit: </span><a href="https://github.com/BobbyWibowo/lolisafe/commit/{{ gitHash }}" target="_blank" rel="noopener">{{ gitHash }}</a>
|
<span>Git commit: </span><a href="https://github.com/BobbyWibowo/lolisafe/commit/{{ utils.gitHash }}" target="_blank" rel="noopener">{{ utils.gitHash }}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-hidden-mobile"></div>
|
<div class="column is-hidden-mobile"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -82,11 +82,11 @@
|
|||||||
{% set plain_links = true %}
|
{% set plain_links = true %}
|
||||||
{% include "_partial/links.njk" %}
|
{% include "_partial/links.njk" %}
|
||||||
|
|
||||||
{% if gitHash -%}
|
{% if utils.gitHash -%}
|
||||||
<div class="git-commit columns is-gapless">
|
<div class="git-commit columns is-gapless">
|
||||||
<div class="column is-hidden-mobile"></div>
|
<div class="column is-hidden-mobile"></div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<span>Git commit: </span><a href="https://github.com/BobbyWibowo/lolisafe/commit/{{ gitHash }}" target="_blank" rel="noopener">{{ gitHash }}</a>
|
<span>Git commit: </span><a href="https://github.com/BobbyWibowo/lolisafe/commit/{{ utils.gitHash }}" target="_blank" rel="noopener">{{ utils.gitHash }}</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-hidden-mobile"></div>
|
<div class="column is-hidden-mobile"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
{% set metaTitle = "Player" %}
|
{% set metaTitle = "Player" %}
|
||||||
|
|
||||||
{% set uploadRoot = config.domain %}
|
{% set uploadRoot = utils.conf.domain %}
|
||||||
{% set titleFormat = '%identifier% | ' + globals.name %}
|
{% set titleFormat = '%identifier% | ' + globals.name %}
|
||||||
|
|
||||||
{% extends "_layout.njk" %}
|
{% extends "_layout.njk" %}
|
||||||
|
Loading…
Reference in New Issue
Block a user