Add customizable notice on main page and in downloads list

This commit is contained in:
timvisee 2025-04-23 10:07:40 +02:00
parent c71100c82a
commit d0f21e8078
No known key found for this signature in database
GPG key ID: B8DB720BC383E172
4 changed files with 37 additions and 0 deletions

View file

@ -1,4 +1,5 @@
const html = require('choo/html'); const html = require('choo/html');
const raw = require('choo/html/raw');
const { list } = require('../utils'); const { list } = require('../utils');
const archiveTile = require('./archiveTile'); const archiveTile = require('./archiveTile');
const modal = require('./modal'); const modal = require('./modal');
@ -16,7 +17,19 @@ module.exports = function(state, emit) {
} else { } else {
left = archiveTile.empty(state, emit); left = archiveTile.empty(state, emit);
} }
if (archives.length > 0 && state.WEB_UI.DOWNLOAD_LIST_NOTICE_HTML) {
archives.push(html`
<p
class="w-full p-2 border-default dark:border-grey-70 rounded-default text-orange-60 bg-yellow-40 text-center leading-normal"
>
${raw(state.WEB_UI.DOWNLOAD_LIST_NOTICE_HTML)}
</p>
`);
}
archives.reverse(); archives.reverse();
const right = const right =
archives.length === 0 archives.length === 0
? intro(state) ? intro(state)

View file

@ -1,6 +1,17 @@
const html = require('choo/html'); const html = require('choo/html');
const raw = require('choo/html/raw');
module.exports = function intro(state) { module.exports = function intro(state) {
const notice = state.WEB_UI.MAIN_NOTICE_HTML
? html`
<p
class="w-full mt-8 p-2 border-default dark:border-grey-70 rounded-default text-orange-60 bg-yellow-40 text-center leading-normal"
>
${raw(state.WEB_UI.MAIN_NOTICE_HTML)}
</p>
`
: '';
return html` return html`
<send-intro <send-intro
class="flex flex-col items-center justify-center bg-white px-6 md:py-0 py-6 mb-0 h-full w-full dark:bg-grey-90" class="flex flex-col items-center justify-center bg-white px-6 md:py-0 py-6 mb-0 h-full w-full dark:bg-grey-90"
@ -12,6 +23,7 @@ module.exports = function intro(state) {
<p class="max-w-sm leading-loose mt-6 md:mt-2 md:pr-14"> <p class="max-w-sm leading-loose mt-6 md:mt-2 md:pr-14">
${state.translate('introDescription')} ${state.translate('introDescription')}
</p> </p>
${notice}
</div> </div>
</send-intro> </send-intro>
`; `;

View file

@ -15,7 +15,9 @@ module.exports = {
FOOTER_SOURCE_URL: config.footer_source_url, FOOTER_SOURCE_URL: config.footer_source_url,
CUSTOM_FOOTER_TEXT: config.custom_footer_text, CUSTOM_FOOTER_TEXT: config.custom_footer_text,
CUSTOM_FOOTER_URL: config.custom_footer_url, CUSTOM_FOOTER_URL: config.custom_footer_url,
MAIN_NOTICE_HTML: config.main_notice_html,
UPLOAD_AREA_WARNING_HTML: config.upload_area_warning_html, UPLOAD_AREA_WARNING_HTML: config.upload_area_warning_html,
DOWNLOAD_LIST_NOTICE_HTML: config.download_list_notice_html,
DOWNLOAD_WARNING_HTML: config.download_warning_html, DOWNLOAD_WARNING_HTML: config.download_warning_html,
COLORS: { COLORS: {
PRIMARY: config.ui_color_primary, PRIMARY: config.ui_color_primary,

View file

@ -264,11 +264,21 @@ const conf = convict({
default: '', default: '',
env: 'CUSTOM_FOOTER_URL' env: 'CUSTOM_FOOTER_URL'
}, },
main_notice_html: {
format: String,
default: '',
env: 'SEND_MAIN_NOTICE_HTML'
},
upload_area_warning_html: { upload_area_warning_html: {
format: String, format: String,
default: '', default: '',
env: 'SEND_UPLOAD_AREA_WARNING_HTML' env: 'SEND_UPLOAD_AREA_WARNING_HTML'
}, },
download_list_notice_html: {
format: String,
default: '',
env: 'SEND_DOWNLOAD_LIST_NOTICE_HTML'
},
download_warning_html: { download_warning_html: {
format: String, format: String,
default: '', default: '',