aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-03-11 07:04:22 +0000
committerFuwn <[email protected]>2023-03-11 07:04:22 +0000
commit695b73133e1ce462f912656d762d0de4bbed5e47 (patch)
tree6ba3a2333fc846086ceb745db6bb4a303080e457
parentci(check.yaml): correct rust toolchain (diff)
downloadseptember-695b73133e1ce462f912656d762d0de4bbed5e47.tar.xz
september-695b73133e1ce462f912656d762d0de4bbed5e47.zip
feat(response): allow multiple css files
-rw-r--r--README.md2
-rw-r--r--src/response.rs13
2 files changed, 10 insertions, 5 deletions
diff --git a/README.md b/README.md
index ee65daa..4196ab9 100644
--- a/README.md
+++ b/README.md
@@ -72,7 +72,7 @@ ROOT=gemini://fuwn.me
### `CSS_EXTERNAL`
-An external CSS file to apply to the HTML response.
+A comma-seperated list of external CSS files to apply to the HTML response.
If no `CSS_EXTERNAL` is provided, there will be no styling done to the HTML
response.
diff --git a/src/response.rs b/src/response.rs
index 547cf12..393e3b8 100644
--- a/src/response.rs
+++ b/src/response.rs
@@ -141,10 +141,15 @@ pub async fn default(
// Try to add an external stylesheet from the `CSS_EXTERNAL` environment
// variable.
if let Ok(css) = var("CSS_EXTERNAL") {
- html_context.push_str(&format!(
- "<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">",
- css
- ));
+ let stylesheets =
+ css.split(',').filter(|s| !s.is_empty()).collect::<Vec<_>>();
+
+ for stylesheet in stylesheets {
+ html_context.push_str(&format!(
+ "<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">",
+ stylesheet,
+ ));
+ }
}
// Try to add an external favicon from the `FAVICON_EXTERNAL` environment