+ Meta data and page data are now split
More env vars to keep track of and doc in the landing page too -_-
This commit is contained in:
parent
5707499af9
commit
46f9000358
@ -2,35 +2,52 @@ use rocket_dyn_templates::Template;
|
||||
use rocket::fs::NamedFile;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
|
||||
// TODO: try... literally try to reduce the number of clones that happen here
|
||||
|
||||
lazy_static! {
|
||||
static ref SITENAME: String = {
|
||||
env::var("SITE_NAME").unwrap_or("Clippable".to_string())
|
||||
};
|
||||
static ref SITEDESC: String = {
|
||||
env::var("SITE_DESC").unwrap_or("Short clips".to_string())
|
||||
};
|
||||
static ref SITEURL: String = {
|
||||
env::var("SITE_URL").unwrap_or("#".to_string())
|
||||
};
|
||||
}
|
||||
|
||||
fn default_map() -> HashMap<&'static str, String> {
|
||||
let mut h: HashMap<&'static str, String> = HashMap::new();
|
||||
h.insert("sitetitle", SITENAME.clone());
|
||||
h.insert("sitedesc", SITEDESC.clone());
|
||||
h.insert("siteurl", SITEURL.clone());
|
||||
return h;
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
pub async fn home() -> Template {
|
||||
let mut h: HashMap<&'static str, &'static str> = HashMap::new();
|
||||
h.insert("script_src", "index.js");
|
||||
h.insert("page", "home");
|
||||
let mut h = default_map();
|
||||
h.insert("script_src", String::from("index.js"));
|
||||
h.insert("page", String::from("home"));
|
||||
h.insert("title", SITENAME.clone());
|
||||
|
||||
return Template::render("list", &h);
|
||||
}
|
||||
|
||||
#[get("/category/<cat..>")]
|
||||
pub async fn category(cat: PathBuf) -> Template {
|
||||
let mut h: HashMap<&'static str, &str> = HashMap::new();
|
||||
h.insert("script_src", "category.js");
|
||||
h.insert("page", "category");
|
||||
let mut h = default_map();
|
||||
h.insert("script_src", String::from("category.js"));
|
||||
h.insert("page", String::from("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);
|
||||
h.insert("title", cat.to_string());
|
||||
h.insert("url", format!("/category/{}", cat));
|
||||
h.insert("desc", format!("{} clips", cat));
|
||||
h.insert("ogimg", format!("/thumbnail/{}/category-thumbnail.jpg", cat));
|
||||
|
||||
return Template::render("list", &h);
|
||||
}
|
||||
|
@ -20,10 +20,10 @@
|
||||
{% endif %}
|
||||
{# Otherwise we defautl to the home tags #}
|
||||
{% else %}
|
||||
<meta property="og:title" content="Shockrah's Clips">
|
||||
<meta property="og:title" content="{{sitetitle}}">
|
||||
<meta property="og:site_name" content="Clippable">
|
||||
<meta property="og:url" content="https://clips.shockrah.xyz/">
|
||||
<meta property="og:description" content="Clips I think are kinda kewl">
|
||||
<meta property="og:url" content="{{siteurl}}">
|
||||
<meta property="og:description" content="{{sitedesc}}">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:image" content="/static/favicon.png">
|
||||
{% endif %}
|
||||
@ -32,7 +32,7 @@
|
||||
<body>
|
||||
<div id="layout">
|
||||
<div class="content">
|
||||
<h1></h1>
|
||||
<h1>{{title}}</h1>
|
||||
<div class="video-gallery" id="main-container">
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user