diff options
| author | Fuwn <[email protected]> | 2024-06-16 03:00:56 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-06-16 03:08:13 -0700 |
| commit | ec3eb50f213aa40f1dc9c1fe4dfce0d74a987284 (patch) | |
| tree | ff611bf63ab09832508f2964ef3324f4d70ca45f | |
| parent | 1e357dbef1a0adf53e3b492e31cdb51fdf4add2e (diff) | |
| download | mayu-ec3eb50f213aa40f1dc9c1fe4dfce0d74a987284.tar.xz mayu-ec3eb50f213aa40f1dc9c1fe4dfce0d74a987284.zip | |
feat(index.html): show version if availablev0.1.9
| -rw-r--r-- | Earthfile | 5 | ||||
| -rw-r--r-- | gleam.toml | 3 | ||||
| -rw-r--r-- | index.html | 2 | ||||
| -rw-r--r-- | manifest.toml | 4 | ||||
| -rw-r--r-- | src/request.gleam | 14 |
5 files changed, 25 insertions, 3 deletions
@@ -11,6 +11,11 @@ docker: COPY +build/erlang-shipment/ /mayu/erlang-shipment/ COPY themes/ /mayu/themes/ COPY index.html /mayu/ + COPY gleam.toml /mayu/ + + ENV MAYU_VERSION=$(grep version /mayu/gleam.toml | cut -d '"' -f 2) + + RUN rm /mayu/gleam.toml WORKDIR /mayu/ @@ -2,7 +2,7 @@ # https://gleam.run/writing-gleam/gleam-toml/. name = "mayu" -version = "0.1.8" +version = "0.1.9" gleam = ">= 1.2.0" description = "Moe-Counter Compatible Website Hit Counter" licenses = ["GPL-3.0-only"] @@ -19,6 +19,7 @@ sqlight = ">= 0.9.0 and < 1.0.0" gleam_json = ">= 1.0.1 and < 2.0.0" simplifile = ">= 1.7.0 and < 2.0.0" birl = ">= 1.6.1 and < 2.0.0" +envoy = ">= 1.0.1 and < 2.0.0" [dev-dependencies] gleeunit = ">= 1.0.0 and < 2.0.0" @@ -220,6 +220,7 @@ Source code available on <a href="https://github.com/Fuwn/mayu" target="_blank">GitHub</a> + {{ MAYU_VERSION }} </p> </div> @@ -246,6 +247,7 @@ Source code available on <a href="https://github.com/Fuwn/mayu" target="_blank">GitHub</a> + {{ MAYU_VERSION }} </p> </div> </main> diff --git a/manifest.toml b/manifest.toml index 7e73827..8871c5d 100644 --- a/manifest.toml +++ b/manifest.toml @@ -3,6 +3,7 @@ packages = [ { name = "birl", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "976CFF85D34D50F7775896615A71745FBE0C325E50399787088F941B539A0497" }, + { name = "envoy", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "CFAACCCFC47654F7E8B75E614746ED924C65BD08B1DE21101548AC314A8B6A41" }, { name = "esqlite", version = "0.8.7", build_tools = ["rebar3"], requirements = [], otp_app = "esqlite", source = "hex", outer_checksum = "AF89C66027704B681657FDCCFFCEAA238D0DD702D5F687CDA3037F1D599A7551" }, { name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" }, { name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" }, @@ -27,7 +28,8 @@ packages = [ ] [requirements] -birl = { version = ">= 1.6.1 and < 2.0.0"} +birl = { version = ">= 1.6.1 and < 2.0.0" } +envoy = { version = ">= 1.0.1 and < 2.0.0"} gleam_erlang = { version = ">= 0.25.0 and < 1.0.0" } gleam_http = { version = ">= 3.6.0 and < 4.0.0" } gleam_json = { version = ">= 1.0.1 and < 2.0.0" } diff --git a/src/request.gleam b/src/request.gleam index d9abccf..6e23caf 100644 --- a/src/request.gleam +++ b/src/request.gleam @@ -1,5 +1,7 @@ import database +import envoy import gleam/json +import gleam/string import gleam/string_builder import simplifile import svg @@ -22,7 +24,17 @@ pub fn handle(request, connection) { [] -> case simplifile.read("index.html") { Ok(content) -> - wisp.html_response(string_builder.from_string(content), 200) + wisp.html_response( + string_builder.from_string( + string.replace(content, "{{ MAYU_VERSION }}", case + envoy.get("MAYU_VERSION") + { + Ok(version) -> "(v" <> version <> ")" + Error(_) -> "" + }), + ), + 200, + ) Error(_) -> wisp.not_found() } ["heart-beat"] -> |