From bbcd7b5f638e594a0cdd968ce5b09f6ec73e718f Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 21 Apr 2022 03:59:25 +0000 Subject: feat: favicon support --- .env.example | 1 + Cargo.toml | 2 +- README.md | 8 ++++++++ src/main.rs | 9 +++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 75bcb55..cb69204 100644 --- a/.env.example +++ b/.env.example @@ -4,3 +4,4 @@ CSS_EXTERNAL=https://example.com/style.css KEEP_GEMINI_EXACT=gemini://fuwn.me/skills # KEEP_GEMINI_DOMAIN=fuwn.me # PROXY_BY_DEFAULT=true +FAVICON_EXTERNAL=https://host.fuwn.me/8te8lw0lxm03.webp diff --git a/Cargo.toml b/Cargo.toml index 9731fac..b8d4dfa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "september" -version = "0.1.2" +version = "0.1.3" authors = ["Fuwn "] edition = "2021" description = "A simple and efficient Gemini-to-HTTP proxy." diff --git a/README.md b/README.md index 91ea929..b5f7a18 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,14 @@ Defaults to `true`. PROXY_BY_DEFAULT=false ``` +### `FAVICON_EXTERNAL` + +An external favicon file to apply to the HTML response. + +```dotenv +FAVICON_EXTERNAL=https://host.fuwn.me/8te8lw0lxm03.webp +``` + ## Capsules using September [Add yours!](https://github.com/gemrest/september/edit/main/README.md) diff --git a/src/main.rs b/src/main.rs index ade91ed..327117d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -327,6 +327,15 @@ async fn default(req: actix_web::HttpRequest) -> Result { )); } + // Try to add an external favicon from the `FAVICON_EXTERNAL` environment + // variable. + if let Ok(favicon) = var("FAVICON_EXTERNAL") { + html_context.push_str(&format!( + "", + favicon + )); + } + // Add a title to HTML response html_context.push_str(&format!("{}", gemini_title)); -- cgit v1.2.3