From 6960cc75fa8a92310121972f2d76128737bbe9fc Mon Sep 17 00:00:00 2001 From: timvisee Date: Wed, 27 Jan 2021 00:13:56 +0100 Subject: [PATCH] Add configurable donate, CLI and DMCA and source links in footer --- android/android.js | 3 +- app/main.js | 1 + app/ui/footer.js | 58 ++++++++++++++++++++++++++++++++--- app/ui/header.js | 1 + public/locales/en-GB/send.ftl | 3 ++ public/locales/en-US/send.ftl | 3 ++ public/locales/nl/send.ftl | 3 ++ server/clientConstants.js | 6 ++++ server/config.js | 20 ++++++++++++ server/initScript.js | 1 + server/storage/s3.js | 8 +++-- 11 files changed, 98 insertions(+), 9 deletions(-) diff --git a/android/android.js b/android/android.js index 22069ea1..033c0581 100644 --- a/android/android.js +++ b/android/android.js @@ -69,9 +69,10 @@ function body(main) { (async function start() { const translate = await getTranslator('en-US'); setTranslate(translate); - const { LIMITS, DEFAULTS } = await getConstants(); + const { LIMITS, WEB_UI, DEFAULTS } = await getConstants(); app.use(state => { state.LIMITS = LIMITS; + state.WEB_UI = WEB_UI; state.DEFAULTS = DEFAULTS; state.translate = translate; state.capabilities = { diff --git a/app/main.js b/app/main.js index 1519a122..56078d4f 100644 --- a/app/main.js +++ b/app/main.js @@ -51,6 +51,7 @@ if (process.env.NODE_ENV === 'production') { window.initialState = { LIMITS, DEFAULTS, + WEB_UI, PREFS, archive: new Archive([], DEFAULTS.EXPIRE_SECONDS), capabilities, diff --git a/app/ui/footer.js b/app/ui/footer.js index a8bdb18b..10296a72 100644 --- a/app/ui/footer.js +++ b/app/ui/footer.js @@ -13,6 +13,58 @@ class Footer extends Component { createElement() { const translate = this.state.translate; + + // Add additional links from configuration if available + var links = []; + if (this.state != undefined && this.state.WEB_UI != undefined) { + const WEB_UI = this.state.WEB_UI; + + if (WEB_UI.FOOTER_DONATE_URL != '') { + links.push(html` +
  • + + ${translate('footerLinkDonate')} + +
  • + `); + } + if (WEB_UI.FOOTER_CLI_URL != '') { + links.push(html` +
  • + + ${translate('footerLinkCli')} + +
  • + `); + } + if (WEB_UI.FOOTER_DMCA_URL != '') { + links.push(html` +
  • + + ${translate('footerLinkDmca')} + +
  • + `); + } + if (WEB_UI.FOOTER_SOURCE_URL != '') { + links.push(html` +
  • + + ${translate('footerLinkSource')} + +
  • + `); + } + } else { + links.push(html` +
  • + + ${translate('footerLinkSource')} + +
  • + `); + } + return html` `; diff --git a/app/ui/header.js b/app/ui/header.js index 4ab38033..c6edc5e1 100644 --- a/app/ui/header.js +++ b/app/ui/header.js @@ -16,6 +16,7 @@ class Header extends Component { this.account.render(); return false; } + createElement() { const title = platform() === 'android' diff --git a/public/locales/en-GB/send.ftl b/public/locales/en-GB/send.ftl index 4c3f1173..1fb7a3f8 100644 --- a/public/locales/en-GB/send.ftl +++ b/public/locales/en-GB/send.ftl @@ -29,6 +29,9 @@ updateFirefox = Update Firefox deletePopupCancel = Cancel deleteButtonHover = Delete footerText = Not affiliated with Mozilla or Firefox. +footerLinkDonate = Donate +footerLinkCli = CLI +footerLinkDmca = DMCA footerLinkSource = Source passwordTryAgain = Incorrect password. Try again. javascriptRequired = Send requires JavaScript diff --git a/public/locales/en-US/send.ftl b/public/locales/en-US/send.ftl index e974d379..36e482f4 100644 --- a/public/locales/en-US/send.ftl +++ b/public/locales/en-US/send.ftl @@ -27,6 +27,9 @@ updateFirefox = Update Firefox deletePopupCancel = Cancel deleteButtonHover = Delete footerText = Not affiliated with Mozilla or Firefox. +footerLinkDonate = Donate +footerLinkCli = CLI +footerLinkDmca = DMCA footerLinkSource = Source passwordTryAgain = Incorrect password. Try again. javascriptRequired = Send requires JavaScript diff --git a/public/locales/nl/send.ftl b/public/locales/nl/send.ftl index 5ddfc047..2344244f 100644 --- a/public/locales/nl/send.ftl +++ b/public/locales/nl/send.ftl @@ -29,6 +29,9 @@ updateFirefox = Firefox bijwerken deletePopupCancel = Annuleren deleteButtonHover = Verwijderen footerText = Niet aangesloten aan Mozilla of Firefox. +footerLinkDonate = Doneren +footerLinkCli = CLI +footerLinkDmca = DMCA footerLinkSource = Broncode passwordTryAgain = Onjuist wachtwoord. Probeer het opnieuw. javascriptRequired = Send vereist JavaScript diff --git a/server/clientConstants.js b/server/clientConstants.js index 0df501c2..0ac85d86 100644 --- a/server/clientConstants.js +++ b/server/clientConstants.js @@ -13,6 +13,12 @@ module.exports = { MAX_FILES_PER_ARCHIVE: config.max_files_per_archive, MAX_ARCHIVES_PER_USER: config.max_archives_per_user }, + WEB_UI: { + FOOTER_DONATE_URL: config.footer_donate_url, + FOOTER_CLI_URL: config.footer_cli_url, + FOOTER_DMCA_URL: config.footer_dmca_url, + FOOTER_SOURCE_URL: config.footer_source_url + }, DEFAULTS: { DOWNLOAD_COUNTS: config.download_counts, EXPIRE_TIMES_SECONDS: config.expire_times_seconds, diff --git a/server/config.js b/server/config.js index 77c01c8d..294e888a 100644 --- a/server/config.js +++ b/server/config.js @@ -194,6 +194,26 @@ const conf = convict({ format: String, default: '', env: 'IP_DB' + }, + footer_donate_url: { + format: String, + default: '', + env: 'SEND_FOOTER_DONATE_URL' + }, + footer_cli_url: { + format: String, + default: 'https://github.com/timvisee/ffsend', + env: 'SEND_FOOTER_CLI_URL' + }, + footer_dmca_url: { + format: String, + default: '', + env: 'SEND_FOOTER_DMCA_URL' + }, + footer_source_url: { + format: String, + default: 'https://github.com/timvisee/send', + env: 'SEND_FOOTER_CLI_URL' } }); diff --git a/server/initScript.js b/server/initScript.js index 2c4ae413..59e4c402 100644 --- a/server/initScript.js +++ b/server/initScript.js @@ -43,6 +43,7 @@ module.exports = function(state) { } var LIMITS = ${JSON.stringify(clientConstants.LIMITS)}; + var WEB_UI = ${JSON.stringify(clientConstants.WEB_UI)}; var DEFAULTS = ${JSON.stringify(clientConstants.DEFAULTS)}; var PREFS = ${JSON.stringify(state.prefs)}; var downloadMetadata = ${ diff --git a/server/storage/s3.js b/server/storage/s3.js index b181e548..f9a7caae 100644 --- a/server/storage/s3.js +++ b/server/storage/s3.js @@ -6,9 +6,9 @@ class S3Storage { this.log = log; const cfg = {}; if (config.s3_endpoint != '') { - cfg['endpoint'] = config.s3_endpoint; + cfg['endpoint'] = config.s3_endpoint; } - cfg['s3ForcePathStyle'] = config.s3_use_path_style_endpoint + cfg['s3ForcePathStyle'] = config.s3_use_path_style_endpoint; AWS.config.update(cfg); this.s3 = new AWS.S3(); } @@ -21,7 +21,9 @@ class S3Storage { } getStream(id) { - return this.s3.getObject({ Bucket: this.bucket, Key: id }).createReadStream(); + return this.s3 + .getObject({ Bucket: this.bucket, Key: id }) + .createReadStream(); } set(id, file) {