diff --git a/src/main.rs b/src/main.rs index 7b29cc9..ea737de 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,12 +44,14 @@ fn not_found() -> templates::NotFound<'static> { } } -#[get("/")] -fn root() -> templates::Root<'static> { +#[get("/?")] +fn root(wallpaper: Option<&str>) -> templates::Root<'static> { templates::Root { title: "Philippe Loctaux", year: chrono::Utc::now().year(), - wallpaper: Wallpaper::random(), + wallpaper: wallpaper + .and_then(Wallpaper::find) + .or_else(Wallpaper::random), networks: Network::new(), jobs: Job::new(), talks: Talk::new(), diff --git a/src/types.rs b/src/types.rs index 063332a..364fccc 100644 --- a/src/types.rs +++ b/src/types.rs @@ -58,4 +58,8 @@ impl Wallpaper { WALLPAPERS.get(ChaCha20::new().generate_range(range)) } + + pub fn find(filename: &str) -> Option<&'static &'static Wallpaper> { + WALLPAPERS.iter().find(|w| w.file.contains(filename)) + } }