120 lines
4.5 KiB
Rust
120 lines
4.5 KiB
Rust
use crate::Language;
|
|
use maud::{html, Markup, DOCTYPE};
|
|
|
|
pub(crate) struct Page {
|
|
lang: Language,
|
|
message: Option<MyMessage>,
|
|
}
|
|
|
|
pub(crate) enum MyMessage {
|
|
NameChanged,
|
|
FoundCam(String, i64),
|
|
Error(String, String, String),
|
|
}
|
|
|
|
impl Page {
|
|
pub fn new(lang: Language) -> Self {
|
|
Self {
|
|
lang,
|
|
message: None,
|
|
}
|
|
}
|
|
|
|
pub(crate) fn set_message(&mut self, message: MyMessage) {
|
|
self.message = Some(message);
|
|
}
|
|
|
|
pub fn content(self, content: Markup) -> Markup {
|
|
rust_i18n::set_locale(self.lang.to_locale());
|
|
|
|
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 { (t!("digital_shadows")) }
|
|
}
|
|
body {
|
|
header.container {
|
|
nav {
|
|
ul {
|
|
li {
|
|
a href="/" {
|
|
strong { (t!("digital_shadows")) }
|
|
}
|
|
}
|
|
}
|
|
ul {
|
|
li {
|
|
a href="/game" {
|
|
span role="img" aria-label="camera" { (t!("icon_camera")) }
|
|
}
|
|
}
|
|
li {
|
|
span id="theme_switcher" {}
|
|
}
|
|
|
|
li {
|
|
button id="lang-toggle" lang=(self.lang.next_language()) {
|
|
(self.lang.next_language())
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
main.container {
|
|
@if let Some(message) = &self.message {
|
|
@match message {
|
|
MyMessage::FoundCam(name, amount) => {
|
|
div.flex {
|
|
article class="succ msg" {
|
|
header { (t!("found_camera_title", name = name)) }
|
|
(t!("found_camera_body", amount = amount))
|
|
footer {
|
|
a href="#ranking" { (t!("see_ranking")) }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
MyMessage::NameChanged => {
|
|
div.flex {
|
|
article class="name msg" {
|
|
header { (t!("new_name_title")) }
|
|
(t!("new_name_message"))
|
|
}
|
|
}
|
|
}
|
|
MyMessage::Error(header, body, footer) => {
|
|
div.flex {
|
|
article class="error msg" {
|
|
header { (header) }
|
|
(body)
|
|
footer { (footer) }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
section { (content) }
|
|
}
|
|
|
|
footer.container {
|
|
small {
|
|
a href="/privacy" { (t!("privacy_policy")) }
|
|
" • "
|
|
a target="_blank" href="https://www.digidow.eu/impressum/" {
|
|
(t!("impressum"))
|
|
}
|
|
}
|
|
}
|
|
script src="/static/theme.js" {}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|