Compare commits
3 commits
fdc2023cfe
...
08a5816f83
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08a5816f83 | ||
|
|
2611b5a9fa | ||
|
|
8d44dcf180 |
7 changed files with 48 additions and 18 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1379,7 +1379,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "mdws"
|
||||
version = "0.1.3"
|
||||
version = "0.1.5"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dirs",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "mdws"
|
||||
version = "0.1.3"
|
||||
version = "0.1.5"
|
||||
edition = "2024"
|
||||
authors = ["Penelope Gwen <support@pogmom.me>"]
|
||||
license-file = "LICENSE.md"
|
||||
|
|
|
|||
15
debian/changelog
vendored
15
debian/changelog
vendored
|
|
@ -1,3 +1,18 @@
|
|||
mdws 0.1.5-1 semistable; urgency=medium
|
||||
|
||||
* don't server .git lmao
|
||||
* also add .noserve as a specifically hidden directory
|
||||
* properly update debian changelog timestamp...
|
||||
|
||||
-- Penelope Gwen <support@pogmom.me> Tue, 11 Mar 2026 13:44:21 -0700
|
||||
|
||||
mdws 0.1.4-1 semistable; urgency=medium
|
||||
|
||||
* more updates to ua filtering
|
||||
* better logging
|
||||
|
||||
-- Penelope Gwen <support@pogmom.me> Tue, 10 Mar 2026 21:09:42 -0700
|
||||
|
||||
mdws 0.1.3-1 semistable; urgency=medium
|
||||
|
||||
* i should test before pushing updates
|
||||
|
|
|
|||
|
|
@ -40,11 +40,7 @@ server_domain = "127.0.0.1:3030"
|
|||
todo:
|
||||
|
||||
- rss feeds
|
||||
|
||||
- implement all client-side js modules from https://pogmom.me (i'm draining brendan of his life force so i can save the world from him)
|
||||
|
||||
- generate sitemap in sidebar
|
||||
|
||||
- implement all client-side js modules from https://old.pogmom.me (i'm draining brendan of his life force so i can save the world from him)
|
||||
- ~~generate sitemap in sidebar~~
|
||||
- detect if markdown module has associated directory (by file basename, maybe specified in frontmatter?)
|
||||
|
||||
- so much more
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@ fn column_layout(mut left_column: String, mut right_column: String) -> String {
|
|||
{
|
||||
left_column = format!("{}\n", left_column);
|
||||
}
|
||||
println!(
|
||||
/* println!(
|
||||
"page: {}\nsidebar: {}",
|
||||
right_column.lines().count(),
|
||||
left_column.lines().count()
|
||||
);
|
||||
); */
|
||||
let cli_columns: Vec<String> = left_column
|
||||
.lines()
|
||||
.zip(right_column.lines())
|
||||
|
|
|
|||
|
|
@ -173,6 +173,6 @@ fn random_image(directory: &str, server_root: PathBuf) -> PathBuf {
|
|||
.map(|f| f.expect("umm what is this?").path())
|
||||
.choose(&mut rand::rng())
|
||||
.expect("where is my rat");
|
||||
println!("{:#?}", rat_image);
|
||||
//println!("{:#?}", rat_image);
|
||||
rat_image
|
||||
}
|
||||
|
|
|
|||
33
src/main.rs
33
src/main.rs
|
|
@ -33,18 +33,20 @@ fn renderer(
|
|||
host: Option<Authority>,
|
||||
config: ServerConfig, //server_root: PathBuf,
|
||||
) -> Box<dyn warp::Reply> {
|
||||
println!("{:?} requested by {}", path, user_agent);
|
||||
println!("┌{:?} requested by {}", path, user_agent);
|
||||
let request_path: PathBuf = path.as_str().strip_prefix("/").unwrap_or_default().into();
|
||||
let target_path = config.server_root.join(request_path.clone());
|
||||
if !target_path.exists()
|
||||
|| target_path.is_file()
|
||||
|| (request_path.starts_with("assets") && target_path.is_dir())
|
||||
|| (((request_path.starts_with("assets") || request_path.starts_with(".git"))
|
||||
|| request_path.starts_with(".noserve"))
|
||||
&& target_path.is_dir())
|
||||
{
|
||||
return Box::new(warp::redirect(Uri::from_static("/")));
|
||||
}
|
||||
|
||||
// this list will grow
|
||||
let ai_user_agent_list = vec![
|
||||
let llm_user_agent_list = vec![
|
||||
"GPTBot",
|
||||
"openai",
|
||||
"ChatGPT",
|
||||
|
|
@ -56,7 +58,8 @@ fn renderer(
|
|||
"Googlebot",
|
||||
];
|
||||
|
||||
if ai_user_agent_list.iter().any(|ua| user_agent.contains(ua)) {
|
||||
if llm_user_agent_list.iter().any(|ua| user_agent.contains(ua)) {
|
||||
println!("│refused to serve llm scraper {}", user_agent);
|
||||
return Box::new(warp::reply::with_status(
|
||||
"llms breaks the internet and our world, go fuck yourself",
|
||||
warp::http::StatusCode::OK,
|
||||
|
|
@ -73,12 +76,18 @@ fn renderer(
|
|||
0
|
||||
};
|
||||
|
||||
let ua_filter = [
|
||||
let ua_counter_whitelist = [
|
||||
"Safari", "curl", "Windows", "Mac OS", "Linux", "iPhone", "iPad", "Android",
|
||||
];
|
||||
let ua_counter_blacklist = ["Kuma", "Mastodon", "Go-http-client", "Misskey", "Iceshrimp"];
|
||||
|
||||
if host.is_some_and(|x| x.as_str().eq("pogmom.me"))
|
||||
&& ua_filter.iter().any(|ua| user_agent.contains(ua))
|
||||
&& ua_counter_whitelist
|
||||
.iter()
|
||||
.any(|ua| user_agent.contains(ua))
|
||||
&& !ua_counter_blacklist
|
||||
.iter()
|
||||
.any(|ua| user_agent.contains(ua))
|
||||
{
|
||||
if target_page_visits.exists() {
|
||||
if target_page_visits
|
||||
|
|
@ -91,15 +100,25 @@ fn renderer(
|
|||
.as_secs()
|
||||
.gt(&1)
|
||||
{
|
||||
println!(
|
||||
"│Incrementing page counter at {} for visit from {}",
|
||||
path.as_str(),
|
||||
user_agent
|
||||
);
|
||||
counter = counter + 1;
|
||||
let _ = std::fs::write(target_page_visits, format!("{}", counter));
|
||||
}
|
||||
} else {
|
||||
println!(
|
||||
"│Incrementing page counter at {} for visit from {}",
|
||||
path.as_str(),
|
||||
user_agent
|
||||
);
|
||||
counter = counter + 1;
|
||||
let _ = std::fs::write(target_page_visits, format!("{}", counter));
|
||||
}
|
||||
};
|
||||
println!("serving path: {:?}", target_path);
|
||||
println!("└serving path: {} to {}", path.as_str(), user_agent);
|
||||
|
||||
let page_contents = markdowner::get_markdown_modules(&target_path);
|
||||
let sidebar_dir = PathBuf::from("assets/sidebar/");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue