1
Fork 0
mirror of https://github.com/RGBCube/Site synced 2025-08-01 13:37:49 +00:00

Add about page

This commit is contained in:
RGBCube 2024-01-05 23:59:12 +03:00
parent 517c2ce99e
commit d03a5224a1
No known key found for this signature in database
8 changed files with 224 additions and 71 deletions

168
Cargo.lock generated
View file

@ -242,6 +242,21 @@ dependencies = [
"alloc-no-stdlib", "alloc-no-stdlib",
] ]
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "anstream" name = "anstream"
version = "0.6.5" version = "0.6.5"
@ -412,6 +427,20 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"wasm-bindgen",
"windows-targets 0.48.5",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.4.13" version = "4.4.13"
@ -475,6 +504,12 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "core-foundation-sys"
version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.12" version = "0.2.12"
@ -656,6 +691,15 @@ dependencies = [
"version_check", "version_check",
] ]
[[package]]
name = "getopts"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
dependencies = [
"unicode-width",
]
[[package]] [[package]]
name = "getrandom" name = "getrandom"
version = "0.2.11" version = "0.2.11"
@ -749,6 +793,29 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "iana-time-zone"
version = "0.1.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "idna" name = "idna"
version = "0.5.0" version = "0.5.0"
@ -795,6 +862,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "js-sys"
version = "0.3.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca"
dependencies = [
"wasm-bindgen",
]
[[package]] [[package]]
name = "language-tags" name = "language-tags"
version = "0.3.2" version = "0.3.2"
@ -933,6 +1009,15 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "num-traits"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "object" name = "object"
version = "0.32.2" version = "0.32.2"
@ -1058,6 +1143,18 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "pulldown-cmark"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998"
dependencies = [
"bitflags 1.3.2",
"getopts",
"memchr",
"unicase",
]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.35" version = "1.0.35"
@ -1261,6 +1358,7 @@ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
"cargo_toml", "cargo_toml",
"chrono",
"clap", "clap",
"embed", "embed",
"env_logger", "env_logger",
@ -1268,6 +1366,7 @@ dependencies = [
"maud", "maud",
"mime_guess", "mime_guess",
"minify-js", "minify-js",
"pulldown-cmark",
] ]
[[package]] [[package]]
@ -1497,6 +1596,12 @@ dependencies = [
"tinyvec", "tinyvec",
] ]
[[package]]
name = "unicode-width"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]] [[package]]
name = "url" name = "url"
version = "2.5.0" version = "2.5.0"
@ -1526,6 +1631,60 @@ version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826"
dependencies = [
"bumpalo",
"log",
"once_cell",
"proc-macro2",
"quote",
"syn 2.0.48",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.48",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.89"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.3.9" version = "0.3.9"
@ -1557,6 +1716,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-core"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
dependencies = [
"windows-targets 0.52.0",
]
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.48.0" version = "0.48.0"

View file

@ -9,17 +9,19 @@ repositoty = "https://github.com/RGBCube/rgbcube.github.io"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
actix-web = "4.4.1" actix-web = "4.4.1"
anyhow = "1.0.77" anyhow = "1.0.77"
bytes = "1.5.0" bytes = "1.5.0"
cargo_toml = "0.17.2" cargo_toml = "0.17.2"
clap = { version = "4.4.12", features = [ "derive" ] } chrono = "0.4.31"
embed = { git = "https://github.com/RGBCube/embed-rs" } clap = { version = "4.4.12", features = [ "derive" ] }
env_logger = "0.10.1" embed = { git = "https://github.com/RGBCube/embed-rs" }
log = { version = "0.4.20", features = [ "serde" ] } env_logger = "0.10.1"
maud = { version = "0.25.0", features = [ "actix-web" ] } log = { version = "0.4.20", features = [ "serde" ] }
mime_guess = "2.0.4" maud = { version = "0.25.0", features = [ "actix-web" ] }
minify-js = "0.6.0" mime_guess = "2.0.4"
minify-js = "0.6.0"
pulldown-cmark = "0.9.3"
[patch.crates-io] [patch.crates-io]
proc-macro2 = { git = "https://github.com/RGBCube/proc-macro2" } proc-macro2 = { git = "https://github.com/RGBCube/proc-macro2" }

View file

@ -2,6 +2,7 @@
mod asset; mod asset;
mod errors; mod errors;
mod markdown;
mod minify; mod minify;
mod page; mod page;
mod routes; mod routes;

18
src/markdown.rs Normal file
View file

@ -0,0 +1,18 @@
use maud::{
Markup,
PreEscaped,
};
use pulldown_cmark::{
html,
Options,
Parser,
};
pub fn parse(markdown: &str) -> Markup {
let mut output = String::new();
let parser = Parser::new_ext(markdown, Options::all());
html::push_html(&mut output, parser);
PreEscaped(output)
}

View file

@ -1,8 +1,7 @@
use std::{ use chrono::{
env, Datelike,
path::PathBuf, Local,
}; };
use maud::{ use maud::{
html, html,
Markup, Markup,
@ -21,7 +20,7 @@ pub fn create(title: Option<&str>, page: Page, body: Markup) -> Markup {
(asset::Css::Shared("text.css")) (asset::Css::Shared("text.css"))
(asset::Css::Owned(format!(r" (asset::Css::Owned(format!(r"
.{page} {{ .{page} {{
font-style: italic !important; font-style: italic;
}} }}
", page = page.as_str()))) ", page = page.as_str())))
}, },
@ -37,8 +36,9 @@ pub fn create(title: Option<&str>, page: Page, body: Markup) -> Markup {
(body) (body)
footer { footer {
"Served by " "Copyright © "
(env::current_exe().unwrap_or_else(|_| PathBuf::from("the toaster in my bathtub")).display()) (Local::now().year())
" RGBCube"
} }
} }
}, },

