diff --git a/src/main.rs b/src/main.rs index a7d5c270..90f72e80 100644 --- a/src/main.rs +++ b/src/main.rs @@ -154,9 +154,34 @@ fn robots_txt() -> Option> { } } -#[get("/")] -async fn index(version_cache: &Cache) -> Template { - render_index(ENGLISH.into(), version_cache).await +#[get("/?")] +async fn index( + uwu: Option, + version_cache: &Cache, +) -> Template { + let is_uwu = uwu.unwrap_or(false); + render_index_with_uwu(ENGLISH.into(), version_cache, is_uwu).await +} + +async fn render_index_with_uwu( + lang: String, + version_cache: &Cache, + is_uwu: bool, +) -> Template { + #[derive(Serialize)] + struct IndexData { + rust_version: String, + uwu: bool, + } + + let data = IndexData { + rust_version: rust_version::rust_version(version_cache).await, + uwu: is_uwu, + }; + + let page = "index"; + let context = Context::new(page, "", true, data, lang); + Template::render(page, context) } #[get("/", rank = 3)] diff --git a/static/images/rust-uwu.png b/static/images/rust-uwu.png new file mode 100644 index 00000000..5a28fcf6 Binary files /dev/null and b/static/images/rust-uwu.png differ diff --git a/templates/index.html.hbs b/templates/index.html.hbs index d2978d23..13cf23e6 100644 --- a/templates/index.html.hbs +++ b/templates/index.html.hbs @@ -2,7 +2,11 @@
-

{{fluent "rust"}}

+ {{#if data.uwu}} + Rust uwu image + {{else}} +

{{fluent "rust"}}

+ {{/if}}

{{fluent "tagline" linebreak="
"}}