summaryrefslogtreecommitdiff
path: root/src/pages.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-02-13 22:10:45 +0100
committermetamuffin <metamuffin@disroot.org>2023-02-13 22:10:45 +0100
commit4298b09bdbf2650130c03b753a6738911e1d45ef (patch)
tree326473c2cdb7f9399d6025ccb6e63b05d387e0a0 /src/pages.rs
parent143ff63acd01300b23178a2a4c08ece78cc83bd2 (diff)
downloadmetamuffin-website-4298b09bdbf2650130c03b753a6738911e1d45ef.tar
metamuffin-website-4298b09bdbf2650130c03b753a6738911e1d45ef.tar.bz2
metamuffin-website-4298b09bdbf2650130c03b753a6738911e1d45ef.tar.zst
optional css
Diffstat (limited to 'src/pages.rs')
-rw-r--r--src/pages.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/pages.rs b/src/pages.rs
index 482e254..7c92c4b 100644
--- a/src/pages.rs
+++ b/src/pages.rs
@@ -1,5 +1,11 @@
use crate::layout::{DynScaffold, Scaffold};
-use rocket::{get, response::Redirect, uri};
+use rocket::{
+ get,
+ http::{ContentType, Cookie, CookieJar},
+ post,
+ response::Redirect,
+ uri,
+};
#[get("/")]
pub fn r_root() -> Redirect {
@@ -95,3 +101,19 @@ pub fn r_contact() -> DynScaffold<'static> {
pub fn r_pgp_key() -> &'static str {
include_str!("../assets/key.asc")
}
+
+#[get("/style.css")]
+pub fn r_style() -> (ContentType, &'static str) {
+ (ContentType::CSS, include_str!("../assets/style.css"))
+}
+
+#[post("/toggle_css")]
+pub fn r_toggle_css(jar: &CookieJar) -> Redirect {
+ let has_css = jar.get("css").map(|v| v.value() == "yes").unwrap_or(false);
+ jar.add(
+ Cookie::build("css", if has_css { "no" } else { "yes" })
+ .permanent()
+ .finish(),
+ );
+ Redirect::to(rocket::uri!(r_root()))
+}