From b3acf9e89b56fd39ded7f3c60ba45fb00a7994be Mon Sep 17 00:00:00 2001 From: Mylloon Date: Fri, 28 Apr 2023 12:19:46 +0200 Subject: [PATCH] Add humans.txt (#11) --- src/routes/agreements.rs | 25 ++++++++++++++++++++++--- static/badges/humanstxt.gif | Bin 0 -> 987 bytes templates/humans.txt | 16 ++++++++++++++++ templates/web3.html | 10 +++++++++- 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 static/badges/humanstxt.gif create mode 100644 templates/humans.txt diff --git a/src/routes/agreements.rs b/src/routes/agreements.rs index e677c0d..1d3ef68 100644 --- a/src/routes/agreements.rs +++ b/src/routes/agreements.rs @@ -38,9 +38,28 @@ fn build_securitytxt(config: Config, info: ConnectionInfo) -> String { } #[get("/humans.txt")] -pub async fn humans() -> impl Responder { - // TODO, see https://humanstxt.org/humans.txt - actix_web::web::Redirect::to("/") +pub async fn humans(config: web::Data) -> impl Responder { + HttpResponse::Ok().body(build_humanstxt(config.get_ref().to_owned())) +} + +#[derive(Content)] +struct HumansTemplate { + contact: String, + lang: String, + name: String, +} + +#[once(time = 60)] +fn build_humanstxt(config: Config) -> String { + config.tmpl.render( + "humans.txt", + HumansTemplate { + contact: config.fc.mail.unwrap_or_default(), + lang: config.fc.lang.unwrap_or_default(), + name: config.fc.name.unwrap_or_default(), + }, + Infos::default(), + ) } #[get("/robots.txt")] diff --git a/static/badges/humanstxt.gif b/static/badges/humanstxt.gif new file mode 100644 index 0000000000000000000000000000000000000000..8a0445b5502afed58c887ca8599bdd2694eadd68 GIT binary patch literal 987 zcmZ?wbhEHbj9`#wc*ej`TU)zk&6=pFsL!82-??+=)BNfqM~euaae%(I%AK(cFaIz(>vg{6ubZcSUO(~U)V7cFDqn<4d|uK1 z_rvRVZILhI6hAGf`TOq0zwe(v&My0T`OvSs7ryOY^sYVXO|jkcK!HySYCkQi|Gc{U zZH?EPa+miVG21t;{dQ>8^I+lExn|FNxjxP;e&3(+t~umwo$re%=~tNsALmv)_vd}r z6#Q{|!Qc0<-d215d4BIzw(+mq=YBuC`yxW}=Y{!1-1zn{6+dz8gqy_aZf2HF7UoX= za~`actO5e}WG;8PGITPyb}HP_;&0(M>|=Jl>G74TlfXyB0~*vTm5A>yFWz|hmg;9;ZGu*ijh+fL4L!r8}eUE-=r7Lyz%FfnTN z%b27%FI*s_X*I>**`os!8ASU9W_TJgGEZ`s%CHG~f1*)|+e1mP(x~Ag3zvt~iLSnc zn~Y4?7#&vm3G&b9|F7inLE+$x)(#I=PZf=cj~FI+q}}=*?r$K}X*yBDf~le5YUzI# zQIV7f2bfqC%jJq5Y-SKpc2;sZ5b%KY-jW)Am8;uB)rHn8$9kvK3dSvr z)8*lHYfTk|n6K1cafpzJ6Ol`1b188!^;qIMfkAhnFaz^ [Valid RSS] + + humans.txt