diff options
Diffstat (limited to 'src/blog/mod.rs')
-rw-r--r-- | src/blog/mod.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/blog/mod.rs b/src/blog/mod.rs index 3ac38eb..23f0721 100644 --- a/src/blog/mod.rs +++ b/src/blog/mod.rs @@ -1,3 +1,4 @@ +pub mod atom; pub mod helper; use self::helper::{article_metadata, get_articles}; @@ -5,10 +6,14 @@ use crate::error::MyResult; use crate::layout::{DynScaffold, Scaffold}; use crate::uri; use anyhow::anyhow; +pub use atom::r_blog_atom; +use atom::rocket_uri_macro_r_blog_atom; use rocket::{get, response::Redirect}; use std::{path::PathBuf, str::FromStr}; use tokio::fs::read_to_string; +pub const ARTICLE_ROOT: &'static str = "./blog/articles"; + #[get("/blog")] pub fn r_blog() -> Redirect { Redirect::to(rocket::uri!(r_blog_index())) @@ -17,12 +22,13 @@ pub fn r_blog() -> Redirect { #[get("/blog/index")] pub async fn r_blog_index() -> MyResult<DynScaffold<'static>> { // TODO this is a major performance issue here. requires O(n) syscalls to complete - let articles = get_articles(&PathBuf::from_str("./blog/articles").unwrap()).await?; + let articles = get_articles(&PathBuf::from_str(ARTICLE_ROOT).unwrap()).await?; Ok(Scaffold { title: "blog index".to_string(), content: markup::new! { h2 { "The Weblog" } - i { "Articles in reverse-chronological order." } + p { i { "Articles in reverse-chronological order." } } + p { a[href=uri!(r_blog_atom())]{ "Atom feed" } } ul { @for a in &articles { li { @@ -37,7 +43,7 @@ pub async fn r_blog_index() -> MyResult<DynScaffold<'static>> { #[get("/blog/<name>")] pub async fn r_blog_article(name: &str) -> MyResult<DynScaffold<'static>> { - let apath = PathBuf::from_str("./blog/articles") + let apath = PathBuf::from_str(ARTICLE_ROOT) .unwrap() .join(PathBuf::new().with_file_name(name).with_extension("md")); let a = article_metadata(apath.clone()).await?; |