From b56ce43c80d000e7fe10b8697982fa7f56169aee Mon Sep 17 00:00:00 2001 From: Andrew-71 Date: Fri, 11 Oct 2024 11:13:55 +0300 Subject: [PATCH] Fix Makefile --- Makefile | 4 ++-- TODO.md | 5 ++++- routes.go | 7 +++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 51564d3..4adeae8 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ build: go build run: - go build & ./hibiscus-txt + go build && ./hibiscus-txt dev: - go build & ./hibiscus-txt --config config/dev-config.txt \ No newline at end of file + go build && ./hibiscus-txt --config config/dev-config.txt \ No newline at end of file diff --git a/TODO.md b/TODO.md index f5303b4..1245c97 100644 --- a/TODO.md +++ b/TODO.md @@ -3,13 +3,16 @@ List of things to add to this project ## Urgent (1.1.5-2.0.0) * `style.css` in config instead of theme (provide themes as examples in repo) -* man page, maybe try packaging for fun * Auth improvement so it DOESN'T ASK ME FOR PASSWORD EVERY DAY UGH XD ## Nice to have * Forward/backward buttons for days * Changelog included * Refactor code +* API field for version +* Notifications late in the day +* man page, maybe try packaging for fun +* store passwords as hash ## Brainstorming Don't expect any of this, these are ideas floating inside my head diff --git a/routes.go b/routes.go index 4386e57..237b089 100644 --- a/routes.go +++ b/routes.go @@ -3,7 +3,6 @@ package main import ( "embed" "errors" - "github.com/go-chi/chi/v5" "html/template" "log/slog" "net/http" @@ -11,6 +10,8 @@ import ( "os" "strings" "time" + + "github.com/go-chi/chi/v5" ) type EntryList struct { @@ -56,6 +57,7 @@ var viewTemplate = template.Must(template.New("").Funcs(templateFuncs).ParseFS(P var listTemplate = template.Must(template.New("").Funcs(templateFuncs).ParseFS(Pages, "pages/base.html", "pages/list.html")) var template404 = template.Must(template.New("404").Funcs(templateFuncs).ParseFS(Pages, "pages/error/404.html")) + // NotFound returns a user-friendly 404 error page. func NotFound(w http.ResponseWriter, r *http.Request) { w.WriteHeader(404) @@ -69,12 +71,13 @@ func NotFound(w http.ResponseWriter, r *http.Request) { } var template500 = template.Must(template.New("500").Funcs(templateFuncs).ParseFS(Pages, "pages/error/500.html")) + // InternalError returns a user-friendly 500 error page. func InternalError(w http.ResponseWriter, r *http.Request) { w.WriteHeader(500) err := template500.Execute(w, nil) - if err != nil { // Well this is awkward + if err != nil { // Well this is awkward slog.Error("error rendering error 500 page", "error", err) HandleWrite(w.Write([]byte("500. Something went *very* wrong."))) return