⭐ Moe-Counter Compatible Website Hit Counter Written in Gleam mayu.due.moe
hit-counter svg moe

feat(index.html): show version if available

fuwn.net 78f50f24 eef8b1c3

verified
+25 -3
+5
Earthfile
··· 11 11 COPY +build/erlang-shipment/ /mayu/erlang-shipment/ 12 12 COPY themes/ /mayu/themes/ 13 13 COPY index.html /mayu/ 14 + COPY gleam.toml /mayu/ 15 + 16 + ENV MAYU_VERSION=$(grep version /mayu/gleam.toml | cut -d '"' -f 2) 17 + 18 + RUN rm /mayu/gleam.toml 14 19 15 20 WORKDIR /mayu/ 16 21
+2 -1
gleam.toml
··· 2 2 # https://gleam.run/writing-gleam/gleam-toml/. 3 3 4 4 name = "mayu" 5 - version = "0.1.8" 5 + version = "0.1.9" 6 6 gleam = ">= 1.2.0" 7 7 description = "Moe-Counter Compatible Website Hit Counter" 8 8 licenses = ["GPL-3.0-only"] ··· 19 19 gleam_json = ">= 1.0.1 and < 2.0.0" 20 20 simplifile = ">= 1.7.0 and < 2.0.0" 21 21 birl = ">= 1.6.1 and < 2.0.0" 22 + envoy = ">= 1.0.1 and < 2.0.0" 22 23 23 24 [dev-dependencies] 24 25 gleeunit = ">= 1.0.0 and < 2.0.0"
+2
index.html
··· 220 220 221 221 Source code available on 222 222 <a href="https://github.com/Fuwn/mayu" target="_blank">GitHub</a> 223 + {{ MAYU_VERSION }} 223 224 </p> 224 225 </div> 225 226 ··· 246 247 247 248 Source code available on 248 249 <a href="https://github.com/Fuwn/mayu" target="_blank">GitHub</a> 250 + {{ MAYU_VERSION }} 249 251 </p> 250 252 </div> 251 253 </main>
+3 -1
manifest.toml
··· 3 3 4 4 packages = [ 5 5 { name = "birl", version = "1.6.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "976CFF85D34D50F7775896615A71745FBE0C325E50399787088F941B539A0497" }, 6 + { name = "envoy", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "envoy", source = "hex", outer_checksum = "CFAACCCFC47654F7E8B75E614746ED924C65BD08B1DE21101548AC314A8B6A41" }, 6 7 { name = "esqlite", version = "0.8.7", build_tools = ["rebar3"], requirements = [], otp_app = "esqlite", source = "hex", outer_checksum = "AF89C66027704B681657FDCCFFCEAA238D0DD702D5F687CDA3037F1D599A7551" }, 7 8 { name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" }, 8 9 { name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" }, ··· 27 28 ] 28 29 29 30 [requirements] 30 - birl = { version = ">= 1.6.1 and < 2.0.0"} 31 + birl = { version = ">= 1.6.1 and < 2.0.0" } 32 + envoy = { version = ">= 1.0.1 and < 2.0.0"} 31 33 gleam_erlang = { version = ">= 0.25.0 and < 1.0.0" } 32 34 gleam_http = { version = ">= 3.6.0 and < 4.0.0" } 33 35 gleam_json = { version = ">= 1.0.1 and < 2.0.0" }
+13 -1
src/request.gleam
··· 1 1 import database 2 + import envoy 2 3 import gleam/json 4 + import gleam/string 3 5 import gleam/string_builder 4 6 import simplifile 5 7 import svg ··· 22 24 [] -> 23 25 case simplifile.read("index.html") { 24 26 Ok(content) -> 25 - wisp.html_response(string_builder.from_string(content), 200) 27 + wisp.html_response( 28 + string_builder.from_string( 29 + string.replace(content, "{{ MAYU_VERSION }}", case 30 + envoy.get("MAYU_VERSION") 31 + { 32 + Ok(version) -> "(v" <> version <> ")" 33 + Error(_) -> "" 34 + }), 35 + ), 36 + 200, 37 + ) 26 38 Error(_) -> wisp.not_found() 27 39 } 28 40 ["heart-beat"] ->