diff options
| author | Fuwn <[email protected]> | 2024-06-13 08:00:21 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-13 08:00:25 -0700 |
| commit | a04d75b3183098d8ab2f78514a00923f203c9cf1 (patch) | |
| tree | c8b7fe8edca214ba7986e57b7a81dfffa0f819dd /src/response.rs | |
| parent | feat(readability.gmi): update text (diff) | |
| download | locus-a04d75b3183098d8ab2f78514a00923f203c9cf1.tar.xz locus-a04d75b3183098d8ab2f78514a00923f203c9cf1.zip | |
feat(response): variable header image
Diffstat (limited to 'src/response.rs')
| -rw-r--r-- | src/response.rs | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/response.rs b/src/response.rs index c6df182..8a58a68 100644 --- a/src/response.rs +++ b/src/response.rs @@ -25,11 +25,12 @@ static QUOTES: LazyLock<Vec<String>> = LazyLock::new(|| { #[derive(yarte::Template)] #[template(path = "main")] struct Main<'a> { - pub body: &'a str, - pub hits: &'a i32, - pub quote: &'a str, - pub commit: &'a str, - pub mini_commit: &'a str, + pub body: &'a str, + pub hits: &'a i32, + pub quote: &'a str, + pub commit: &'a str, + pub mini_commit: &'a str, + pub header_image: &'a str, } pub fn success( @@ -38,15 +39,16 @@ pub fn success( ) -> Response { Response::success( Main { - body: &body.to_string(), - hits: &crate::route::hits_from(context.url.path()), - quote: { + body: &body.to_string(), + hits: &crate::route::hits_from(context.url.path()), + quote: { use rand::prelude::SliceRandom; "ES.choose(&mut rand::thread_rng()).unwrap().to_string() }, - commit: &format!("/tree/{}", env!("VERGEN_GIT_SHA")), - mini_commit: env!("VERGEN_GIT_SHA").get(0..5).unwrap_or("UNKNOWN"), + commit: &format!("/tree/{}", env!("VERGEN_GIT_SHA")), + mini_commit: env!("VERGEN_GIT_SHA").get(0..5).unwrap_or("UNKNOWN"), + header_image: &std::env::var("HEADER_IMAGE").unwrap_or_else(|_| "https://is1-ssl.mzstatic.com/image/thumb/Music112/v4/27/8b/e1/278be12a-185e-2b65-aa68-7e7e98b140f7/859754679778_cover.jpg/316x316bb.webp".to_string()), } .to_string(), ) |