Skip to content

Commit

Permalink
Improve comments for embedded filesystems
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-71 committed Jun 2, 2024
1 parent ada165f commit f33206c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var DefaultConfig = Config{

TelegramToken: "",
TelegramChat: "",
TelegramTopic: "",
}

// String returns text version of modified and mandatory config options
Expand Down
2 changes: 1 addition & 1 deletion info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand Down
5 changes: 1 addition & 4 deletions public/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 9 additions & 5 deletions routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit f33206c

Please sign in to comment.