Compare commits

...

4 commits

Author SHA1 Message Date
f33206c99d Improve comments for embedded filesystems 2024-06-02 12:27:36 +03:00
Andrey N
ada165fe29
Merge pull request #2
Log real IP address and fix textarea padding in Safari
2024-06-02 12:07:09 +03:00
Rithas K
e5962ebfe7
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)
2024-06-02 11:53:40 +05:30
Rithas K
408d244471
Log real IP address
Log real IP address of the client when accessed through a reverse proxy
2024-06-02 10:29:11 +05:30
6 changed files with 18 additions and 6 deletions

View file

@ -1,6 +1,11 @@
# Changelog # Changelog
This file keeps track of changes in more human-readable fashion 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 ## 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. 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 ## v1.1.0

View file

@ -48,6 +48,7 @@ var DefaultConfig = Config{
TelegramToken: "", TelegramToken: "",
TelegramChat: "", TelegramChat: "",
TelegramTopic: "",
} }
// String returns text version of modified and mandatory config options // String returns text version of modified and mandatory config options

View file

@ -15,7 +15,7 @@ type AppInfo struct {
// Info contains app information // Info contains app information
var Info = AppInfo{ var Info = AppInfo{
Version: "1.1.1", Version: "1.1.2",
SourceLink: "https://git.a71.su/Andrew71/hibiscus", SourceLink: "https://git.a71.su/Andrew71/hibiscus",
} }

View file

@ -25,6 +25,7 @@
--textarea-border-dark: #454545; --textarea-border-dark: #454545;
} }
* { box-sizing: border-box; }
body { body {
color: var(--text-light); color: var(--text-light);
background-color: var(--bg-light); background-color: var(--bg-light);

View file

@ -27,17 +27,21 @@ type Entry struct {
type formatEntries func([]string) []Entry type formatEntries func([]string) []Entry
// Public contains the static files e.g. CSS, JS
//
//go:embed public //go:embed public
var Public embed.FS var Public embed.FS
// Pages contains the HTML templates used by the app
//
//go:embed pages //go:embed pages
var Pages embed.FS var Pages embed.FS
// EmbeddedFile returns a file in Pages while "handling" potential errors // EmbeddedPage returns contents of a file in Pages while "handling" potential errors
func EmbeddedFile(name string) []byte { func EmbeddedPage(name string) []byte {
data, err := Pages.ReadFile(name) data, err := Pages.ReadFile(name)
if err != nil { if err != nil {
slog.Error("Error embedded file", "err", err) slog.Error("error reading embedded file", "err", err)
} }
return data return data
} }
@ -54,13 +58,13 @@ var listTemplate = template.Must(template.New("").Funcs(templateFuncs).ParseFS(P
// NotFound returns a user-friendly 404 error page // NotFound returns a user-friendly 404 error page
func NotFound(w http.ResponseWriter, r *http.Request) { func NotFound(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(404) 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 // InternalError returns a user-friendly 500 error page
func InternalError(w http.ResponseWriter, r *http.Request) { func InternalError(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(500) 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 // GetToday renders HTML page for today's entry

View file

@ -12,6 +12,7 @@ import (
// Serve starts the app's web server // Serve starts the app's web server
func Serve() { func Serve() {
r := chi.NewRouter() r := chi.NewRouter()
r.Use(middleware.RealIP)
r.Use(middleware.Logger, middleware.CleanPath, middleware.StripSlashes) r.Use(middleware.Logger, middleware.CleanPath, middleware.StripSlashes)
r.NotFound(NotFound) r.NotFound(NotFound)