View file

@ -15,7 +15,7 @@ body {
} }
nav { nav {
font-size: 150%; font-size: large;
background-color: white; background-color: white;
padding: .3em .6em; padding: .3em .6em;
@ -43,5 +43,10 @@ a:hover {
} }
footer { footer {
border-top: .15em solid white;
display: flex;
font-size: small;
justify-content: center;
margin-bottom: 3em; margin-bottom: 3em;
padding-top: .5em;
} }

3
src/routes/about.md Normal file
View file

@ -0,0 +1,3 @@
### Hi.
Test 123

View file

@ -1,12 +1,12 @@
use actix_web::get; use actix_web::get;
use maud::{ use maud::Markup;
html,
Markup,
};
use crate::page::{ use crate::{
text, markdown,
Page, page::{
text,
Page,
},
}; };
#[get("/about")] #[get("/about")]
@ -14,50 +14,6 @@ pub async fn handler() -> actix_web::Result<Markup> {
Ok(text::create( Ok(text::create(
Some("About"), Some("About"),
Page::About, Page::About,
html! { markdown::parse(embed::string!("about.md").as_ref()),
h1 { "Lorem Ipsum" }
p {
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eget justo nec libero finibus facilisis. Curabitur fermentum quam et neque faucibus, nec pharetra nunc hendrerit."
}
h2 { "Section 1" }
p {
"Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec auctor velit id lectus vehicula molestie."
}
h3 { "Subsection 1.1" }
p {
"Nullam mollis nunc non nisl fermentum, a varius eros viverra. Fusce condimentum felis vitae nibh vehicula, a tincidunt ipsum eleifend."
}
h2 { "Section 2" }
p {
"Phasellus euismod eros a elit volutpat, sed volutpat eros placerat. Sed dictum est et metus consectetur, quis fringilla nunc venenatis."
}
h3 { "Subsection 2.1" }
p {
"Integer ac libero id nisi posuere bibendum. Vivamus ut enim auctor, scelerisque quam a, fermentum ligula."
}
h3 { "Subsection 2.2" }
p {
"Morbi ut ex vel odio congue lobortis sit amet vel lacus. Duis rhoncus risus eget justo tincidunt vehicula."
}
h2 { "Section 3" }
p {
"Etiam quis sapien quis lacus malesuada vestibulum. Nam bibendum risus sed dui maximus, sed posuere lorem ultricies."
}
h3 { "Subsection 3.1" }
p {
"Cras interdum arcu at dolor dictum, a posuere urna aliquam. Vestibulum nec tortor nec nunc cursus lobortis sit amet a arcu."
}
h3 { "Subsection 3.2" }
p {
"Nunc auctor mauris quis lacus molestie lobortis. Vivamus eu sapien vel ligula congue convallis."
}
p {
a href="#" { "Link 1" }
" | "
a href="#" { "Link 2" }
" | "
a href="#" { "Link 3" }
}
},
)) ))
} }