aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-12-26 14:57:58 +0000
committerFuwn <[email protected]>2024-03-17 13:52:56 +0000
commit7bdb71a5e2540c101da57514c3731027d09c6dbf (patch)
tree4197eb5358bbb485831fbf1523f53306eca61164
parentci(earthly): remove git (diff)
downloadseptember-7bdb71a5e2540c101da57514c3731027d09c6dbf.tar.xz
september-7bdb71a5e2540c101da57514c3731027d09c6dbf.zip
feat(response): html head variable
-rw-r--r--README.md19
-rw-r--r--src/response.rs4
2 files changed, 18 insertions, 5 deletions
diff --git a/README.md b/README.md
index 4f97859..04944a5 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@ A simple and efficient Gemini-to-HTTP proxy written in Rust.
### Docker
```shell
-$ docker run -d [ -e ROOT="gemini://fuwn.me" ] [ -e PORT="8080"] [ -e CSS_EXTERNAL="https://example.com/style.css"] fuwn/september:latest
+docker run -d [ -e ROOT="gemini://fuwn.me" ] [ -e PORT="8080"] [ -e CSS_EXTERNAL="https://example.com/style.css"] fuwn/september:latest
```
### Docker Compose
@@ -17,13 +17,13 @@ $ docker run -d [ -e ROOT="gemini://fuwn.me" ] [ -e PORT="8080"] [ -e CSS_EXTERN
Edit the `docker-compose.yaml` file to your liking, and then
```shell
-$ docker-compose up -d
+docker-compose up -d
```
### Executable
```shell
-$ [ ROOT="gemini://fuwn.me" ] [ PORT="8080"] [ CSS_EXTERNAL="https://example.com/style.css"] ./september
+[ ROOT="gemini://fuwn.me" ] [ PORT="8080"] [ CSS_EXTERNAL="https://example.com/style.css"] ./september
```
or use a `.env` file
@@ -34,12 +34,13 @@ or use a `.env` file
ROOT=gemini://fuwn.me
PORT=8080
CSS_EXTERNAL=https://example.com/style.css
+HEAD=<script>/* september */</script>
```
and then
```shell
-$ ./september
+./september
```
## Configuration
@@ -85,11 +86,19 @@ CSS_EXTERNAL=https://cdnjs.cloudflare.com/ajax/libs/mini.css/3.0.1/mini-default.
Keeps exactly matching URLs as a Gemini URL.
+### `HEAD`
+
+Inserts any string at the end of the HTMl `<head>`
+
+```dotenv
+HEAD=<script>/* september */</script>
+```
+
#### Examples
If `KEEP_GEMINI_EXACT` is equal to `KEEP_GEMINI_EXACT=gemini://fuwn.me/gemini`,
all routes will be proxied their "/proxy" equivalent (e.g.,
-"https://fuwn.me/proxy/fuwn.me/gopher"), except occurrences of
+"<https://fuwn.me/proxy/fuwn.me/gopher>"), except occurrences of
"gemini://fuwn.me/skills" will be kept as is.
```dotenv
diff --git a/src/response.rs b/src/response.rs
index 4f7c693..911880f 100644
--- a/src/response.rs
+++ b/src/response.rs
@@ -178,6 +178,10 @@ For example: to proxy "gemini://fuwn.me/uptime", visit "/proxy/fuwn.me/uptime".<
);
}
+ if let Ok(head) = var("HEAD") {
+ html_context.push_str(&head);
+ }
+
// Add a title to HTML response
html_context.push_str(&format!("<title>{gemini_title}</title>"));
html_context.push_str("</head><body>");