Merge commit 'd643da6d18cb89f856abdabb1c373b87bcd7a4f0'

This commit is contained in:
Marie Birner
2025-08-03 11:01:07 +02:00
3 changed files with 107 additions and 57 deletions

View File

@@ -1,2 +0,0 @@
# TODOs
- [ ] limit names to 25(?) chars

View File

@@ -1,4 +1,4 @@
use crate::{language::language, page::new}; use crate::{language::language, page::Page};
use axum::http::HeaderMap; use axum::http::HeaderMap;
use axum_extra::extract::CookieJar; use axum_extra::extract::CookieJar;
use maud::{html, Markup}; use maud::{html, Markup};
@@ -8,7 +8,11 @@ pub(super) async fn index(cookies: CookieJar, headers: HeaderMap) -> Markup {
rust_i18n::set_locale(lang.to_locale()); rust_i18n::set_locale(lang.to_locale());
new( let mut page = Page::new(lang);
page.succ("Yeah! That worked!".into());
page.err("Damn...".into());
page.content(
html! { html! {
h1 { (t!("digital_shadows")) } h1 { (t!("digital_shadows")) }
hgroup { hgroup {
@@ -73,7 +77,6 @@ pub(super) async fn index(cookies: CookieJar, headers: HeaderMap) -> Markup {
} }
} }
} }
}, }
lang,
) )
} }

View File

@@ -3,66 +3,115 @@ use maud::{html, Markup, DOCTYPE};
// TODO: set dynamic meta lang attribute // TODO: set dynamic meta lang attribute
// TODO: remove function
#[deprecated]
pub fn new(content: Markup, lang: Language) -> Markup { pub fn new(content: Markup, lang: Language) -> Markup {
html! { let page = Page::new(lang);
(DOCTYPE) page.content(content)
html lang=(lang) { }
head {
meta charset="utf-8";
meta name="viewport" content="width=device-width, initial-scale=1.0";
link rel="stylesheet" href="/static/pico.min.css";
link rel="stylesheet" href="/static/style.css";
title { "Digital Shadows" }
}
body {
header.container {
nav {
ul {
li {
a href="/" {
strong { "Digital Shadows" }
}
}
}
ul {
li {
a href="/" {
span role="img" aria-label="home" { "🏠" }
}
}
li {
a href="/game" {
span role="img" aria-label="camera" { "📸" }
}
}
li {
span id="theme_switcher" {}
}
li { pub(crate) struct Page {
button id="lang-toggle" lang=(lang.next_language()) { lang: Language,
(lang.next_language()) succ: Option<String>,
err: Option<String>,
}
impl Page {
pub fn new(lang: Language) -> Self {
Self {
lang,
succ: None,
err: None,
}
}
pub fn succ(&mut self, msg: String) {
self.succ = Some(msg);
}
pub fn err(&mut self, msg: String) {
self.err = Some(msg);
}
fn has_msg(&self) -> bool {
self.succ.is_some() || self.err.is_some()
}
pub fn content(self, content: Markup) -> Markup {
html! {
(DOCTYPE)
html lang=(self.lang) {
head {
meta charset="utf-8";
meta name="viewport" content="width=device-width, initial-scale=1.0";
link rel="stylesheet" href="/static/pico.min.css";
link rel="stylesheet" href="/static/style.css";
title { "Digital Shadows" }
}
body {
header.container {
nav {
ul {
li {
a href="/" {
strong { "Digital Shadows" }
}
}
}
ul {
li {
a href="/" {
span role="img" aria-label="home" { "🏠" }
}
}
li {
a href="/game" {
span role="img" aria-label="camera" { "📸" }
}
}
li {
span id="theme_switcher" {}
}
li {
button id="lang-toggle" lang=(self.lang.next_language()) {
(self.lang.next_language())
}
} }
} }
} }
} }
}
main.container { main.container {
section { (content) } @if self.has_msg() {
} section {
@if let Some(succ) = self.succ {
footer.container { p class="succ" {
small { (succ)
"Footer " }
mark { "to be completed" } }
a href="#" { "with links" } @if let Some(err) = self.err{
"" p class="err" {
a target="_blank" href="https://www.digidow.eu/impressum/" { "Impressum" } (err)
}
}
}
}
section { (content) }
} }
footer.container {
small {
"Footer "
mark { "to be completed" }
a href="#" { "with links" }
""
a target="_blank" href="https://www.digidow.eu/impressum/" { "Impressum" }
}
}
script src="/static/theme.js" {}
}
} }
script src="/static/theme.js" {}
}
} }
} }
} }