mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-30 23:01:34 +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)
|
||||
// Homepage uploader will not use this (use dashboard instead)
|
||||
if (user) {
|
||||
map.deleteUrl = `${config.homeDomain}/file/${file.name}?delete`
|
||||
map.deleteUrl = `${utils.conf.homeDomain}/file/${file.name}?delete`
|
||||
}
|
||||
|
||||
return map
|
||||
|
@ -288,14 +288,11 @@ safe.use('/api', api)
|
||||
safe.get(`/${page === 'home' ? '' : page}`, (req, res, next) => res.sendFile(customPage))
|
||||
} else if (page === 'home') {
|
||||
safe.get('/', (req, res, next) => res.render(page, {
|
||||
config,
|
||||
versions: utils.versionStrings,
|
||||
gitHash: utils.gitHash
|
||||
config, utils, versions: utils.versionStrings
|
||||
}))
|
||||
} else {
|
||||
safe.get(`/${page}`, (req, res, next) => res.render(page, {
|
||||
config,
|
||||
versions: utils.versionStrings
|
||||
config, utils, versions: utils.versionStrings
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ routes.get('/a/:identifier', async (req, res, next) => {
|
||||
if (!utils.albumsCache[cacheid].cache && utils.albumsCache[cacheid].generating) {
|
||||
return res.render('album-notice', {
|
||||
config,
|
||||
utils,
|
||||
versions: utils.versionStrings,
|
||||
album,
|
||||
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', {
|
||||
config,
|
||||
utils,
|
||||
versions: utils.versionStrings,
|
||||
album,
|
||||
files,
|
||||
|
@ -7,8 +7,7 @@ routes.get([
|
||||
], async (req, res, next) => {
|
||||
// Uploads identifiers parsing, etc., are strictly handled by client-side JS at src/js/file.js
|
||||
return res.render('file', {
|
||||
config,
|
||||
versions: utils.versionStrings
|
||||
config, utils, versions: utils.versionStrings
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -6,8 +6,8 @@ const config = require('./../config')
|
||||
routes.get('/nojs', async (req, res, next) => {
|
||||
return res.render('nojs', {
|
||||
config,
|
||||
versions: utils.versionStrings,
|
||||
gitHash: utils.gitHash
|
||||
utils,
|
||||
versions: utils.versionStrings
|
||||
})
|
||||
})
|
||||
|
||||
@ -17,8 +17,8 @@ routes.post('/nojs', (req, res, next) => {
|
||||
const result = args[0]
|
||||
return res.render('nojs', {
|
||||
config,
|
||||
utils,
|
||||
versions: utils.versionStrings,
|
||||
gitHash: utils.gitHash,
|
||||
errorMessage: result.success ? '' : (result.description || 'An unexpected error occurred.'),
|
||||
files: result.files || [{}]
|
||||
})
|
||||
|
@ -8,8 +8,7 @@ routes.get([
|
||||
], async (req, res, next) => {
|
||||
// Uploads identifiers parsing, etc., are strictly handled by client-side JS at src/js/player.js
|
||||
return res.render('player', {
|
||||
config,
|
||||
versions: utils.versionStrings
|
||||
config, utils, versions: utils.versionStrings
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
{%- import '_globals.njk' as globals -%}
|
||||
|
||||
{# 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 -%}
|
||||
{%- if metaTitle -%}
|
||||
|
@ -4,7 +4,7 @@
|
||||
{% set metaDesc = album.description | striptags | truncate(200, true, '…') %}
|
||||
{% set metaUrl = '/' + album.url %}
|
||||
|
||||
{% set fileRoot = config.domain %}
|
||||
{% set fileRoot = utils.conf.domain %}
|
||||
{% set metaImage = fileRoot + '/' + album.thumb %}
|
||||
|
||||
{% extends "_layout.njk" %}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% set metaTitle = "File" %}
|
||||
|
||||
{% set uploadRoot = config.domain %}
|
||||
{% set uploadRoot = utils.conf.domain %}
|
||||
{% set titleFormat = '%identifier% | ' + globals.name %}
|
||||
|
||||
{% extends "_layout.njk" %}
|
||||
|
@ -184,11 +184,11 @@
|
||||
|
||||
{% include "_partial/links.njk" %}
|
||||
|
||||
{% if gitHash -%}
|
||||
{% if utils.gitHash -%}
|
||||
<div class="git-commit columns is-gapless">
|
||||
<div class="column is-hidden-mobile"></div>
|
||||
<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 class="column is-hidden-mobile"></div>
|
||||
</div>
|
||||
|
@ -82,11 +82,11 @@
|
||||
{% set plain_links = true %}
|
||||
{% include "_partial/links.njk" %}
|
||||
|
||||
{% if gitHash -%}
|
||||
{% if utils.gitHash -%}
|
||||
<div class="git-commit columns is-gapless">
|
||||
<div class="column is-hidden-mobile"></div>
|
||||
<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 class="column is-hidden-mobile"></div>
|
||||
</div>
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{% set metaTitle = "Player" %}
|
||||
|
||||
{% set uploadRoot = config.domain %}
|
||||
{% set uploadRoot = utils.conf.domain %}
|
||||
{% set titleFormat = '%identifier% | ' + globals.name %}
|
||||
|
||||
{% extends "_layout.njk" %}
|
||||
|
Loading…
Reference in New Issue
Block a user