2024-05-02 15:26:08 +02:00
|
|
|
use camino::Utf8Path;
|
2024-04-13 15:26:52 +02:00
|
|
|
use hypertext::{html_elements, maud, maud_move, GlobalAttributes, Raw, Renderable};
|
|
|
|
|
2024-04-13 17:29:26 +02:00
|
|
|
use crate::REPO;
|
|
|
|
|
2024-04-13 15:26:52 +02:00
|
|
|
|
2024-05-04 13:48:51 +02:00
|
|
|
const JS_RELOAD: &str = r#"
|
|
|
|
const socket = new WebSocket("ws://localhost:1337");
|
|
|
|
socket.addEventListener("message", (event) => {
|
|
|
|
console.log(event);
|
|
|
|
window.location.reload();
|
|
|
|
});
|
|
|
|
"#;
|
|
|
|
|
|
|
|
const JS_IMPORTS: &str = r#"
|
|
|
|
{
|
|
|
|
"imports": {
|
|
|
|
"splash": "/js/splash.js",
|
|
|
|
"reveal": "/js/reveal.js",
|
2024-05-14 19:25:20 +02:00
|
|
|
"photos": "/js/photos.js"
|
2024-05-04 13:48:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
"#;
|
|
|
|
|
|
|
|
|
2024-04-13 15:26:52 +02:00
|
|
|
pub fn head(title: &str) -> impl Renderable + '_ {
|
2024-04-14 20:43:08 +02:00
|
|
|
let title = format!("{} | kamoshi.org", title);
|
|
|
|
|
2024-04-13 15:26:52 +02:00
|
|
|
maud_move!(
|
|
|
|
meta charset="utf-8";
|
|
|
|
meta name="viewport" content="width=device-width, initial-scale=1";
|
|
|
|
title {
|
|
|
|
(title)
|
|
|
|
}
|
|
|
|
|
|
|
|
// link rel="sitemap" href="/sitemap.xml";
|
|
|
|
|
|
|
|
link rel="stylesheet" href="/styles.css";
|
|
|
|
link rel="stylesheet" href="/static/css/reveal.css";
|
|
|
|
link rel="stylesheet" href="/static/css/leaflet.css";
|
|
|
|
link rel="stylesheet" href="/static/css/MarkerCluster.css";
|
|
|
|
link rel="stylesheet" href="/static/css/MarkerCluster.Default.css";
|
|
|
|
link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png";
|
|
|
|
link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png";
|
|
|
|
link rel="icon" href="/favicon.ico" sizes="any";
|
2024-05-04 13:48:51 +02:00
|
|
|
|
|
|
|
script type="importmap" {(Raw(JS_IMPORTS))}
|
|
|
|
|
|
|
|
script { (Raw(JS_RELOAD)) }
|
2024-04-13 15:26:52 +02:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn navbar() -> impl Renderable {
|
|
|
|
static ITEMS: &[(&str, &str)] = &[
|
|
|
|
("Posts", "/posts/"),
|
|
|
|
("Slides", "/slides/"),
|
|
|
|
("Wiki", "/wiki/"),
|
|
|
|
("Map", "/map/"),
|
|
|
|
("About", "/about/"),
|
|
|
|
("Search", "/search/"),
|
|
|
|
];
|
|
|
|
|
|
|
|
maud!(
|
|
|
|
nav .p-nav {
|
|
|
|
input #p-nav-toggle type="checkbox" hidden;
|
|
|
|
|
|
|
|
div .p-nav__bar {
|
|
|
|
a .p-nav__logo href="/" {
|
|
|
|
img .p-nav__logo-icon height="48px" width="51px" src="/static/svg/aya.svg" alt="";
|
|
|
|
div .p-nav__logo-text {
|
|
|
|
div .p-nav__logo-main {
|
|
|
|
(Raw(include_str!("logotype.svg")))
|
|
|
|
}
|
|
|
|
div #p-nav-splash .p-nav__logo-sub {
|
|
|
|
"夢現の遥か彼方"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
label .p-nav__burger for="p-nav-toggle" tabindex="0" {
|
|
|
|
span .p-nav__burger-icon {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu .p-nav__menu {
|
|
|
|
@for (name, url) in ITEMS {
|
|
|
|
li .p-nav__menu-item {
|
|
|
|
a .p-nav__menu-link href=(*url) {
|
|
|
|
(*name)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-05-02 15:26:08 +02:00
|
|
|
pub fn footer(path: Option<&Utf8Path>) -> impl Renderable {
|
2024-04-14 20:43:08 +02:00
|
|
|
let copy = format!("Copyright © {} Maciej Jur", &REPO.year);
|
2024-04-13 15:26:52 +02:00
|
|
|
let mail = "maciej@kamoshi.org";
|
|
|
|
let href = format!("mailto:{}", mail);
|
2024-05-14 19:25:20 +02:00
|
|
|
let link = Utf8Path::new(&REPO.link).join("src/commit").join(&REPO.hash);
|
2024-05-02 15:26:08 +02:00
|
|
|
let link = match path {
|
|
|
|
Some(path) => link.join(path),
|
|
|
|
None => link,
|
|
|
|
};
|
2024-04-13 15:26:52 +02:00
|
|
|
|
|
|
|
maud_move!(
|
|
|
|
footer .footer {
|
2024-04-13 17:29:26 +02:00
|
|
|
div .left {
|
2024-04-13 15:26:52 +02:00
|
|
|
div {
|
|
|
|
(Raw(copy))
|
|
|
|
}
|
|
|
|
a href=(href) {
|
|
|
|
(mail)
|
|
|
|
}
|
|
|
|
}
|
2024-04-14 20:43:08 +02:00
|
|
|
div .repo {
|
2024-05-02 15:26:08 +02:00
|
|
|
a href=(link.as_str()) {
|
2024-04-14 20:43:08 +02:00
|
|
|
(&REPO.hash)
|
|
|
|
}
|
|
|
|
div {
|
|
|
|
(&REPO.date)
|
|
|
|
}
|
2024-04-13 17:29:26 +02:00
|
|
|
}
|
|
|
|
a .right.footer__cc-wrap rel="license" href="http://creativecommons.org/licenses/by/4.0/" {
|
2024-04-13 15:26:52 +02:00
|
|
|
img .footer__cc-stamp alt="Creative Commons License" width="88" height="31" src="/static/svg/by.svg";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|