Add humans.txt (#11)
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-28 12:19:46 +02:00
parent d3ad35f3e8
commit b3acf9e89b
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
4 changed files with 47 additions and 4 deletions

View file

@ -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<Config>) -> 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")]

BIN
static/badges/humanstxt.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 987 B

16
templates/humans.txt Normal file
View file

@ -0,0 +1,16 @@
/* ABOUT ME */{{#data}}
{{name}}
Contact: {{contact}}
Lang: {{lang}}
/* THANKS */
All the dependencies I use for building ewp
They are listed here: https://git.mylloon.fr/Anri/mylloon.fr/src/branch/main/Cargo.toml
/* SITE */
Authored by Anri (Mylloon)
Tech used: Rust, HTML5, CSS3, JavaScript, mustache templates, Docker, TOML files, Markdown, XML, Internet
IDE: Visual Studio Code
{{/data}}

View file

@ -262,12 +262,20 @@
/></a>
<a
href="https://www.rssboard.org/rss-validator/check.cgi?url=https%3A//www.mylloon.fr/blog/rss"
target="_blank"
href="//www.rssboard.org/rss-validator/check.cgi?url=https%3A//www.mylloon.fr/blog/rss"
><img
src="/badges/valid-rss.png"
alt="[Valid RSS]"
title="Validate my RSS feed"
/></a>
<a target="_blank" href="/humans.txt"
><img
src="/badges/humanstxt.gif"
alt="humans.txt"
title="We are humans"
/></a>
</div>
<br />