Made opengraph info page redirect

This commit is contained in:
G2-Games 2025-05-20 19:12:09 -05:00
parent 4f39f6b081
commit 3c04b72cd8
4 changed files with 40 additions and 28 deletions

View file

@ -10,6 +10,9 @@ build = "build.rs"
[lints] [lints]
workspace = true workspace = true
[features]
git_tag = ["vergen-gix"]
[dependencies] [dependencies]
blake3 = { version = "1.5", features = ["mmap", "rayon", "serde"] } blake3 = { version = "1.5", features = ["mmap", "rayon", "serde"] }
chrono = { version = "0.4", features = ["serde"] } chrono = { version = "0.4", features = ["serde"] }
@ -29,4 +32,4 @@ uuid = { version = "1.11", features = ["serde", "v4"] }
[build-dependencies] [build-dependencies]
vergen-gix = { version = "1.0", features = ["build", "cargo", "rustc", "si"] } vergen-gix = { version = "1.0", features = ["build", "cargo", "rustc", "si"], optional = true }

View file

@ -1,23 +1,24 @@
use vergen_gix::{BuildBuilder, CargoBuilder, Emitter, GixBuilder, RustcBuilder, SysinfoBuilder};
fn main() { fn main() {
let build = BuildBuilder::all_build().unwrap(); #[cfg(feature = "git_tag")]
let cargo = CargoBuilder::all_cargo().unwrap(); {
let gitcl = GixBuilder::all_git().unwrap(); let build = vergen_gix::BuildBuilder::all_build().unwrap();
let rustc = RustcBuilder::all_rustc().unwrap(); let cargo = vergen_gix::CargoBuilder::all_cargo().unwrap();
let si = SysinfoBuilder::all_sysinfo().unwrap(); let gitcl = vergen_gix::GixBuilder::all_git().unwrap();
let rustc = vergen_gix::RustcBuilder::all_rustc().unwrap();
let si = vergen_gix::SysinfoBuilder::all_sysinfo().unwrap();
Emitter::default() vergen_gix::Emitter::default()
.add_instructions(&build) .add_instructions(&build)
.unwrap() .unwrap()
.add_instructions(&cargo) .add_instructions(&cargo)
.unwrap() .unwrap()
.add_instructions(&gitcl) .add_instructions(&gitcl)
.unwrap() .unwrap()
.add_instructions(&rustc) .add_instructions(&rustc)
.unwrap() .unwrap()
.add_instructions(&si) .add_instructions(&si)
.unwrap() .unwrap()
.emit() .emit()
.unwrap(); .unwrap();
}
} }

View file

@ -60,6 +60,11 @@ pub async fn file_info_opengraph(
let title = entry.name().clone() + " - " + &size + " - " + &expiry; let title = entry.name().clone() + " - " + &size + " - " + &expiry;
let url = uri!(lookup_mmid_name(
mmid.to_string(),
entry.name()
)).to_string();
Some(html! { Some(html! {
(DOCTYPE) (DOCTYPE)
meta charset="UTF-8"; meta charset="UTF-8";
@ -68,6 +73,12 @@ pub async fn file_info_opengraph(
meta property="og:title" content=(title); meta property="og:title" content=(title);
meta property="twitter:title" content=(title); meta property="twitter:title" content=(title);
meta property="og:description" content={"Size: " (size) ", expires in " (expiry)}; meta property="og:description" content={"Size: " (size) ", expires in " (expiry)};
body {
script {
"window.location.href = '" (url) "';"
}
}
}) })
} }

View file

@ -17,13 +17,10 @@ pub fn head(page_title: &str) -> Markup {
} }
pub fn footer() -> Markup { pub fn footer() -> Markup {
let hash = match option_env!("VERGEN_GIT_SHA") { let hash = option_env!("VERGEN_GIT_SHA").map(|h| &h[0..7]);
Some(hash) => &hash[0..7],
None => "",
};
let pkg_version = env!("CARGO_PKG_VERSION"); let pkg_version = env!("CARGO_PKG_VERSION");
let hash_link = "https://github.com/Dangoware/confetti-box/commit/".to_string() + hash; let build_date = option_env!("VERGEN_BUILD_DATE").unwrap_or_default();
html! { html! {
footer { footer {
@ -36,8 +33,8 @@ pub fn footer() -> Markup {
} }
p.version { "Running Confetti-Box v" (pkg_version) " " } p.version { "Running Confetti-Box v" (pkg_version) " " }
@if !hash.is_empty() { @if let Some(h) = hash {
p.version style="font-size: 0.8em" { "(" a style="font-family:'Fira Code'" href=(hash_link) {(hash)} " - " (env!("VERGEN_BUILD_DATE")) ")" } p.version style="font-size: 0.8em" { "(" a style="font-family:'Fira Code'" href={"https://github.com/Dangoware/confetti-box/commit/" (h)} {(h)} " - " (build_date) ")" }
} }
} }
} }