Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,34 @@ fn robots_txt() -> Option<content::RawText<&'static str>> {
}
}

#[get("/")]
async fn index(version_cache: &Cache<RustVersion>) -> Template {
render_index(ENGLISH.into(), version_cache).await
#[get("/?<uwu>")]
async fn index(
uwu: Option<bool>,
version_cache: &Cache<RustVersion>,
) -> 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<RustVersion>,
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("/<locale>", rank = 3)]
Expand Down
Binary file added static/images/rust-uwu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion templates/index.html.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
<header class="mt3 mb6 w-100 mw-none ph3 mw8-m mw9-l center">
<div class="flex flex-column flex-row-l">
<div class="w-70-l mw8-l">
<h1>{{fluent "rust"}}</h1>
{{#if data.uwu}}
<img src="/static/images/rust-uwu.png" height="200" alt="Rust uwu image" />
{{else}}
<h1>{{fluent "rust"}}</h1>
{{/if}}
<h2 class="mt4 mb0 f2 f1-ns">
{{fluent "tagline" linebreak="<br class='dn db-ns'>"}}
</h2>
Expand Down
Loading