mirror of
https://github.com/YGGverse/btracker.git
synced 2026-03-31 09:05:30 +00:00
implement semantic meta titles
This commit is contained in:
parent
b53a6cf8ca
commit
ee494dbfd8
2 changed files with 24 additions and 1 deletions
23
src/main.rs
23
src/main.rs
|
|
@ -50,6 +50,18 @@ fn index(
|
||||||
Ok(Template::render(
|
Ok(Template::render(
|
||||||
"index",
|
"index",
|
||||||
context! {
|
context! {
|
||||||
|
title: {
|
||||||
|
let mut t = meta.title.clone();
|
||||||
|
if let Some(ref description) = meta.description {
|
||||||
|
t.push_str(S);
|
||||||
|
t.push_str(description)
|
||||||
|
}
|
||||||
|
if let Some(p) = page {
|
||||||
|
t.push_str(S);
|
||||||
|
t.push_str(&format!("Page {p}"));
|
||||||
|
}
|
||||||
|
t
|
||||||
|
},
|
||||||
meta: meta.inner(),
|
meta: meta.inner(),
|
||||||
back: page.map(|p| uri!(index(if p > 2 { Some(p - 1) } else { None }))),
|
back: page.map(|p| uri!(index(if p > 2 { Some(p - 1) } else { None }))),
|
||||||
next: if page.unwrap_or(1) * public.default_limit >= total { None }
|
next: if page.unwrap_or(1) * public.default_limit >= total { None }
|
||||||
|
|
@ -105,6 +117,15 @@ fn info(
|
||||||
Ok(Template::render(
|
Ok(Template::render(
|
||||||
"info",
|
"info",
|
||||||
context! {
|
context! {
|
||||||
|
title: {
|
||||||
|
let mut t = String::new();
|
||||||
|
if let Some(ref name) = torrent.name {
|
||||||
|
t.push_str(name);
|
||||||
|
t.push_str(S)
|
||||||
|
}
|
||||||
|
t.push_str(&meta.title);
|
||||||
|
t
|
||||||
|
},
|
||||||
meta: meta.inner(),
|
meta: meta.inner(),
|
||||||
created: torrent.creation_date.map(|t| t.format(&meta.format_time).to_string()),
|
created: torrent.creation_date.map(|t| t.format(&meta.format_time).to_string()),
|
||||||
files_total: torrent.files(),
|
files_total: torrent.files(),
|
||||||
|
|
@ -219,3 +240,5 @@ fn rocket() -> _ {
|
||||||
.mount("/", rocket::fs::FileServer::from(config.public))
|
.mount("/", rocket::fs::FileServer::from(config.public))
|
||||||
.mount("/", routes![index, rss, info])
|
.mount("/", routes![index, rss, info])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const S: &str = " - ";
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>{{ meta.title }}</title>
|
<title>{{ title }}</title>
|
||||||
{% if meta.description %}
|
{% if meta.description %}
|
||||||
<meta name="description" content="{{ meta.description }}" />
|
<meta name="description" content="{{ meta.description }}" />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue