From 57ea5f0b280a07474416a598ba36e98a1b0fdb39 Mon Sep 17 00:00:00 2001 From: Uli Roth Date: Tue, 24 Sep 2024 10:23:53 +0200 Subject: [PATCH] added imprint_html option --- README.md | 4 +-- packages/backend/src/config.rs | 4 +++ packages/backend/src/status/mod.rs | 2 ++ packages/cli/src/shared/api.ts | 1 + packages/frontend/src/lib/views/Footer.svelte | 2 ++ .../frontend/src/routes/imprint/+page.svelte | 35 +++++++++++++++++++ 6 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 packages/frontend/src/routes/imprint/+page.svelte diff --git a/README.md b/README.md index 6c4c085..3c3d695 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,8 @@ of the notes even if it tried to. | `THEME_PAGE_TITLE` | `""` | Custom text the page title | | `THEME_FAVICON` | `""` | Custom url for the favicon. Must be publicly reachable | | `THEME_NEW_NOTE_NOTICE` | `true` | Show the message about how notes are stored in the memory and may be evicted after creating a new note. Defaults to `true`. | -| `IMPRINT_URL` | `""` | Custom url for an Imprint hosted somewhere else. Must be publicly reachable. | - +| `IMPRINT_URL` | `""` | Custom url for an Imprint hosted somewhere else. Must be publicly reachable. Takes precedence above `IMPRINT_HTML`. | +| `IMPRINT_HTML` | `""` | Alternative to `IMPRINT_URL`, this can be used to specify the HTML code to show on `/imprint`. Only `IMPRINT_HTML` or `IMPRINT_URL` should be specified, not both.| ## Deployment > ℹ️ `https` is required otherwise browsers will not support the cryptographic functions. diff --git a/packages/backend/src/config.rs b/packages/backend/src/config.rs index 6dbd700..318b66f 100644 --- a/packages/backend/src/config.rs +++ b/packages/backend/src/config.rs @@ -42,6 +42,10 @@ pub static ref IMPRINT_URL: String = std::env::var("IMPRINT_URL") .unwrap_or("".to_string()) .parse() .unwrap(); +pub static ref IMPRINT_HTML: String = std::env::var("IMPRINT_HTML") + .unwrap_or("".to_string()) + .parse() + .unwrap(); } // THEME diff --git a/packages/backend/src/status/mod.rs b/packages/backend/src/status/mod.rs index db8a4d9..fcec5d2 100644 --- a/packages/backend/src/status/mod.rs +++ b/packages/backend/src/status/mod.rs @@ -13,6 +13,7 @@ pub struct Status { pub allow_advanced: bool, pub allow_files: bool, pub imprint_url: String, + pub imprint_html: String, // Theme pub theme_image: String, pub theme_text: String, @@ -30,6 +31,7 @@ pub async fn get_status() -> (StatusCode, Json) { allow_advanced: *config::ALLOW_ADVANCED, allow_files: *config::ALLOW_FILES, imprint_url: config::IMPRINT_URL.to_string(), + imprint_html: config::IMPRINT_HTML.to_string(), theme_new_note_notice: *config::THEME_NEW_NOTE_NOTICE, theme_image: config::THEME_IMAGE.to_string(), theme_text: config::THEME_TEXT.to_string(), diff --git a/packages/cli/src/shared/api.ts b/packages/cli/src/shared/api.ts index abc50f9..6f8f010 100644 --- a/packages/cli/src/shared/api.ts +++ b/packages/cli/src/shared/api.ts @@ -114,6 +114,7 @@ export type Status = { allow_advanced: boolean allow_files: boolean imprint_url: string + imprint_html: string theme_image: string theme_text: string theme_favicon: string diff --git a/packages/frontend/src/lib/views/Footer.svelte b/packages/frontend/src/lib/views/Footer.svelte index 481139e..6a19497 100644 --- a/packages/frontend/src/lib/views/Footer.svelte +++ b/packages/frontend/src/lib/views/Footer.svelte @@ -10,6 +10,8 @@ /about {#if $status?.imprint_url} /imprint + {:else if $status?.imprint_html} + /imprint {/if} code diff --git a/packages/frontend/src/routes/imprint/+page.svelte b/packages/frontend/src/routes/imprint/+page.svelte new file mode 100644 index 0000000..93fcbc8 --- /dev/null +++ b/packages/frontend/src/routes/imprint/+page.svelte @@ -0,0 +1,35 @@ + + + + Imprint + + +
+{#if $status?.imprint_html} + {@html $status.imprint_html} +{/if} +
+ +