Add tag search.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2025-08-31 01:52:25 -05:00
parent 4e868abb01
commit 3ec4c11219
2 changed files with 56 additions and 0 deletions

View File

@@ -82,6 +82,17 @@ async fn page<'r>(
})
.render()))
}
if key == "tag" {
return PageResponder::Page(RawHtml(renderer.template("search.html")
.with_historian(&historian)
.with_page(&page)
.insert("results", &Searcher::new(&historian).tag_search(&page, value))
.insert("options", &toml! {
dynamic = true
})
.render()))
}
}
}
@@ -208,6 +219,10 @@ struct Args {
#[arg(long)]
search: Option<String>,
/// Search the wiki by tag
#[arg(long)]
tag: Option<String>,
/// Search root
#[arg(long)]
search_root: Option<String>
@@ -276,6 +291,16 @@ async fn main() {
return;
}
if let Some(tag) = args.tag {
let searcher = Searcher::new(&historian);
let search_root = args.search_root.as_deref().unwrap_or("");
let page = historian.resolve_to_page(&search_root).expect("failed to find page");
for result in searcher.tag_search(&page, &tag) {
print_result(&result);
}
return;
}
rocket::build()
.manage(historian)
.manage(renderer)