From 408d244471c288a1f658704a350aacf697daff74 Mon Sep 17 00:00:00 2001 From: Rithas K Date: Sun, 2 Jun 2024 10:29:11 +0530 Subject: [PATCH 1/3] Log real IP address Log real IP address of the client when accessed through a reverse proxy --- serve.go | 1 + 1 file changed, 1 insertion(+) diff --git a/serve.go b/serve.go index ab11789..064e98a 100644 --- a/serve.go +++ b/serve.go @@ -12,6 +12,7 @@ import ( // Serve starts the app's web server func Serve() { r := chi.NewRouter() + r.Use(middleware.RealIP) r.Use(middleware.Logger, middleware.CleanPath, middleware.StripSlashes) r.NotFound(NotFound) From e5962ebfe7aed259802ec5043a5d644cb9cd1894 Mon Sep 17 00:00:00 2001 From: Rithas K Date: Sun, 2 Jun 2024 11:53:40 +0530 Subject: [PATCH 2/3] Fix textarea padding in Safari Use `box-sizing: border-box` to include padding in the width of the textarea. Also, > Box-sizing should be border-box by default from [csswg](https://wiki.csswg.org/ideas/mistakes) --- public/main.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/main.css b/public/main.css index 9c48afb..7a3d058 100644 --- a/public/main.css +++ b/public/main.css @@ -25,6 +25,10 @@ --textarea-border-dark: #454545; } +* { + box-sizing: border-box; +} + body { color: var(--text-light); background-color: var(--bg-light); From f33206c99d202e2401271843442edbe290792583 Mon Sep 17 00:00:00 2001 From: Andrew-71 Date: Sun, 2 Jun 2024 12:27:36 +0300 Subject: [PATCH 3/3] Improve comments for embedded filesystems --- CHANGELOG.md | 5 +++++ config.go | 1 + info.go | 2 +- public/main.css | 5 +---- routes.go | 14 +++++++++----- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 015e9cb..16ad037 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog This file keeps track of changes in more human-readable fashion +## v1.1.2 +This version contains changes from pull request #2 by Rithas K. +* Real IPs are now logged +* Textarea has been fixed Safari +* Done some minor behind-the-scenes housekeeping ## v1.1.1 This release is mostly a technicality, with a move over to GitHub (`ghcr.io/andrew-71/hibiscus`) for packages due to DockerHub's anti-Russian actions making old "CI/CD" impossible. ## v1.1.0 diff --git a/config.go b/config.go index d290c2d..1883dd0 100644 --- a/config.go +++ b/config.go @@ -48,6 +48,7 @@ var DefaultConfig = Config{ TelegramToken: "", TelegramChat: "", + TelegramTopic: "", } // String returns text version of modified and mandatory config options diff --git a/info.go b/info.go index 64ecdad..7e1fc65 100644 --- a/info.go +++ b/info.go @@ -15,7 +15,7 @@ type AppInfo struct { // Info contains app information var Info = AppInfo{ - Version: "1.1.1", + Version: "1.1.2", SourceLink: "https://git.a71.su/Andrew71/hibiscus", } diff --git a/public/main.css b/public/main.css index 7a3d058..19250a4 100644 --- a/public/main.css +++ b/public/main.css @@ -25,10 +25,7 @@ --textarea-border-dark: #454545; } -* { - box-sizing: border-box; -} - +* { box-sizing: border-box; } body { color: var(--text-light); background-color: var(--bg-light); diff --git a/routes.go b/routes.go index 8d16d24..85e4a37 100644 --- a/routes.go +++ b/routes.go @@ -27,17 +27,21 @@ type Entry struct { type formatEntries func([]string) []Entry +// Public contains the static files e.g. CSS, JS +// //go:embed public var Public embed.FS +// Pages contains the HTML templates used by the app +// //go:embed pages var Pages embed.FS -// EmbeddedFile returns a file in Pages while "handling" potential errors -func EmbeddedFile(name string) []byte { +// EmbeddedPage returns contents of a file in Pages while "handling" potential errors +func EmbeddedPage(name string) []byte { data, err := Pages.ReadFile(name) if err != nil { - slog.Error("Error embedded file", "err", err) + slog.Error("error reading embedded file", "err", err) } return data } @@ -54,13 +58,13 @@ var listTemplate = template.Must(template.New("").Funcs(templateFuncs).ParseFS(P // NotFound returns a user-friendly 404 error page func NotFound(w http.ResponseWriter, r *http.Request) { w.WriteHeader(404) - HandleWrite(w.Write(EmbeddedFile("pages/error/404.html"))) + HandleWrite(w.Write(EmbeddedPage("pages/error/404.html"))) } // InternalError returns a user-friendly 500 error page func InternalError(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) - HandleWrite(w.Write(EmbeddedFile("pages/error/500.html"))) + HandleWrite(w.Write(EmbeddedPage("pages/error/500.html"))) } // GetToday renders HTML page for today's entry