about summary refs log tree commit diff
path: root/kittybox-rs
diff options
context:
space:
mode:
Diffstat (limited to 'kittybox-rs')
-rw-r--r--kittybox-rs/src/database/mod.rs20
-rw-r--r--kittybox-rs/src/frontend/mod.rs6
-rw-r--r--kittybox-rs/src/frontend/onboarding.rs4
-rw-r--r--kittybox-rs/templates/src/templates.rs31
4 files changed, 51 insertions, 10 deletions
diff --git a/kittybox-rs/src/database/mod.rs b/kittybox-rs/src/database/mod.rs
index 2039ac0..db0e360 100644
--- a/kittybox-rs/src/database/mod.rs
+++ b/kittybox-rs/src/database/mod.rs
@@ -48,6 +48,11 @@ pub mod settings {
         fn from(settings: Settings) -> Self {
             settings.site_name
         }
+    }
+    impl From<Settings> for Webring {
+        fn from(settings: Settings) -> Self {
+            settings.webring
+        }
     }*/
 
     /// A trait for various settings that should be contained here.
@@ -96,6 +101,21 @@ pub mod settings {
         }
     }
 
+    /// Participation status in the IndieWeb Webring: https://πŸ•ΈπŸ’.ws/dashboard
+    #[derive(Debug, Default, serde::Deserialize, serde::Serialize, Clone, Copy, PartialEq, Eq)]
+    pub struct Webring(bool);
+    impl private::Sealed for Webring {}
+    impl Setting<'_> for Webring {
+        type Data = bool;
+        const ID: &'static str = "webring";
+
+        fn into_inner(self) -> Self::Data {
+            self.0
+        }
+
+        fn new(data: Self::Data) -> Self {
+            Self(data)
+        }
     }
 }
 
diff --git a/kittybox-rs/src/frontend/mod.rs b/kittybox-rs/src/frontend/mod.rs
index 9d5c164..b90d57c 100644
--- a/kittybox-rs/src/frontend/mod.rs
+++ b/kittybox-rs/src/frontend/mod.rs
@@ -131,10 +131,13 @@ pub async fn homepage<D: Storage>(
             // other requests anyway if it's serious...)
             //
             // btw is it more efficient to fetch these in parallel?
-            let (blogname, channels) = tokio::join!(
+            let (blogname, webring, channels) = tokio::join!(
                 db.get_setting::<crate::database::settings::SiteName>(&path)
                 .map(Result::unwrap_or_default),
 
+                db.get_setting::<crate::database::settings::Webring>(&path)
+                .map(Result::unwrap_or_default),
+
                 db.get_channels(&path).map(|i| i.unwrap_or_default())
             );
             // Render the homepage
@@ -152,6 +155,7 @@ pub async fn homepage<D: Storage>(
                     content: MainPage {
                         feed: &hfeed,
                         card: &hcard,
+                        webring: crate::database::settings::Setting::into_inner(webring)
                     }
                     .to_string(),
                 }
diff --git a/kittybox-rs/src/frontend/onboarding.rs b/kittybox-rs/src/frontend/onboarding.rs
index 88b533b..f797abd 100644
--- a/kittybox-rs/src/frontend/onboarding.rs
+++ b/kittybox-rs/src/frontend/onboarding.rs
@@ -72,6 +72,10 @@ async fn onboard<D: Storage + 'static>(
         .await
         .map_err(FrontendError::from)?;
 
+    db.set_setting::<settings::Webring>(user.me.as_str(), false)
+        .await
+        .map_err(FrontendError::from)?;
+
     let (_, hcard) = {
         let mut hcard = data.user;
         hcard["properties"]["uid"] = serde_json::json!([&user_uid]);
diff --git a/kittybox-rs/templates/src/templates.rs b/kittybox-rs/templates/src/templates.rs
index ba52af7..10c84a7 100644
--- a/kittybox-rs/templates/src/templates.rs
+++ b/kittybox-rs/templates/src/templates.rs
@@ -63,18 +63,31 @@ markup::define! {
             }
         }
     }
-    MainPage<'a>(feed: &'a serde_json::Value, card: &'a serde_json::Value) {
+    MainPage<'a>(feed: &'a serde_json::Value, card: &'a serde_json::Value, webring: bool) {
         .sidebyside {
             @VCard { card }
             #dynamicstuff {
-                p { "This section will provide interesting statistics or tidbits about my life in this exact moment (with maybe a small delay)." }
-                p { "It will probably require JavaScript to self-update, but I promise to keep this widget lightweight and open-source!" }
-                p { small {
-                    "JavaScript isn't a menace, stop fearing it or I will switch to WebAssembly "
-                    "and knock your nico-nico-kneecaps so fast with its speed you won't even notice that... "
-                    small { "omae ha mou shindeiru" }
-                    @markup::raw("<!-- NANI?!!! -->")
-                } }
+                div {
+                    p { "This section will provide interesting statistics or tidbits about my life in this exact moment (with maybe a small delay)." }
+                    p { "It will probably require JavaScript to self-update, but I promise to keep this widget lightweight and open-source!" }
+                    p { small {
+                        "JavaScript isn't a menace, stop fearing it or I will switch to WebAssembly "
+                        "and knock your nico-nico-kneecaps so fast with its speed you won't even notice that... "
+                        small { "omae ha mou shindeiru" }
+                        @markup::raw("<!-- NANI?!!! -->")
+                    } }
+                }
+                @if *webring {
+                    #webring {
+                        a[href="https://xn--sr8hvo.ws/previous"] { "←" }
+                        " An "
+                        a[href="https://xn--sr8hvo.ws"] {
+                            "IndieWeb Webring"
+                        }
+                        " πŸ•ΈπŸ’ "
+                        a[href="https://xn--sr8hvo.ws/next"] { "β†’" }
+                    }
+                }
             }
         }
         @Feed { feed }