From: Nutomic Date: Wed, 23 Feb 2022 16:40:36 +0000 (+0000) Subject: Add site option for default theme (#2104) X-Git-Url: http://these/git/readmes/%24%7B%60data:application/static/README.es.md?a=commitdiff_plain;h=9f5183fe983014d0cf9f0959ff1e17230d35af0e;p=lemmy.git Add site option for default theme (#2104) --- diff --git a/config/defaults.hjson b/config/defaults.hjson index cf8b5573..c30c33ac 100644 --- a/config/defaults.hjson +++ b/config/defaults.hjson @@ -101,6 +101,7 @@ require_application: true application_question: "string" private_instance: true + default_theme: "string" } # the domain name of your instance (mandatory) hostname: "unset" diff --git a/crates/api_common/src/site.rs b/crates/api_common/src/site.rs index a707dd65..df752c00 100644 --- a/crates/api_common/src/site.rs +++ b/crates/api_common/src/site.rs @@ -106,6 +106,7 @@ pub struct CreateSite { pub require_application: Option, pub application_question: Option, pub private_instance: Option, + pub default_theme: Option, pub auth: Sensitive, } @@ -124,6 +125,7 @@ pub struct EditSite { pub require_application: Option, pub application_question: Option, pub private_instance: Option, + pub default_theme: Option, pub auth: Sensitive, } diff --git a/crates/api_crud/src/site/create.rs b/crates/api_crud/src/site/create.rs index d714afea..4d51504f 100644 --- a/crates/api_crud/src/site/create.rs +++ b/crates/api_crud/src/site/create.rs @@ -80,6 +80,7 @@ impl PerformCrud for CreateSite { inbox_url, private_key: Some(Some(keypair.private_key)), public_key: Some(keypair.public_key), + default_theme: data.default_theme.clone(), ..SiteForm::default() }; diff --git a/crates/api_crud/src/site/read.rs b/crates/api_crud/src/site/read.rs index ee777d2d..d214f7b6 100644 --- a/crates/api_crud/src/site/read.rs +++ b/crates/api_crud/src/site/read.rs @@ -68,6 +68,7 @@ impl PerformCrud for GetSite { require_application: setup.require_application, application_question: setup.application_question.to_owned(), private_instance: setup.private_instance, + default_theme: setup.default_theme.to_owned(), auth: admin_jwt, }; create_site.perform(context, websocket_id).await?; diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index c6f59523..7696711c 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -69,6 +69,7 @@ impl PerformCrud for EditSite { require_application: data.require_application, application_question, private_instance: data.private_instance, + default_theme: data.default_theme.clone(), ..SiteForm::default() }; diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 811e8b09..390a8e72 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -460,6 +460,7 @@ table! { inbox_url -> Text, private_key -> Nullable, public_key -> Text, + default_theme -> Text, } } diff --git a/crates/db_schema/src/source/site.rs b/crates/db_schema/src/source/site.rs index 25bed1c2..6a055842 100644 --- a/crates/db_schema/src/source/site.rs +++ b/crates/db_schema/src/source/site.rs @@ -25,6 +25,7 @@ pub struct Site { pub inbox_url: DbUrl, pub private_key: Option, pub public_key: String, + pub default_theme: String, } #[derive(Insertable, AsChangeset, Default)] @@ -50,4 +51,5 @@ pub struct SiteForm { pub inbox_url: Option, pub private_key: Option>, pub public_key: Option, + pub default_theme: Option, } diff --git a/crates/utils/src/settings/structs.rs b/crates/utils/src/settings/structs.rs index 0aaae87c..16ead863 100644 --- a/crates/utils/src/settings/structs.rs +++ b/crates/utils/src/settings/structs.rs @@ -205,4 +205,6 @@ pub struct SetupConfig { pub application_question: Option, #[default(None)] pub private_instance: Option, + #[default(None)] + pub default_theme: Option, } diff --git a/migrations/2022-02-18-210946_default_theme/down.sql b/migrations/2022-02-18-210946_default_theme/down.sql new file mode 100644 index 00000000..fc57669a --- /dev/null +++ b/migrations/2022-02-18-210946_default_theme/down.sql @@ -0,0 +1 @@ +alter table site drop column default_theme; \ No newline at end of file diff --git a/migrations/2022-02-18-210946_default_theme/up.sql b/migrations/2022-02-18-210946_default_theme/up.sql new file mode 100644 index 00000000..dd6faad4 --- /dev/null +++ b/migrations/2022-02-18-210946_default_theme/up.sql @@ -0,0 +1 @@ +alter table site add column default_theme text not null default 'browser'; \ No newline at end of file