Compare commits
1 commit
71e9776aa2
...
d68071f48c
Author | SHA1 | Date | |
---|---|---|---|
d68071f48c |
2 changed files with 20 additions and 0 deletions
|
@ -51,6 +51,7 @@ async fn main() -> Result<()> {
|
|||
.service(blog::index)
|
||||
.service(blog::rss)
|
||||
.service(blog::page)
|
||||
.service(blog::rawpage)
|
||||
.service(contrib::page)
|
||||
.service(cours::page)
|
||||
.service(cv::page)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::{
|
||||
collections::hash_map::DefaultHasher,
|
||||
fs,
|
||||
hash::{Hash, Hasher},
|
||||
};
|
||||
|
||||
|
@ -197,6 +198,24 @@ pub async fn page(path: web::Path<(String,)>, config: web::Data<Config>) -> impl
|
|||
))
|
||||
}
|
||||
|
||||
#[get("/blog/raw/{id}")]
|
||||
pub async fn rawpage(path: web::Path<(String,)>, config: web::Data<Config>) -> impl Responder {
|
||||
let filename = format!(
|
||||
"{}/{BLOG_DIR}/{POST_DIR}/{}.md",
|
||||
config.locations.data_dir,
|
||||
path.into_inner().0
|
||||
);
|
||||
|
||||
match fs::read_to_string(filename) {
|
||||
Ok(text) => HttpResponse::Ok()
|
||||
.content_type(ContentType::plaintext())
|
||||
.body(text),
|
||||
Err(_) => HttpResponse::NotFound()
|
||||
.content_type(ContentType::plaintext())
|
||||
.body("post not found"),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_post(file: &str, config: Config) -> String {
|
||||
let mut post = None;
|
||||
let (infos, toc) = get_post(
|
||||
|
|
Loading…
Reference in a new issue