mirror of
https://github.com/Noratrieb/website.git
synced 2026-01-14 17:05:02 +01:00
static stuff
This commit is contained in:
parent
56da12a5bc
commit
148a5352a3
8 changed files with 237 additions and 2 deletions
137
Cargo.lock
generated
137
Cargo.lock
generated
|
|
@ -26,6 +26,56 @@ dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "askama"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28"
|
||||||
|
dependencies = [
|
||||||
|
"askama_derive",
|
||||||
|
"askama_escape",
|
||||||
|
"humansize",
|
||||||
|
"num-traits",
|
||||||
|
"percent-encoding",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "askama_derive"
|
||||||
|
version = "0.12.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83"
|
||||||
|
dependencies = [
|
||||||
|
"askama_parser",
|
||||||
|
"basic-toml",
|
||||||
|
"mime",
|
||||||
|
"mime_guess",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"serde",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "askama_escape"
|
||||||
|
version = "0.10.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "askama_parser"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0"
|
||||||
|
dependencies = [
|
||||||
|
"nom",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "backtrace"
|
name = "backtrace"
|
||||||
version = "0.3.69"
|
version = "0.3.69"
|
||||||
|
|
@ -41,6 +91,15 @@ dependencies = [
|
||||||
"rustc-demangle",
|
"rustc-demangle",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "basic-toml"
|
||||||
|
version = "0.1.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2db21524cad41c5591204d22d75e1970a2d1f71060214ca931dc7d5afe2c14e5"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.83"
|
version = "1.0.83"
|
||||||
|
|
@ -117,6 +176,15 @@ version = "0.14.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "humansize"
|
||||||
|
version = "2.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6cb51c9a029ddc91b07a787f1d86b53ccfa49b0e86688c946ebe8d3555685dd7"
|
||||||
|
dependencies = [
|
||||||
|
"libm",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indenter"
|
name = "indenter"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
|
|
@ -145,6 +213,12 @@ version = "0.2.152"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libm"
|
||||||
|
version = "0.2.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.20"
|
version = "0.4.20"
|
||||||
|
|
@ -166,6 +240,28 @@ version = "2.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mime"
|
||||||
|
version = "0.3.17"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mime_guess"
|
||||||
|
version = "2.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef"
|
||||||
|
dependencies = [
|
||||||
|
"mime",
|
||||||
|
"unicase",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "minimal-lexical"
|
||||||
|
version = "0.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "miniz_oxide"
|
name = "miniz_oxide"
|
||||||
version = "0.7.1"
|
version = "0.7.1"
|
||||||
|
|
@ -175,6 +271,16 @@ dependencies = [
|
||||||
"adler",
|
"adler",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nom"
|
||||||
|
version = "7.1.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"minimal-lexical",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-ansi-term"
|
name = "nu-ansi-term"
|
||||||
version = "0.46.0"
|
version = "0.46.0"
|
||||||
|
|
@ -185,6 +291,15 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[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"
|
||||||
|
|
@ -212,6 +327,12 @@ version = "3.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
|
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "percent-encoding"
|
||||||
|
version = "2.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "pin-project-lite"
|
||||||
version = "0.2.13"
|
version = "0.2.13"
|
||||||
|
|
@ -456,6 +577,15 @@ dependencies = [
|
||||||
"tracing-log",
|
"tracing-log",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicase"
|
||||||
|
version = "2.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89"
|
||||||
|
dependencies = [
|
||||||
|
"version_check",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.12"
|
version = "1.0.12"
|
||||||
|
|
@ -468,10 +598,17 @@ version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "website"
|
name = "website"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"askama",
|
||||||
"color-eyre",
|
"color-eyre",
|
||||||
"fs_extra",
|
"fs_extra",
|
||||||
"serde",
|
"serde",
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
askama = "0.12.1"
|
||||||
color-eyre = "0.6.2"
|
color-eyre = "0.6.2"
|
||||||
fs_extra = "1.3.0"
|
fs_extra = "1.3.0"
|
||||||
serde = { version = "1.0.195", features = ["derive"] }
|
serde = { version = "1.0.195", features = ["derive"] }
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
mod blog;
|
mod blog;
|
||||||
mod slides;
|
mod slides;
|
||||||
|
mod statics;
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
|
@ -9,7 +10,12 @@ use color_eyre::{eyre::Context, Result};
|
||||||
|
|
||||||
use crate::Config;
|
use crate::Config;
|
||||||
|
|
||||||
pub fn assemble_website(config: &Config, submodules: &Path, dist: &Path) -> Result<()> {
|
pub fn assemble_website(
|
||||||
|
config: &Config,
|
||||||
|
statics: &Path,
|
||||||
|
submodules: &Path,
|
||||||
|
dist: &Path,
|
||||||
|
) -> Result<()> {
|
||||||
blog::build(&submodules.join("blog"), &dist.join("blog")).wrap_err("building blog")?;
|
blog::build(&submodules.join("blog"), &dist.join("blog")).wrap_err("building blog")?;
|
||||||
slides::build(
|
slides::build(
|
||||||
&config.slides,
|
&config.slides,
|
||||||
|
|
@ -18,6 +24,8 @@ pub fn assemble_website(config: &Config, submodules: &Path, dist: &Path) -> Resu
|
||||||
)
|
)
|
||||||
.wrap_err("building slides")?;
|
.wrap_err("building slides")?;
|
||||||
|
|
||||||
|
statics::build(&config.slides, statics, dist).wrap_err("building root files")?;
|
||||||
|
|
||||||
add_cname(dist)?;
|
add_cname(dist)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
29
src/build/statics.rs
Normal file
29
src/build/statics.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
//! Root index.html and some other static stuff
|
||||||
|
|
||||||
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
|
use askama::Template;
|
||||||
|
use color_eyre::{eyre::WrapErr, Result};
|
||||||
|
|
||||||
|
use crate::{utils, SlidesConfig};
|
||||||
|
|
||||||
|
#[derive(askama::Template)]
|
||||||
|
#[template(path = "slides.html")]
|
||||||
|
struct Slides {
|
||||||
|
talks: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn build(config: &SlidesConfig, statics: &Path, dist: &Path) -> Result<()> {
|
||||||
|
utils::cp_content(&statics.join("root"), dist).wrap_err("copying root files")?;
|
||||||
|
|
||||||
|
let slide_html = Slides {
|
||||||
|
talks: config.talks.clone(),
|
||||||
|
}
|
||||||
|
.render()
|
||||||
|
.wrap_err("rendering slide index")?;
|
||||||
|
|
||||||
|
fs::write(dist.join("slides").join("index.html"), slide_html)
|
||||||
|
.wrap_err("writing slides index.html")?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
12
src/main.rs
12
src/main.rs
|
|
@ -33,6 +33,16 @@ fn main() -> Result<()> {
|
||||||
// Set the current dir to nonsense to fail everything that relies on it
|
// Set the current dir to nonsense to fail everything that relies on it
|
||||||
let _ = std::env::set_current_dir("/");
|
let _ = std::env::set_current_dir("/");
|
||||||
|
|
||||||
|
if std::env::args().nth(1).as_deref() == Some("clean") {
|
||||||
|
info!("Cleaning dist");
|
||||||
|
match std::fs::remove_dir_all(root.join("dist")) {
|
||||||
|
Ok(()) => {}
|
||||||
|
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
|
||||||
|
e => return e.wrap_err("removing dist"),
|
||||||
|
}
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let config =
|
let config =
|
||||||
std::fs::read_to_string(root.join("config.toml")).wrap_err("reading config.toml")?;
|
std::fs::read_to_string(root.join("config.toml")).wrap_err("reading config.toml")?;
|
||||||
let config = toml::from_str::<Config>(&config).wrap_err("parsing config.toml")?;
|
let config = toml::from_str::<Config>(&config).wrap_err("parsing config.toml")?;
|
||||||
|
|
@ -45,7 +55,7 @@ fn main() -> Result<()> {
|
||||||
submodule::sync(&submodules_path, &sub_config).wrap_err("syncing subtrees")?;
|
submodule::sync(&submodules_path, &sub_config).wrap_err("syncing subtrees")?;
|
||||||
|
|
||||||
let dist_path = root.join("dist");
|
let dist_path = root.join("dist");
|
||||||
build::assemble_website(&config, &submodules_path, &dist_path)?;
|
build::assemble_website(&config, &root.join("static"), &submodules_path, &dist_path)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
src/utils.rs
15
src/utils.rs
|
|
@ -53,3 +53,18 @@ pub fn cp_r(from: &Path, to: &Path) -> Result<()> {
|
||||||
.wrap_err(format!("copying to {}", to.display()))?;
|
.wrap_err(format!("copying to {}", to.display()))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cp_content(from: &Path, to: &Path) -> Result<()> {
|
||||||
|
fs_extra::dir::copy(
|
||||||
|
from,
|
||||||
|
to,
|
||||||
|
&CopyOptions {
|
||||||
|
overwrite: true,
|
||||||
|
copy_inside: true,
|
||||||
|
content_only: true,
|
||||||
|
..CopyOptions::default()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.wrap_err(format!("copying to {}", to.display()))?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
18
static/root/index.html
Normal file
18
static/root/index.html
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>nilstrieb.dev</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>hi!</h1>
|
||||||
|
<p>This is my website. It is work in progress.</p>
|
||||||
|
<h2>my blog</h2>
|
||||||
|
<p>I have a blog, it might be interesting, maybe.</p>
|
||||||
|
<a href="/blog">blog</a>
|
||||||
|
<h2>slides</h2>
|
||||||
|
<p>i have given one talk, here are its slides, isnt this amazing</p>
|
||||||
|
<a href="/slides/index.html">slides from talks</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
17
templates/slides.html
Normal file
17
templates/slides.html
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Slides</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Slides</h1>
|
||||||
|
<p>Talks I have given with slides available:</p>
|
||||||
|
<div>
|
||||||
|
{% for talk in talks %}
|
||||||
|
<a href="{{ talk }}">{{ talk }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue