use of name and fullname
All checks were successful
ci/woodpecker/push/publish Pipeline was successful

This commit is contained in:
Mylloon 2023-04-28 12:49:48 +02:00
parent c3e89a061d
commit 503173f129
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
7 changed files with 24 additions and 12 deletions

View file

@ -23,6 +23,8 @@ pub struct FileConfig {
pub app_name: Option<String>, pub app_name: Option<String>,
/// Name of website owner /// Name of website owner
pub name: Option<String>, pub name: Option<String>,
/// Fullname of website owner
pub fullname: Option<String>,
} }
impl FileConfig { impl FileConfig {
@ -58,6 +60,7 @@ impl FileConfig {
onion: test(a.onion, d.onion), onion: test(a.onion, d.onion),
app_name: test(a.app_name, d.app_name), app_name: test(a.app_name, d.app_name),
name: test(a.name, d.name), name: test(a.name, d.name),
fullname: test(a.fullname, d.fullname),
} }
} }
} }

View file

@ -56,7 +56,7 @@ fn build_humanstxt(config: Config) -> String {
HumansTemplate { HumansTemplate {
contact: config.fc.mail.unwrap_or_default(), contact: config.fc.mail.unwrap_or_default(),
lang: config.fc.lang.unwrap_or_default(), lang: config.fc.lang.unwrap_or_default(),
name: config.fc.name.unwrap_or_default(), name: config.fc.fullname.unwrap_or_default(),
}, },
Infos::default(), Infos::default(),
) )

View file

@ -52,7 +52,10 @@ pub fn build_index(config: Config) -> String {
}, },
Infos { Infos {
page_title: Some("Blog".into()), page_title: Some("Blog".into()),
page_desc: Some("Liste des posts d'Anri".into()), page_desc: Some(format!(
"Liste des posts d'{}",
config.fc.name.unwrap_or_default()
)),
page_kw: Some(["blog", "blogging"].join(", ")), page_kw: Some(["blog", "blogging"].join(", ")),
}, },
) )
@ -159,14 +162,14 @@ pub async fn page(path: web::Path<(String,)>, config: web::Data<Config>) -> impl
fn build_post(file: String, config: Config) -> String { fn build_post(file: String, config: Config) -> String {
let mut post = None; let mut post = None;
let infos = get_post(&mut post, file); let infos = get_post(&mut post, file, config.fc.name.unwrap_or_default());
config config
.tmpl .tmpl
.render("blog/post.html", BlogPostTemplate { post }, infos) .render("blog/post.html", BlogPostTemplate { post }, infos)
} }
fn get_post(post: &mut Option<File>, filename: String) -> Infos { fn get_post(post: &mut Option<File>, filename: String, name: String) -> Infos {
let blog_dir = "data/blog"; let blog_dir = "data/blog";
let ext = ".md"; let ext = ".md";
@ -182,7 +185,7 @@ fn get_post(post: &mut Option<File>, filename: String) -> Infos {
Infos { Infos {
page_title: Some(format!("Post: {}", title)), page_title: Some(format!("Post: {}", title)),
page_desc: Some("Blog d'Anri".into()), page_desc: Some(format!("Blog d'{name}")),
page_kw: Some(["blog", "blogging", "write", "writing"].join(", ")), page_kw: Some(["blog", "blogging", "write", "writing"].join(", ")),
} }
} }
@ -212,12 +215,12 @@ fn build_rss(config: Config, info: ConnectionInfo) -> String {
} }
let link_to_site = format!("{}://{}", info.scheme(), info.host()); let link_to_site = format!("{}://{}", info.scheme(), info.host());
let author = if let (Some(mail), Some(name)) = (config.fc.mail, config.fc.name) { let author = if let (Some(mail), Some(name)) = (config.fc.mail, config.fc.fullname.to_owned()) {
Some(format!("{mail} ({name})")) Some(format!("{mail} ({name})"))
} else { } else {
None None
}; };
let title = "Blog d'Anri"; let title = format!("Blog d'{}", config.fc.name.unwrap_or_default());
let lang = "fr"; let lang = "fr";
let channel = Channel { let channel = Channel {
title: title.to_owned(), title: title.to_owned(),
@ -281,7 +284,7 @@ fn build_rss(config: Config, info: ConnectionInfo) -> String {
rel: "self".into(), rel: "self".into(),
hreflang: Some(lang.into()), hreflang: Some(lang.into()),
mime_type: Some(MIME_TYPE_RSS.into()), mime_type: Some(MIME_TYPE_RSS.into()),
title: Some(title.to_owned()), title: Some(title),
length: None, length: None,
}], }],
}), }),

View file

@ -141,7 +141,10 @@ pub async fn build_page(config: Config) -> String {
data, data,
Infos { Infos {
page_title: Some("Mes contributions".into()), page_title: Some("Mes contributions".into()),
page_desc: Some("Contributions à l'opensource par Anri".into()), page_desc: Some(format!(
"Contributions à l'opensource par {}",
config.fc.name.unwrap_or_default()
)),
page_kw: None, page_kw: None,
}, },
) )

View file

@ -14,7 +14,7 @@ pub fn build_page(config: Config) -> String {
"index.html", "index.html",
(), (),
Infos { Infos {
page_title: Some("Mylloon".into()), page_title: config.fc.fullname,
page_desc: Some("Page principale".into()), page_desc: Some("Page principale".into()),
page_kw: None, page_kw: None,
}, },

View file

@ -15,7 +15,7 @@ pub fn build_page(config: Config) -> String {
(), (),
Infos { Infos {
page_title: Some("Mes réseaux".into()), page_title: Some("Mes réseaux".into()),
page_desc: Some("Réseaux d'Anri".into()), page_desc: Some(format!("Réseaux d'{}", config.fc.name.unwrap_or_default())),
page_kw: None, page_kw: None,
}, },
) )

View file

@ -76,7 +76,10 @@ pub fn build_page(config: Config) -> String {
}, },
Infos { Infos {
page_title: Some("Portfolio".into()), page_title: Some("Portfolio".into()),
page_desc: Some("Portfolio d'Anri".into()), page_desc: Some(format!(
"Portfolio d'{}",
config.fc.name.unwrap_or_default()
)),
page_kw: None, page_kw: None,
}, },
) )