From 9fc315b475753e78a9c8dafd5c92fa27d30630ad Mon Sep 17 00:00:00 2001 From: WanderingPenwing Date: Mon, 2 Sep 2024 02:30:24 +0200 Subject: [PATCH] filled in tools --- pages/tools.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++-- src/common.html | 1 + src/main.rs | 44 +++++++++++++++++++++++--- 3 files changed, 121 insertions(+), 6 deletions(-) diff --git a/pages/tools.md b/pages/tools.md index 1a46b3c..0be9912 100644 --- a/pages/tools.md +++ b/pages/tools.md @@ -1,2 +1,80 @@ -# Tools -test 2 +# The Igloo - Tools + +###### nginx + +## Nginx + +> > to document + +###### cloudflare + +## Cloudflare + +> > to document + +###### portainer + +## A dashboard ⌨ + +Being as new to docker container as I was (and still am), I wanted a pretty +dashboard to motinor and tinker with the containers I run on the server. +I chose [portainer](https://www.portainer.io/") for its beginner-friendliness, +and it never failed me (yet). + +*port.penwing.org* + +###### pihole + +## An adblocker 🛑 + +*local network only x)* + +###### searxng + +## A search engine 🔍 + +I am not a big corporate fan *(as a linux user, surprising)*, so I was +unhappy about relying on google for my searchs. Not because of its hunger for data +but merely because I want to search for informations and not accept whatever google +says the best result is. [SearXNG](https://github.com/searxng/searxng) +is a **self-hostable meta search engine** (a bit of a mouthful). What it means +in practice is that it will sort results according to *multiple sources* +instead of just one (and you can choose the sources !) + +*search.penwing.org* + +###### forgejo + +## Some git versioning 🗃 + +> > to document + +*git.penwing.org* + +###### jellyfin + +## Some movies 🎬 + +As a huge movie watcher, which I collect very legally, I had to make myself a +collection. But why not share it with my friends ? So I use my server to host a +[Jellyfin](https://jellyfin.org/) instance + +*movie.penwing.org* + +###### stirling + +## A pdf "edition" tool + +> > to document + +*pdf.penwing.org* + +###### seafile + +## A file manager 📁 + +While I use a lot scp (not the foundation, [the command](https://linux.die.net/man/1/scp)), +I like to have my own remote file drive. Following the move away from google as a +search engine, I want to be free of google drive as well. + +*file.penwing.org* diff --git a/src/common.html b/src/common.html index 38b27c1..719e7a1 100644 --- a/src/common.html +++ b/src/common.html @@ -31,6 +31,7 @@

#CONTENT# +




diff --git a/src/main.rs b/src/main.rs index e9f3e9e..c90753b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,48 @@ -use pulldown_cmark::{Parser, html}; +use pulldown_cmark::{Parser, html, Event, Tag, HeadingLevel}; use actix_web::{web, App, HttpServer, HttpResponse, Responder}; use std::fs; +fn slugify(text: &str) -> String { + text.to_lowercase() + .replace(" ", "-") + .replace(|c: char| !c.is_alphanumeric() && c != '-', "") +} + fn markdown_to_html(markdown_content: &str) -> String { - let mut html_output = String::new(); let parser = Parser::new(markdown_content); - html::push_html(&mut html_output, parser); - html_output + + let mut html_output = String::new(); + let mut events = Vec::new(); + let mut in_header = false; + let mut header_text = String::new(); + + for event in parser { + match &event { + Event::Start(Tag::Heading(HeadingLevel::H6, ..)) => { + in_header = true; + header_text.clear(); + } + Event::End(Tag::Heading(HeadingLevel::H6, ..)) => { + in_header = false; + let slug = slugify(&header_text); + events.push(Event::Html(format!("


", slug).into())); + } + Event::Text(text) => { + if in_header { + header_text.push_str(text); + } else { + events.push(event.clone()); + } + } + _ => { + events.push(event.clone()); + } + } + } + + let mut html_renderer = String::new(); + html::push_html(&mut html_renderer, events.into_iter()); + html_renderer } async fn serve_markdown(file_path: &str) -> impl Responder {