From 224abd3a93d464344796b4d511fb905edb76fd75 Mon Sep 17 00:00:00 2001 From: cbax Date: Mon, 28 Oct 2024 23:38:04 -0400 Subject: [PATCH] worked on html templates --- .gitignore | 1 + Cargo.lock | 6 +- Cargo.toml | 1 + src/main.rs | 133 ++++++++++++++++--- static/css/components.css | 52 +++++++- static/css/core.css | 28 +++- static/img/{ => 88x31}/abc.gif | Bin static/img/{ => 88x31}/adryd.png | Bin static/img/{ => 88x31}/archbtw.png | Bin static/img/{ => 88x31}/cbax.gif | Bin static/img/{ => 88x31}/dam.gif | Bin static/img/88x31/dontfeedai.gif | Bin 0 -> 934 bytes static/img/88x31/eightyeightthirtyone.png | Bin 0 -> 646 bytes static/img/{ => 88x31}/eva.gif | Bin static/img/{ => 88x31}/honbra.png | Bin static/img/88x31/index.json | 70 ++++++++++ static/img/{ => 88x31}/kofi.gif | Bin static/img/{ => 88x31}/mat.png | Bin static/img/{ => 88x31}/neovim.gif | Bin static/img/{ => 88x31}/notnite.gif | Bin static/img/{ => 88x31}/powered_by_alpine.gif | Bin static/img/88x31/preserve.gif | Bin 0 -> 2046 bytes static/img/{ => 88x31}/shwecky.png | Bin static/img/{ => 88x31}/ssi.gif | Bin static/img/{ => 88x31}/ublockorigin.png | Bin templates/blog_list.html | 4 +- templates/buttons.html | 8 ++ templates/footer.html | 3 +- templates/index.html | 84 +++--------- templates/nav.html | 6 +- 30 files changed, 293 insertions(+), 103 deletions(-) rename static/img/{ => 88x31}/abc.gif (100%) rename static/img/{ => 88x31}/adryd.png (100%) rename static/img/{ => 88x31}/archbtw.png (100%) rename static/img/{ => 88x31}/cbax.gif (100%) rename static/img/{ => 88x31}/dam.gif (100%) create mode 100644 static/img/88x31/dontfeedai.gif create mode 100644 static/img/88x31/eightyeightthirtyone.png rename static/img/{ => 88x31}/eva.gif (100%) rename static/img/{ => 88x31}/honbra.png (100%) create mode 100644 static/img/88x31/index.json rename static/img/{ => 88x31}/kofi.gif (100%) rename static/img/{ => 88x31}/mat.png (100%) rename static/img/{ => 88x31}/neovim.gif (100%) rename static/img/{ => 88x31}/notnite.gif (100%) rename static/img/{ => 88x31}/powered_by_alpine.gif (100%) create mode 100644 static/img/88x31/preserve.gif rename static/img/{ => 88x31}/shwecky.png (100%) rename static/img/{ => 88x31}/ssi.gif (100%) rename static/img/{ => 88x31}/ublockorigin.png (100%) create mode 100644 templates/buttons.html diff --git a/.gitignore b/.gitignore index ea8c4bf..fedaa2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +.env diff --git a/Cargo.lock b/Cargo.lock index 370c052..6bc995f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -389,6 +389,7 @@ dependencies = [ "gray_matter", "notify", "serde", + "serde_json", "syntect", "tokio", "tower 0.5.1", @@ -1438,11 +1439,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.111" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "176e46fa42316f18edd598015a5166857fc835ec732f5215eac6b7bdbf0a84f4" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index 7e04cee..3989b30 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ comrak = "0.29.0" gray_matter = "0.2.8" notify = "6.1.1" serde = { version = "1.0.213", features = ["derive"] } +serde_json = "1.0.132" syntect = "5.2.0" tokio = { version = "1.41.0", features = ["full"] } tower = "0.5.1" diff --git a/src/main.rs b/src/main.rs index e4909fe..dc61931 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ use comrak::{markdown_to_html_with_plugins, Options, Plugins}; use gray_matter::engine::YAML; use gray_matter::Matter; use notify::{RecursiveMode, Watcher}; +use serde::{Deserialize, Serialize}; use tower::ServiceBuilder; use tower_http::services::ServeDir; use tower_http::trace::TraceLayer; @@ -36,12 +37,11 @@ pub struct Post { body: String, } -/*#[derive(Template)] -#[template(path = "includes/head.html", escape = "none")] -struct HeadTemplate { - styles: String, - meta: Meta, -}*/ +#[derive(Clone, Deserialize, Serialize)] +pub struct Button { + path: String, + location: String, +} #[derive(Template)] #[template(path = "base.html", escape = "none")] @@ -53,7 +53,9 @@ struct BaseTemplate { #[derive(Template)] #[template(path = "index.html", escape = "none")] struct IndexTemplate { + _parent: BaseTemplate, styles: String, + meta: Meta, } #[derive(Template)] @@ -62,6 +64,15 @@ struct HomelabTemplate { styles: String, } +#[derive(Template)] +#[template(path = "buttons.html", escape = "none")] +struct ButtonsTemplate { + _parent: BaseTemplate, + styles: String, + meta: Meta, + buttons: Vec + CBAX.DEV + Blog