Lots of changes to the website
This commit is contained in:
@@ -11,9 +11,11 @@ import (
|
||||
"time"
|
||||
|
||||
"ridgwaysystems.org/website/internal/blog"
|
||||
"ridgwaysystems.org/website/internal/changelog"
|
||||
"ridgwaysystems.org/website/internal/feed"
|
||||
"ridgwaysystems.org/website/internal/mailer"
|
||||
"ridgwaysystems.org/website/internal/status"
|
||||
"ridgwaysystems.org/website/internal/uptime"
|
||||
)
|
||||
|
||||
const postsPerPage = 10
|
||||
@@ -143,7 +145,7 @@ func (h *Handler) Feed(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "feed unavailable", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
rss, err := feed.RSS(h.siteURL, "Ridgway Systems", "A homelab built on OpenBSD.", posts)
|
||||
rss, err := feed.RSS(h.siteURL, "Ridgway Systems", "A homelab built on FreeBSD.", posts)
|
||||
if err != nil {
|
||||
http.Error(w, "feed error", http.StatusInternalServerError)
|
||||
return
|
||||
@@ -156,10 +158,17 @@ func (h *Handler) Infrastructure(w http.ResponseWriter, r *http.Request) {
|
||||
h.render(w, "infrastructure", nil)
|
||||
}
|
||||
|
||||
// serviceHistory bundles per-service uptime data for the status template.
|
||||
type serviceHistory struct {
|
||||
Blocks []uptime.DayBlock
|
||||
UptimePct float64
|
||||
}
|
||||
|
||||
// statusData is passed to the status template.
|
||||
type statusData struct {
|
||||
Page *status.Page
|
||||
LastChecked string
|
||||
History map[string]serviceHistory // keyed by service name
|
||||
}
|
||||
|
||||
func (h *Handler) Status(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -171,7 +180,28 @@ func (h *Handler) Status(w http.ResponseWriter, r *http.Request) {
|
||||
if !p.LastChecked.IsZero() {
|
||||
lastChecked = p.LastChecked.UTC().Format("2006-01-02 15:04 UTC")
|
||||
}
|
||||
h.render(w, "status", statusData{Page: p, LastChecked: lastChecked})
|
||||
uptimePath := filepath.Join(h.dataDir, "uptime.json")
|
||||
history := make(map[string]serviceHistory, len(p.Services))
|
||||
for _, svc := range p.Services {
|
||||
history[svc.Name] = serviceHistory{
|
||||
Blocks: uptime.ServiceHistory(uptimePath, svc.Name),
|
||||
UptimePct: uptime.UptimePct(uptimePath, svc.Name),
|
||||
}
|
||||
}
|
||||
h.render(w, "status", statusData{Page: p, LastChecked: lastChecked, History: history})
|
||||
}
|
||||
|
||||
// changelogData is passed to the changelog template.
|
||||
type changelogData struct {
|
||||
Log *changelog.Log
|
||||
}
|
||||
|
||||
func (h *Handler) Changelog(w http.ResponseWriter, r *http.Request) {
|
||||
l, err := changelog.Load(filepath.Join(h.dataDir, "changelog.json"))
|
||||
if err != nil {
|
||||
l = &changelog.Log{}
|
||||
}
|
||||
h.render(w, "changelog", changelogData{Log: l})
|
||||
}
|
||||
|
||||
func (h *Handler) About(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user