ability to get wallpaper from url
This commit is contained in:
parent
5e434a37ed
commit
e4570b549e
2 changed files with 9 additions and 3 deletions
|
|
@ -44,12 +44,14 @@ fn not_found() -> templates::NotFound<'static> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/?<wallpaper>")]
|
||||||
fn root() -> templates::Root<'static> {
|
fn root(wallpaper: Option<&str>) -> templates::Root<'static> {
|
||||||
templates::Root {
|
templates::Root {
|
||||||
title: "Philippe Loctaux",
|
title: "Philippe Loctaux",
|
||||||
year: chrono::Utc::now().year(),
|
year: chrono::Utc::now().year(),
|
||||||
wallpaper: Wallpaper::random(),
|
wallpaper: wallpaper
|
||||||
|
.and_then(Wallpaper::find)
|
||||||
|
.or_else(Wallpaper::random),
|
||||||
networks: Network::new(),
|
networks: Network::new(),
|
||||||
jobs: Job::new(),
|
jobs: Job::new(),
|
||||||
talks: Talk::new(),
|
talks: Talk::new(),
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,8 @@ impl Wallpaper {
|
||||||
|
|
||||||
WALLPAPERS.get(ChaCha20::new().generate_range(range))
|
WALLPAPERS.get(ChaCha20::new().generate_range(range))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn find(filename: &str) -> Option<&'static &'static Wallpaper> {
|
||||||
|
WALLPAPERS.iter().find(|w| w.file.contains(filename))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue