Page base
This commit is contained in:
87
crates/service-webpage/src/components/base.rs
Normal file
87
crates/service-webpage/src/components/base.rs
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
use macro_sass::sass;
|
||||||
|
use maud::{DOCTYPE, Markup, PreEscaped, Render, html};
|
||||||
|
|
||||||
|
use crate::components::misc::FarLink;
|
||||||
|
|
||||||
|
pub struct PageMetadata {
|
||||||
|
pub title: String,
|
||||||
|
pub author: Option<String>,
|
||||||
|
pub description: Option<String>,
|
||||||
|
pub image: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Render for PageMetadata {
|
||||||
|
fn render(&self) -> Markup {
|
||||||
|
let empty = String::new();
|
||||||
|
let title = &self.title;
|
||||||
|
let author = &self.author.as_ref().unwrap_or(&empty);
|
||||||
|
let description = &self.description.as_ref().unwrap_or(&empty);
|
||||||
|
let image = &self.image.as_ref().unwrap_or(&empty);
|
||||||
|
|
||||||
|
html!(
|
||||||
|
meta property="og:site_name" content=(title) {}
|
||||||
|
meta name="title" content=(title) {}
|
||||||
|
meta property="og:title" content=(title) {}
|
||||||
|
meta property="twitter:title" content=(title) {}
|
||||||
|
|
||||||
|
meta name="author" content=(author) {}
|
||||||
|
|
||||||
|
meta name="description" content=(description) {}
|
||||||
|
meta property="og:description" content=(description) {}
|
||||||
|
meta property="twitter:description" content=(description) {}
|
||||||
|
|
||||||
|
|
||||||
|
meta content=(image) property="og:image" {}
|
||||||
|
link rel="shortcut icon" href=(image) type="image/x-icon" {}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const CSS: &str = sass!("css/main.scss");
|
||||||
|
|
||||||
|
pub struct BasePage<T: Render>(pub PageMetadata, pub T);
|
||||||
|
|
||||||
|
impl<T: Render> Render for BasePage<T> {
|
||||||
|
fn render(&self) -> Markup {
|
||||||
|
let meta = &self.0;
|
||||||
|
|
||||||
|
html! {
|
||||||
|
(DOCTYPE)
|
||||||
|
html {
|
||||||
|
head {
|
||||||
|
meta charset="UTF" {}
|
||||||
|
meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" {}
|
||||||
|
meta content="text/html; charset=UTF-8" http-equiv="content-type" {}
|
||||||
|
meta property="og:type" content="website" {}
|
||||||
|
|
||||||
|
(meta)
|
||||||
|
title { (PreEscaped(meta.title.clone())) }
|
||||||
|
style { (PreEscaped(CSS)) }
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
div class="wrapper" {
|
||||||
|
main { (self.1) }
|
||||||
|
|
||||||
|
footer {
|
||||||
|
hr class = "footline" {}
|
||||||
|
div class = "footContainer" {
|
||||||
|
p {
|
||||||
|
"This site was built by hand using "
|
||||||
|
(FarLink("https://rust-lang.org", "Rust"))
|
||||||
|
", "
|
||||||
|
(FarLink("https://maud.lambda.xyz", "Maud"))
|
||||||
|
", "
|
||||||
|
(FarLink("https://github.com/connorskees/grass", "Grass"))
|
||||||
|
", and "
|
||||||
|
(FarLink("https://docs.rs/axum/latest/axum", "Axum"))
|
||||||
|
"."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
pub mod base;
|
||||||
pub mod fa;
|
pub mod fa;
|
||||||
pub mod mangle;
|
pub mod mangle;
|
||||||
pub mod md;
|
pub mod md;
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
use assetserver::Asset;
|
use assetserver::Asset;
|
||||||
use macro_sass::sass;
|
use maud::{Markup, html};
|
||||||
use maud::{DOCTYPE, Markup, PreEscaped, html};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
components::{md::Markdown, misc::FarLink},
|
components::{
|
||||||
routes::{
|
base::{BasePage, PageMetadata},
|
||||||
assets::{Image_Betalupi, Image_Icon},
|
md::Markdown,
|
||||||
index::PageMetadata,
|
|
||||||
},
|
},
|
||||||
|
routes::assets::{Image_Betalupi, Image_Icon},
|
||||||
};
|
};
|
||||||
|
|
||||||
const CSS: &str = sass!("css/main.scss");
|
|
||||||
|
|
||||||
pub async fn betalupi() -> Markup {
|
pub async fn betalupi() -> Markup {
|
||||||
let meta = PageMetadata {
|
let meta = PageMetadata {
|
||||||
title: "What's a \"betalupi?\"".into(),
|
title: "What's a \"betalupi?\"".into(),
|
||||||
@@ -21,23 +18,9 @@ pub async fn betalupi() -> Markup {
|
|||||||
};
|
};
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
(DOCTYPE)
|
(BasePage(
|
||||||
html {
|
meta,
|
||||||
head {
|
html!(
|
||||||
meta charset="UTF" {}
|
|
||||||
meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" {}
|
|
||||||
meta content="text/html; charset=UTF-8" http-equiv="content-type" {}
|
|
||||||
meta property="og:type" content="website" {}
|
|
||||||
|
|
||||||
(meta)
|
|
||||||
title { (PreEscaped(meta.title)) }
|
|
||||||
style { (PreEscaped(CSS)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
div class="wrapper" {
|
|
||||||
main {
|
|
||||||
|
|
||||||
// TODO: no metadata class, generate backlink array
|
// TODO: no metadata class, generate backlink array
|
||||||
div {
|
div {
|
||||||
a href="/" style="padding-left:4pt;padding-right:4pt;" {"home"}
|
a href="/" style="padding-left:4pt;padding-right:4pt;" {"home"}
|
||||||
@@ -54,27 +37,8 @@ pub async fn betalupi() -> Markup {
|
|||||||
br {}
|
br {}
|
||||||
|
|
||||||
img alt="betalupi map" class="image" src=(Image_Betalupi::URL) {}
|
img alt="betalupi map" class="image" src=(Image_Betalupi::URL) {}
|
||||||
}
|
)
|
||||||
|
))
|
||||||
footer {
|
|
||||||
hr class = "footline" {}
|
|
||||||
div class = "footContainer" {
|
|
||||||
p {
|
|
||||||
"This site was built by hand using "
|
|
||||||
(FarLink("https://rust-lang.org", "Rust"))
|
|
||||||
", "
|
|
||||||
(FarLink("https://maud.lambda.xyz", "Maud"))
|
|
||||||
", "
|
|
||||||
(FarLink("https://github.com/connorskees/grass", "Grass"))
|
|
||||||
", and "
|
|
||||||
(FarLink("https://docs.rs/axum/latest/axum", "Axum"))
|
|
||||||
"."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use assetserver::Asset;
|
use assetserver::Asset;
|
||||||
use macro_sass::sass;
|
use maud::{Markup, html};
|
||||||
use maud::{DOCTYPE, Markup, PreEscaped, Render, html};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
components::{
|
components::{
|
||||||
|
base::{BasePage, PageMetadata},
|
||||||
fa::FAIcon,
|
fa::FAIcon,
|
||||||
mangle::{MangledBetaEmail, MangledGoogleEmail},
|
mangle::{MangledBetaEmail, MangledGoogleEmail},
|
||||||
md::Markdown,
|
md::Markdown,
|
||||||
@@ -12,43 +12,6 @@ use crate::{
|
|||||||
routes::assets::{Image_Cover, Image_Icon},
|
routes::assets::{Image_Cover, Image_Icon},
|
||||||
};
|
};
|
||||||
|
|
||||||
const CSS: &str = sass!("css/main.scss");
|
|
||||||
|
|
||||||
pub struct PageMetadata {
|
|
||||||
/// Text shown in tab
|
|
||||||
pub title: String,
|
|
||||||
pub author: Option<String>,
|
|
||||||
pub description: Option<String>,
|
|
||||||
pub image: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Render for PageMetadata {
|
|
||||||
fn render(&self) -> Markup {
|
|
||||||
let empty = String::new();
|
|
||||||
let title = &self.title;
|
|
||||||
let author = &self.author.as_ref().unwrap_or(&empty);
|
|
||||||
let description = &self.description.as_ref().unwrap_or(&empty);
|
|
||||||
let image = &self.image.as_ref().unwrap_or(&empty);
|
|
||||||
|
|
||||||
html!(
|
|
||||||
meta property="og:site_name" content=(title) {}
|
|
||||||
meta name="title" content=(title) {}
|
|
||||||
meta property="og:title" content=(title) {}
|
|
||||||
meta property="twitter:title" content=(title) {}
|
|
||||||
|
|
||||||
meta name="author" content=(author) {}
|
|
||||||
|
|
||||||
meta name="description" content=(description) {}
|
|
||||||
meta property="og:description" content=(description) {}
|
|
||||||
meta property="twitter:description" content=(description) {}
|
|
||||||
|
|
||||||
|
|
||||||
meta content=(image) property="og:image" {}
|
|
||||||
link rel="shortcut icon" href=(image) type="image/x-icon" {}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn index() -> Markup {
|
pub async fn index() -> Markup {
|
||||||
let meta = PageMetadata {
|
let meta = PageMetadata {
|
||||||
title: "Betalupi: About".into(),
|
title: "Betalupi: About".into(),
|
||||||
@@ -58,22 +21,9 @@ pub async fn index() -> Markup {
|
|||||||
};
|
};
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
(DOCTYPE)
|
(BasePage(
|
||||||
html {
|
meta,
|
||||||
head {
|
html!(
|
||||||
meta charset="UTF" {}
|
|
||||||
meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" {}
|
|
||||||
meta content="text/html; charset=UTF-8" http-equiv="content-type" {}
|
|
||||||
meta property="og:type" content="website" {}
|
|
||||||
|
|
||||||
(meta)
|
|
||||||
title { (PreEscaped(meta.title)) }
|
|
||||||
style { (PreEscaped(CSS)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
div class="wrapper" {
|
|
||||||
main {
|
|
||||||
h2 id="about" { "About" }
|
h2 id="about" { "About" }
|
||||||
|
|
||||||
div {
|
div {
|
||||||
@@ -290,26 +240,9 @@ pub async fn index() -> Markup {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
|
||||||
hr class = "footline" {}
|
)
|
||||||
div class = "footContainer" {
|
))
|
||||||
p {
|
|
||||||
"This site was built by hand using "
|
|
||||||
(FarLink("https://rust-lang.org", "Rust"))
|
|
||||||
", "
|
|
||||||
(FarLink("https://maud.lambda.xyz", "Maud"))
|
|
||||||
", "
|
|
||||||
(FarLink("https://github.com/connorskees/grass", "Grass"))
|
|
||||||
", and "
|
|
||||||
(FarLink("https://docs.rs/axum/latest/axum", "Axum"))
|
|
||||||
"."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,18 @@
|
|||||||
use assetserver::Asset;
|
use assetserver::Asset;
|
||||||
use macro_sass::sass;
|
use maud::{Markup, html};
|
||||||
use maud::{DOCTYPE, Markup, PreEscaped, html};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
components::{md::Markdown, misc::FarLink},
|
components::{
|
||||||
routes::{assets::Image_Icon, index::PageMetadata},
|
base::{BasePage, PageMetadata},
|
||||||
|
md::Markdown,
|
||||||
|
},
|
||||||
|
routes::assets::Image_Icon,
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: emoji
|
// TODO: emoji
|
||||||
// TODO: one page base
|
|
||||||
// TODO: spellcheck
|
// TODO: spellcheck
|
||||||
// TODO: check links
|
// TODO: check links
|
||||||
|
|
||||||
const CSS: &str = sass!("css/main.scss");
|
|
||||||
|
|
||||||
pub async fn links() -> Markup {
|
pub async fn links() -> Markup {
|
||||||
let meta = PageMetadata {
|
let meta = PageMetadata {
|
||||||
title: "Links".into(),
|
title: "Links".into(),
|
||||||
@@ -23,23 +22,9 @@ pub async fn links() -> Markup {
|
|||||||
};
|
};
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
(DOCTYPE)
|
(BasePage(
|
||||||
html {
|
meta,
|
||||||
head {
|
html!(
|
||||||
meta charset="UTF" {}
|
|
||||||
meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" {}
|
|
||||||
meta content="text/html; charset=UTF-8" http-equiv="content-type" {}
|
|
||||||
meta property="og:type" content="website" {}
|
|
||||||
|
|
||||||
(meta)
|
|
||||||
title { (PreEscaped(meta.title)) }
|
|
||||||
style { (PreEscaped(CSS)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
div class="wrapper" {
|
|
||||||
main {
|
|
||||||
|
|
||||||
// TODO: no metadata class, generate backlink array
|
// TODO: no metadata class, generate backlink array
|
||||||
div {
|
div {
|
||||||
a href="/" style="padding-left:4pt;padding-right:4pt;" {"home"}
|
a href="/" style="padding-left:4pt;padding-right:4pt;" {"home"}
|
||||||
@@ -60,29 +45,8 @@ pub async fn links() -> Markup {
|
|||||||
hr style="margin-top: 8rem; margin-bottom: 8rem" {}
|
hr style="margin-top: 8rem; margin-bottom: 8rem" {}
|
||||||
|
|
||||||
(Markdown(MD_D))
|
(Markdown(MD_D))
|
||||||
|
)
|
||||||
|
))
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
|
||||||
hr class = "footline" {}
|
|
||||||
div class = "footContainer" {
|
|
||||||
p {
|
|
||||||
"This site was built by hand using "
|
|
||||||
(FarLink("https://rust-lang.org", "Rust"))
|
|
||||||
", "
|
|
||||||
(FarLink("https://maud.lambda.xyz", "Maud"))
|
|
||||||
", "
|
|
||||||
(FarLink("https://github.com/connorskees/grass", "Grass"))
|
|
||||||
", and "
|
|
||||||
(FarLink("https://docs.rs/axum/latest/axum", "Axum"))
|
|
||||||
"."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user