v0.2.1
This commit is contained in:
parent
c34ae002c2
commit
763f6ea969
6 changed files with 33 additions and 6 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1441,7 +1441,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mdws"
|
name = "mdws"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "mdws"
|
name = "mdws"
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
authors = ["Penelope Gwen <support@pogmom.me>"]
|
authors = ["Penelope Gwen <support@pogmom.me>"]
|
||||||
license-file = "LICENSE.md"
|
license-file = "LICENSE.md"
|
||||||
|
|
|
||||||
7
debian/changelog
vendored
7
debian/changelog
vendored
|
|
@ -1,3 +1,10 @@
|
||||||
|
mdws 0.2.1-1 semistable; urgency=medium
|
||||||
|
|
||||||
|
* enable listing page contents
|
||||||
|
* better page content sorting
|
||||||
|
|
||||||
|
-- Penelope Gwen <support@pogmom.me> Tue, 06 Apr 2026 13:18:27 -0700
|
||||||
|
|
||||||
mdws 0.2.0-1 semistable; urgency=medium
|
mdws 0.2.0-1 semistable; urgency=medium
|
||||||
|
|
||||||
* better date sorting
|
* better date sorting
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{cmp::Reverse, path::PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
#[derive(serde::Deserialize, Debug, Clone)]
|
#[derive(serde::Deserialize, Debug, Clone)]
|
||||||
pub struct FrontMatter {
|
pub struct FrontMatter {
|
||||||
|
|
@ -75,7 +75,11 @@ pub fn get_markdown_modules(target_path: &PathBuf) -> Vec<MarkdownModule> {
|
||||||
.reverse()
|
.reverse()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
e.metadata.index.partial_cmp(&f.metadata.index).unwrap()
|
e.metadata
|
||||||
|
.index
|
||||||
|
.unwrap_or_default()
|
||||||
|
.partial_cmp(&f.metadata.index.unwrap_or(999))
|
||||||
|
.unwrap()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mds
|
mds
|
||||||
|
|
|
||||||
|
|
@ -102,14 +102,26 @@ pub fn sidebar_content(
|
||||||
root_path: PathBuf,
|
root_path: PathBuf,
|
||||||
counter: i32,
|
counter: i32,
|
||||||
path: &str,
|
path: &str,
|
||||||
|
page_path: &PathBuf,
|
||||||
) -> Vec<MarkdownModule> {
|
) -> Vec<MarkdownModule> {
|
||||||
let sidebar_modules = markdowner::get_markdown_modules(target_path);
|
let sidebar_modules = markdowner::get_markdown_modules(target_path);
|
||||||
|
let page_modules: Vec<String> = markdowner::get_markdown_modules(page_path)
|
||||||
|
.iter()
|
||||||
|
.filter(|m| m.path.file_stem().unwrap().ne("header"))
|
||||||
|
.map(|m| {
|
||||||
|
format!(
|
||||||
|
"- [{}](#{})",
|
||||||
|
m.metadata.title.clone(),
|
||||||
|
m.path.file_stem().unwrap().to_str().unwrap(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
let sidebar_modules: Vec<MarkdownModule> = sidebar_modules
|
let sidebar_modules: Vec<MarkdownModule> = sidebar_modules
|
||||||
.iter()
|
.iter()
|
||||||
.map(|f| match f.metadata.title.as_str() {
|
.map(|f| match f.metadata.title.as_str() {
|
||||||
"rats" => random_image_module(f, "rats", root_path.clone()),
|
"rats" => random_image_module(f, "rats", root_path.clone()),
|
||||||
"buttons" => random_image_module(f, "buttons", root_path.clone()),
|
"buttons" => random_image_module(f, "buttons", root_path.clone()),
|
||||||
"sitemap" => sitemap(f, &root_path, counter, path),
|
"sitemap" => sitemap(f, &root_path, counter, path, page_modules.clone()),
|
||||||
_ => MarkdownModule {
|
_ => MarkdownModule {
|
||||||
path: f.path.clone(),
|
path: f.path.clone(),
|
||||||
content: f.content.clone(),
|
content: f.content.clone(),
|
||||||
|
|
@ -125,6 +137,7 @@ fn sitemap(
|
||||||
root_path: &PathBuf,
|
root_path: &PathBuf,
|
||||||
counter: i32,
|
counter: i32,
|
||||||
path: &str,
|
path: &str,
|
||||||
|
page_modules: Vec<String>,
|
||||||
) -> MarkdownModule {
|
) -> MarkdownModule {
|
||||||
let mut writer: Vec<u8> = Vec::new();
|
let mut writer: Vec<u8> = Vec::new();
|
||||||
let dir = PathItem(root_path.clone());
|
let dir = PathItem(root_path.clone());
|
||||||
|
|
@ -153,9 +166,12 @@ fn sitemap(
|
||||||
|
|
||||||
let tree_text = String::from_utf8(writer).expect("could not parse string from utf8");
|
let tree_text = String::from_utf8(writer).expect("could not parse string from utf8");
|
||||||
|
|
||||||
|
let page_content = page_modules.join("\n\n");
|
||||||
|
|
||||||
let visit_count = format!("{}", counter);
|
let visit_count = format!("{}", counter);
|
||||||
|
|
||||||
values.insert("sitemap", tree_text.as_str());
|
values.insert("sitemap", tree_text.as_str());
|
||||||
|
values.insert("content", page_content.as_str());
|
||||||
values.insert("location", path);
|
values.insert("location", path);
|
||||||
values.insert("visit_count", &visit_count.as_str());
|
values.insert("visit_count", &visit_count.as_str());
|
||||||
|
|
||||||
|
|
@ -173,6 +189,5 @@ fn random_image(directory: &str, server_root: PathBuf) -> PathBuf {
|
||||||
.map(|f| f.expect("umm what is this?").path())
|
.map(|f| f.expect("umm what is this?").path())
|
||||||
.choose(&mut rand::rng())
|
.choose(&mut rand::rng())
|
||||||
.expect("where is my rat");
|
.expect("where is my rat");
|
||||||
//println!("{:#?}", rat_image);
|
|
||||||
rat_image
|
rat_image
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,6 +138,7 @@ fn renderer(
|
||||||
config.server_root.clone(),
|
config.server_root.clone(),
|
||||||
counter,
|
counter,
|
||||||
path.as_str(),
|
path.as_str(),
|
||||||
|
&target_path,
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = if user_agent.starts_with("curl/") {
|
let response = if user_agent.starts_with("curl/") {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue