diff --git a/app/templates_src/claim.lisp b/app/templates_src/claim.lisp index bff9a83..a860676 100644 --- a/app/templates_src/claim.lisp +++ b/app/templates_src/claim.lisp @@ -6,7 +6,7 @@ (div ("class" "card container") (h1 (text "{{ entry.slug }}")) - (p (text "Custom slug reclaims are handled through ") (b (text "{{ tetratto }}")) (text ". You'll need to have an account there to submit a claim request.")) + (p (text "Custom slug reclaims are handled through ") (b (text "{{ config.service_hosts.tetratto }}")) (text ". You'll need to have an account there to submit a claim request.")) (p (text "Please note that you are unlikely to receive a response unless your claim is accepted. Please do not submit additional requests for the same slug.")) (text "{% if metadata.tetratto_owner_username -%}") @@ -24,13 +24,13 @@ (text "{% if metadata.tetratto_owner_username -%}") ; contact owner button (a - ("href" "{{ tetratto }}/mail/compose?receivers={{ tetratto_owner_username }}&subject=Reclaim%20for%20%22{{ entry.slug }}%22") + ("href" "{{ config.service_hosts.tetratto }}/mail/compose?receivers={{ tetratto_owner_username }}&subject=Reclaim%20for%20%22{{ entry.slug }}%22") ("class" "button surface no_fill") (text "{{ icon \"external-link\" }} Contact owner")) (text "{%- endif %}") (a - ("href" "{{ tetratto }}/mail/compose?receivers={{ tetratto_handler_account_username }}&subject=Reclaim%20for%20%22{{ entry.slug }}%22") + ("href" "{{ config.service_hosts.tetratto }}/mail/compose?receivers={{ tetratto_handler_account_username }}&subject=Reclaim%20for%20%22{{ entry.slug }}%22") ("class" "button surface no_fill") (text "{{ icon \"external-link\" }} Submit request")) (text "{% else %}") diff --git a/app/templates_src/view.lisp b/app/templates_src/view.lisp index d06db89..6c4816c 100644 --- a/app/templates_src/view.lisp +++ b/app/templates_src/view.lisp @@ -46,10 +46,12 @@ (text "Owner:") (a ("class" "flex items_center gap_2") - ("href" "{{ tetratto }}/@{{ metadata.tetratto_owner_username }}") + ("href" "{{ config.service_hosts.tetratto }}/@{{ metadata.tetratto_owner_username }}") + (text "{% if metadata.tetratto_owner_id -%}") (img ("class" "avatar") - ("src" "{{ tetratto }}/api/v1/auth/user/{{ metadata.tetratto_owner_username }}/avatar?selector_type=username")) + ("src" "{{ config.service_hosts.buckets }}/avatars/{{ metadata.tetratto_owner_id }}")) + (text "{%- endif %}") (text "{{ metadata.tetratto_owner_username }}"))) (text "{%- endif %}") diff --git a/src/config.rs b/src/config.rs index 1b9e05c..8f57438 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,6 +3,12 @@ use pathbufd::PathBufD; use serde::{Deserialize, Serialize}; use tetratto_shared::hash::random_id; +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct ServiceHostsConfig { + pub tetratto: String, + pub buckets: String, +} + #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Config { /// The name of the site. Shown in the UI. @@ -11,9 +17,6 @@ pub struct Config { /// The (CSS) theme color of the site. Shown in the UI. #[serde(default = "default_theme_color")] pub theme_color: String, - /// The URL of the Tetratto host associated with this instance. - #[serde(default = "default_tetratto")] - pub tetratto: String, /// The slug of the instance's information page. /// /// Should be the pathname WITHOUT the leading slash. @@ -29,6 +32,9 @@ pub struct Config { /// Real IP header (for reverse proxy). #[serde(default = "default_real_ip_header")] pub real_ip_header: String, + /// The host URL of required services. + #[serde(default = "default_service_hosts")] + pub service_hosts: ServiceHostsConfig, /// The master password which is allowed to do anything without password checks. pub master_pass: String, } @@ -41,10 +47,6 @@ fn default_theme_color() -> String { "#a3b3ff".to_string() } -fn default_tetratto() -> String { - "https://tetratto.com".to_string() -} - fn default_what_page_slug() -> String { "what".to_string() } @@ -61,6 +63,13 @@ fn default_real_ip_header() -> String { "CF-Connecting-IP".to_string() } +fn default_service_hosts() -> ServiceHostsConfig { + ServiceHostsConfig { + tetratto: "https://tetratto.com".to_string(), + buckets: "https://assetdelivery.tetratto.com".to_string(), + } +} + impl Configuration for Config { fn db_config(&self) -> DatabaseConfig { self.database.to_owned() @@ -72,11 +81,11 @@ impl Default for Config { Self { name: default_name(), theme_color: default_theme_color(), - tetratto: default_tetratto(), what_page_slug: default_what_page_slug(), tetratto_handler_account_username: default_tetratto_handler_account_username(), database: default_database(), real_ip_header: default_real_ip_header(), + service_hosts: default_service_hosts(), master_pass: random_id(), } } diff --git a/src/model.rs b/src/model.rs index 7dbbe2e..641eb40 100644 --- a/src/model.rs +++ b/src/model.rs @@ -444,6 +444,9 @@ pub struct EntryMetadata { #[serde(default, alias = "TETRATTO_OWNER_USERNAME")] #[validate(max_length = 32)] pub tetratto_owner_username: String, + /// The ID of the owner of this entry on the Tetratto instance. + #[serde(default, alias = "TETRATTO_OWNER_ID")] + pub tetratto_owner_id: usize, } macro_rules! metadata_css { diff --git a/src/routes.rs b/src/routes.rs index 352e769..5340522 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -42,7 +42,7 @@ fn default_context(config: &Config, build_code: &str) -> Context { let mut ctx = Context::new(); ctx.insert("name", &config.name); ctx.insert("theme_color", &config.theme_color); - ctx.insert("tetratto", &config.tetratto); + ctx.insert("config", &config); ctx.insert("what_page_slug", &config.what_page_slug); ctx.insert( "tetratto_handler_account_username",