]> Untitled Git - lemmy.git/commitdiff
Add site option for default theme (#2104)
authorNutomic <me@nutomic.com>
Wed, 23 Feb 2022 16:40:36 +0000 (16:40 +0000)
committerGitHub <noreply@github.com>
Wed, 23 Feb 2022 16:40:36 +0000 (11:40 -0500)
config/defaults.hjson
crates/api_common/src/site.rs
crates/api_crud/src/site/create.rs
crates/api_crud/src/site/read.rs
crates/api_crud/src/site/update.rs
crates/db_schema/src/schema.rs
crates/db_schema/src/source/site.rs
crates/utils/src/settings/structs.rs
migrations/2022-02-18-210946_default_theme/down.sql [new file with mode: 0644]
migrations/2022-02-18-210946_default_theme/up.sql [new file with mode: 0644]

index cf8b55731cee23ce5904514bf5f6af2cd2675c5d..c30c33ac88625ee9250e0d24778a94c953142150 100644 (file)
     require_application: true
     application_question: "string"
     private_instance: true
+    default_theme: "string"
   }
   # the domain name of your instance (mandatory)
   hostname: "unset"
index a707dd656ec6817a992ce5b5daf4e822abde822c..df752c00c13a9f8a2fff4843839fc099ff2263a3 100644 (file)
@@ -106,6 +106,7 @@ pub struct CreateSite {
   pub require_application: Option<bool>,
   pub application_question: Option<String>,
   pub private_instance: Option<bool>,
+  pub default_theme: Option<String>,
   pub auth: Sensitive<String>,
 }
 
@@ -124,6 +125,7 @@ pub struct EditSite {
   pub require_application: Option<bool>,
   pub application_question: Option<String>,
   pub private_instance: Option<bool>,
+  pub default_theme: Option<String>,
   pub auth: Sensitive<String>,
 }
 
index d714afea7d859b7db457be8e91962876b305ece7..4d51504f70568eb985077dc7fbaf5d4617536057 100644 (file)
@@ -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()
     };
 
index ee777d2d7edc4b76f3dce098c1a94dd0bab5e9b4..d214f7b6e041390102d2f34d175a2402a765a2bc 100644 (file)
@@ -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?;
index c6f595230966f4a38a1f783ce219df69d2b19ecc..7696711c6316b72927f72c5e6977461e0d1392ac 100644 (file)
@@ -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()
     };
 
index 811e8b09a984fe4f9480a47dd477872121f4134c..390a8e723035ca625cf643f175400a7143444b46 100644 (file)
@@ -460,6 +460,7 @@ table! {
         inbox_url -> Text,
         private_key -> Nullable<Text>,
         public_key -> Text,
+        default_theme -> Text,
     }
 }
 
index 25bed1c243b47c91acf686a3245723893110be2d..6a055842054d72854880ef239e70f24f050316d3 100644 (file)
@@ -25,6 +25,7 @@ pub struct Site {
   pub inbox_url: DbUrl,
   pub private_key: Option<String>,
   pub public_key: String,
+  pub default_theme: String,
 }
 
 #[derive(Insertable, AsChangeset, Default)]
@@ -50,4 +51,5 @@ pub struct SiteForm {
   pub inbox_url: Option<DbUrl>,
   pub private_key: Option<Option<String>>,
   pub public_key: Option<String>,
+  pub default_theme: Option<String>,
 }
index 0aaae87ce48e6d471463c5cee598dc405dbf1cc3..16ead86373d50856cd5b6e3fd6b0c097b3d8b54d 100644 (file)
@@ -205,4 +205,6 @@ pub struct SetupConfig {
   pub application_question: Option<String>,
   #[default(None)]
   pub private_instance: Option<bool>,
+  #[default(None)]
+  pub default_theme: Option<String>,
 }
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 (file)
index 0000000..fc57669
--- /dev/null
@@ -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 (file)
index 0000000..dd6faad
--- /dev/null
@@ -0,0 +1 @@
+alter table site add column default_theme text not null default 'browser';
\ No newline at end of file