From 67d4f09bd7b864bff40e7eb0612d79e43e4f6ea9 Mon Sep 17 00:00:00 2001 From: Nicco Date: Thu, 27 Oct 2022 17:26:56 +0200 Subject: [PATCH] #62 (#63) * #62 add theme options for title and favicon * docs * version bump --- README.md | 22 +++++++++++---------- packages/backend/Cargo.lock | 2 +- packages/backend/Cargo.toml | 2 +- packages/backend/src/config.rs | 8 ++++++++ packages/backend/src/status/model.rs | 2 ++ packages/backend/src/status/routes.rs | 2 ++ packages/frontend/src/app.html | 1 - packages/frontend/src/lib/stores/status.ts | 2 ++ packages/frontend/src/routes/+layout.svelte | 5 +++-- 9 files changed, 31 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index f931076..de3abff 100644 --- a/README.md +++ b/README.md @@ -50,16 +50,18 @@ of the notes even if it tried to. ## Environment Variables -| Variable | Default | Description | -| ---------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `REDIS` | `redis://redis/` | Redis URL to connect to. [According to format](https://docs.rs/redis/latest/redis/#connection-parameters) | -| `SIZE_LIMIT` | `1 KiB` | Max size for body. Accepted values according to [byte-unit](https://docs.rs/byte-unit/).
`512 MiB` is the maximum allowed.
The frontend will show that number including the ~35% encoding overhead. | -| `MAX_VIEWS` | `100` | Maximal number of views. | -| `MAX_EXPIRATION` | `360` | Maximal expiration in minutes. | -| `ALLOW_ADVANCED` | `true` | Allow custom configuration. If set to `false` all notes will be one view only. | -| `THEME_IMAGE` | `""` | Custom image for replacing the logo. Must be publicly reachable | -| `THEME_TEXT` | `""` | Custom text for replacing the description below the logo | -| `VERBOSITY` | `warn` | Verbosity level for the backend. [Possible values](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) are: `error`, `warn`, `info`, `debug`, `trace` | +| Variable | Default | Description | +| ------------------ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `REDIS` | `redis://redis/` | Redis URL to connect to. [According to format](https://docs.rs/redis/latest/redis/#connection-parameters) | +| `SIZE_LIMIT` | `1 KiB` | Max size for body. Accepted values according to [byte-unit](https://docs.rs/byte-unit/).
`512 MiB` is the maximum allowed.
The frontend will show that number including the ~35% encoding overhead. | +| `MAX_VIEWS` | `100` | Maximal number of views. | +| `MAX_EXPIRATION` | `360` | Maximal expiration in minutes. | +| `ALLOW_ADVANCED` | `true` | Allow custom configuration. If set to `false` all notes will be one view only. | +| `VERBOSITY` | `warn` | Verbosity level for the backend. [Possible values](https://docs.rs/env_logger/latest/env_logger/#enabling-logging) are: `error`, `warn`, `info`, `debug`, `trace` | +| `THEME_IMAGE` | `""` | Custom image for replacing the logo. Must be publicly reachable | +| `THEME_TEXT` | `""` | Custom text for replacing the description below the logo | +| `THEME_PAGE_TITLE` | `""` | Custom text the page title | +| `THEME_FAVICON` | `""` | Custom url for the favicon. Must be publicly reachable | ## Deployment diff --git a/packages/backend/Cargo.lock b/packages/backend/Cargo.lock index b20b2f2..4635ad1 100644 --- a/packages/backend/Cargo.lock +++ b/packages/backend/Cargo.lock @@ -424,7 +424,7 @@ dependencies = [ [[package]] name = "cryptgeon" -version = "2.0.3" +version = "2.0.4" dependencies = [ "actix-files", "actix-web", diff --git a/packages/backend/Cargo.toml b/packages/backend/Cargo.toml index 6367710..f386ef5 100644 --- a/packages/backend/Cargo.toml +++ b/packages/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cryptgeon" -version = "2.0.3" +version = "2.0.4" authors = ["cupcakearmy "] edition = "2021" diff --git a/packages/backend/src/config.rs b/packages/backend/src/config.rs index 8fff7f9..13e3649 100644 --- a/packages/backend/src/config.rs +++ b/packages/backend/src/config.rs @@ -42,4 +42,12 @@ lazy_static! { .unwrap_or("".to_string()) .parse() .unwrap(); + pub static ref THEME_PAGE_TITLE: String = std::env::var("THEME_PAGE_TITLE") + .unwrap_or("".to_string()) + .parse() + .unwrap(); + pub static ref THEME_FAVICON: String = std::env::var("THEME_FAVICON") + .unwrap_or("".to_string()) + .parse() + .unwrap(); } diff --git a/packages/backend/src/status/model.rs b/packages/backend/src/status/model.rs index 3b29118..56190bc 100644 --- a/packages/backend/src/status/model.rs +++ b/packages/backend/src/status/model.rs @@ -12,4 +12,6 @@ pub struct Status { // Theme pub theme_image: String, pub theme_text: String, + pub theme_page_title: String, + pub theme_favicon: String, } diff --git a/packages/backend/src/status/routes.rs b/packages/backend/src/status/routes.rs index bbb8a43..a6dad2b 100644 --- a/packages/backend/src/status/routes.rs +++ b/packages/backend/src/status/routes.rs @@ -13,6 +13,8 @@ async fn get_status() -> impl Responder { allow_advanced: *config::ALLOW_ADVANCED, theme_image: config::THEME_IMAGE.to_string(), theme_text: config::THEME_TEXT.to_string(), + theme_page_title: config::THEME_PAGE_TITLE.to_string(), + theme_favicon: config::THEME_FAVICON.to_string() }); } diff --git a/packages/frontend/src/app.html b/packages/frontend/src/app.html index a8c3eca..80b32c6 100644 --- a/packages/frontend/src/app.html +++ b/packages/frontend/src/app.html @@ -2,7 +2,6 @@ - %sveltekit.head% diff --git a/packages/frontend/src/lib/stores/status.ts b/packages/frontend/src/lib/stores/status.ts index 173dda3..627bb3f 100644 --- a/packages/frontend/src/lib/stores/status.ts +++ b/packages/frontend/src/lib/stores/status.ts @@ -9,6 +9,8 @@ export type Status = { allow_advanced: boolean theme_image: string theme_text: string + theme_favicon: string + theme_page_title: string } export const status = writable(null) diff --git a/packages/frontend/src/routes/+layout.svelte b/packages/frontend/src/routes/+layout.svelte index 89c8cb0..46366b1 100644 --- a/packages/frontend/src/routes/+layout.svelte +++ b/packages/frontend/src/routes/+layout.svelte @@ -5,7 +5,7 @@ import '../app.css' - import { init as initStores } from '$lib/stores/status' + import { init as initStores, status } from '$lib/stores/status' import Footer from '$lib/views/Footer.svelte' import Header from '$lib/views/Header.svelte' @@ -15,7 +15,8 @@ - cryptgeon + {$status?.theme_page_title || 'cryptgeon'} + {#await waitLocale() then _}