+ /category page handler now fills out open graph meta data correctly
This commit is contained in:
parent
3252ddd586
commit
ba7cd26f3a
@ -6,8 +6,6 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
pub async fn home() -> Template {
|
pub async fn home() -> Template {
|
||||||
// WARN: this is just to get the templates to behave but we're still
|
|
||||||
// doing everything the browser for the home page
|
|
||||||
let mut h: HashMap<&'static str, &'static str> = HashMap::new();
|
let mut h: HashMap<&'static str, &'static str> = HashMap::new();
|
||||||
h.insert("script_src", "index.js");
|
h.insert("script_src", "index.js");
|
||||||
h.insert("page", "home");
|
h.insert("page", "home");
|
||||||
@ -15,21 +13,36 @@ pub async fn home() -> Template {
|
|||||||
return Template::render("list", &h);
|
return Template::render("list", &h);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/category/<cat>")]
|
#[get("/category/<cat..>")]
|
||||||
pub async fn category(cat: String) -> Template {
|
pub async fn category(cat: PathBuf) -> Template {
|
||||||
let mut h: HashMap<&'static str, &'static str> = HashMap::new();
|
let mut h: HashMap<&'static str, &str> = HashMap::new();
|
||||||
h.insert("script_src", "category.js");
|
h.insert("script_src", "category.js");
|
||||||
h.insert("page", "category");
|
h.insert("page", "category");
|
||||||
|
|
||||||
|
// Opengraph meta tags bro
|
||||||
|
let cat = cat.file_name().unwrap().to_string_lossy();
|
||||||
|
h.insert("title", &cat);
|
||||||
|
|
||||||
|
let og_cat = format!("/category/{}", &cat);
|
||||||
|
h.insert("url", &og_cat);
|
||||||
|
|
||||||
|
let og_desc = format!("{} clips", &cat);
|
||||||
|
h.insert("desc", &og_desc);
|
||||||
|
|
||||||
|
let og_img = format!("/thumbnail/{}/category-thumbnail.jpg", cat);
|
||||||
|
h.insert("ogimg", &og_img);
|
||||||
|
|
||||||
return Template::render("list", &h);
|
return Template::render("list", &h);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/clip/<id>")]
|
#[get("/clip/<id>")]
|
||||||
pub async fn video(id: String) -> Template {
|
pub async fn video(id: String) -> Template {
|
||||||
|
println!("id: {}", id);
|
||||||
return Template::render("video", &{})
|
return Template::render("video", &{})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/<file..>")]
|
#[get("/<file..>")]
|
||||||
pub async fn files(file: PathBuf) -> Option<NamedFile> {
|
pub async fn files(file: PathBuf) -> Option<NamedFile> {
|
||||||
|
// Used for things like javascript, css, and favicons
|
||||||
NamedFile::open(Path::new("static/").join(file)).await.ok()
|
NamedFile::open(Path::new("static/").join(file)).await.ok()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user