Compare commits

...

2 commits

Author SHA1 Message Date
a66e26477c Clean up HTML&CSS 2024-03-29 14:58:24 +03:00
1ba9c87184 Treat today differently in previous day view 2024-03-29 14:48:55 +03:00
6 changed files with 13 additions and 11 deletions

View file

@ -1,11 +1,10 @@
{{define "header"}}
<header>
<h1>🌺 Hibiscus.txt</h1>
<p id="status">Today is <span id="today-date">a place</span></p>
<p>Today is <span id="today-date">a place</span></p>
</header>
{{end}}
{{define "base"}}
<!DOCTYPE html>
<html lang="en">
@ -23,10 +22,7 @@
{{template "main" .}}
</main>
{{template "footer" .}}
<script defer>
updateDate()
beginDateUpdater()
</script>
<script defer>updateDate();beginDateUpdater()</script>
</body>
</html>
{{end}}

View file

@ -1,4 +1,4 @@
{{define "main"}}
<h2 style="margin-bottom:0;"><label for="day">Viewing {{ .Date }}</label> | <a href="/day">Go back</a></h2>
<h2><label for="day">{{ .Date }}</label> | <a href="/day">Go back</a></h2>
<textarea id="day" cols="40" rows="15" readonly>{{ .Day }}</textarea>
{{end}}

View file

@ -1,6 +1,6 @@
{{define "main"}}
<h2>{{.Title}}</h2>
<ul id="days">
<ul>
{{range .Entries}}
<li><a href="/day/{{.Link}}">{{.Name}}</a></li>
{{end}}

View file

@ -1,6 +1,6 @@
{{define "main"}}
<form method="POST">
<h2 style="margin-bottom:0;"><label for="day">Your day so far:</label></h2>
<h2><label for="day">Your day so far:</label></h2>
<textarea id="day" cols="40" rows="15" name="day">{{ .Day }}</textarea>
<button type="submit">Save</button>
</form>

View file

@ -12,8 +12,7 @@ body {
display: flex;
flex-direction: column;
}
/* Red links! */
h2 { margin-bottom:12px; }
a, a:visited { color: #f85552; }
a:hover, a:visited:hover { color: #e66868; }

View file

@ -89,6 +89,9 @@ func GetDays(w http.ResponseWriter, r *http.Request) {
if err == nil {
dayString = t.Format("02 Jan 2006")
}
if v == time.Now().Format(time.DateOnly) {
dayString = "Today"
}
daysFormatted = append(daysFormatted, ListEntry{Name: dayString, Link: v})
}
@ -116,6 +119,10 @@ func GetDay(w http.ResponseWriter, r *http.Request) {
HandleWrite(w.Write([]byte("day not specified")))
return
}
if dayString == time.Now().Format(time.DateOnly) { // today can still be edited
http.Redirect(w, r, "/", 302)
return
}
day, err := ReadFile("day/" + dayString)
if err != nil {
slog.Error("error reading day's file", "error", err, "day", dayString)