From 3bb00c4eb712d164117e3299357f6e34a098d8da Mon Sep 17 00:00:00 2001 From: glyph Date: Mon, 17 Jan 2022 15:19:48 +0200 Subject: [PATCH 1/4] add route for sbot config --- peach-web/src/routes/settings/scuttlebutt.rs | 55 +++++++++----------- 1 file changed, 25 insertions(+), 30 deletions(-) diff --git a/peach-web/src/routes/settings/scuttlebutt.rs b/peach-web/src/routes/settings/scuttlebutt.rs index bd1a129..0ab9e70 100644 --- a/peach-web/src/routes/settings/scuttlebutt.rs +++ b/peach-web/src/routes/settings/scuttlebutt.rs @@ -1,41 +1,36 @@ -use rocket::{get, request::FlashMessage, serde::Serialize}; -use rocket_dyn_templates::Template; +use rocket::{get, request::FlashMessage}; +use rocket_dyn_templates::{tera::Context, Template}; use crate::routes::authentication::Authenticated; // HELPERS AND ROUTES FOR /settings/scuttlebutt -#[derive(Debug, Serialize)] -pub struct ScuttlebuttSettingsContext { - pub back: Option, - pub title: Option, - pub flash_name: Option, - pub flash_msg: Option, -} - -impl ScuttlebuttSettingsContext { - pub fn build() -> ScuttlebuttSettingsContext { - ScuttlebuttSettingsContext { - back: None, - title: None, - flash_name: None, - flash_msg: None, - } - } -} - /// Scuttlebutt settings menu. #[get("/")] pub fn ssb_settings_menu(flash: Option, _auth: Authenticated) -> Template { - let mut context = ScuttlebuttSettingsContext::build(); - // set back icon link to network route - context.back = Some("/settings".to_string()); - context.title = Some("Scuttlebutt Settings".to_string()); - // check to see if there is a flash message to display + let mut context = Context::new(); + context.insert("back", &Some("/settings".to_string())); + context.insert("title", &Some("Scuttlebutt Settings".to_string())); + if let Some(flash) = flash { - // add flash message contents to the context object - context.flash_name = Some(flash.kind().to_string()); - context.flash_msg = Some(flash.message().to_string()); + context.insert("flash_name", &Some(flash.kind().to_string())); + context.insert("flash_msg", &Some(flash.message().to_string())); }; - Template::render("settings/scuttlebutt", &context) + + Template::render("settings/scuttlebutt/menu", &context.into_json()) +} + +/// Sbot configuration page (includes form for updating configuration parameters). +#[get("/configure")] +pub fn configure_sbot(flash: Option, _auth: Authenticated) -> Template { + let mut context = Context::new(); + context.insert("back", &Some("/settings/scuttlebutt".to_string())); + context.insert("title", &Some("Sbot Configuration".to_string())); + + if let Some(flash) = flash { + context.insert("flash_name", &Some(flash.kind().to_string())); + context.insert("flash_msg", &Some(flash.message().to_string())); + }; + + Template::render("settings/scuttlebutt/configure_sbot", &context.into_json()) } From 8f5b257ed1b83041f9884a513a6d76280e801d07 Mon Sep 17 00:00:00 2001 From: glyph Date: Mon, 17 Jan 2022 15:20:08 +0200 Subject: [PATCH 2/4] mount routes for sbot config --- peach-web/src/router.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/peach-web/src/router.rs b/peach-web/src/router.rs index f86148b..51e34c5 100644 --- a/peach-web/src/router.rs +++ b/peach-web/src/router.rs @@ -48,7 +48,10 @@ pub fn build_minimal_rocket() -> Rocket { ], ) // SCUTTLEBUTT SETTINGS HTML ROUTES - .mount("/settings/scuttlebutt", routes![ssb_settings_menu]) + .mount( + "/settings/scuttlebutt", + routes![ssb_settings_menu, configure_sbot], + ) // SCUTTLEBUTT SOCIAL HTML ROUTES .mount( "/scuttlebutt", @@ -125,7 +128,10 @@ pub fn build_complete_rocket() -> Rocket { ], ) // SCUTTLEBUTT SETTINGS HTML ROUTES - .mount("/settings/scuttlebutt", routes![ssb_settings_menu]) + .mount( + "/settings/scuttlebutt", + routes![ssb_settings_menu, configure_sbot], + ) // SCUTTLEBUTT SOCIAL HTML ROUTES .mount( "/scuttlebutt", From 8c4cf6261e98a2ef5153ae1cac5650efd5d05d0a Mon Sep 17 00:00:00 2001 From: glyph Date: Mon, 17 Jan 2022 15:20:43 +0200 Subject: [PATCH 3/4] add sbot config template and rename menu --- .../scuttlebutt/configure_sbot.html.tera | 55 +++++++++++++++++++ .../menu.html.tera} | 10 ++-- 2 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 peach-web/templates/settings/scuttlebutt/configure_sbot.html.tera rename peach-web/templates/settings/{scuttlebutt.html.tera => scuttlebutt/menu.html.tera} (69%) diff --git a/peach-web/templates/settings/scuttlebutt/configure_sbot.html.tera b/peach-web/templates/settings/scuttlebutt/configure_sbot.html.tera new file mode 100644 index 0000000..1497853 --- /dev/null +++ b/peach-web/templates/settings/scuttlebutt/configure_sbot.html.tera @@ -0,0 +1,55 @@ +{%- extends "nav" -%} +{%- block card %} + +
+
+
+ +
+ + + + + + + + + +
+
+
+
+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
+ + +
+
+
+ +
+
+ +
+
+
+ + +
+
+{%- endblock card -%} diff --git a/peach-web/templates/settings/scuttlebutt.html.tera b/peach-web/templates/settings/scuttlebutt/menu.html.tera similarity index 69% rename from peach-web/templates/settings/scuttlebutt.html.tera rename to peach-web/templates/settings/scuttlebutt/menu.html.tera index 2ceb8de..386e458 100644 --- a/peach-web/templates/settings/scuttlebutt.html.tera +++ b/peach-web/templates/settings/scuttlebutt/menu.html.tera @@ -4,15 +4,13 @@ {%- endblock card -%} From b4a930e774cff6cb832fe6875ad7aaf081fc7870 Mon Sep 17 00:00:00 2001 From: glyph Date: Mon, 17 Jan 2022 15:21:11 +0200 Subject: [PATCH 4/4] add bottom margin for small label class --- peach-web/static/css/peachcloud.css | 1 + 1 file changed, 1 insertion(+) diff --git a/peach-web/static/css/peachcloud.css b/peach-web/static/css/peachcloud.css index 8c767f0..93936d4 100644 --- a/peach-web/static/css/peachcloud.css +++ b/peach-web/static/css/peachcloud.css @@ -684,6 +684,7 @@ html { font-family: var(--sans-serif); font-size: var(--font-size-7); display: block; + margin-bottom: 2px; } .label-medium {