diff options
| author | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-06 20:32:20 +0200 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <william@herges.fr> | 2025-10-06 20:32:20 +0200 |
| commit | bde341ccfa74ad702745e84ee91c2e7045cbe307 (patch) | |
| tree | 3d914112e7153c8fd7bc1d6a459d143f8ccab8f3 /backend/logs.go | |
| parent | 9cfcbabb032c729b06d581412a64a9e7cefed6b1 (diff) | |
feat(backend): rss feeds for logs
Diffstat (limited to 'backend/logs.go')
| -rw-r--r-- | backend/logs.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/backend/logs.go b/backend/logs.go index 86e0221..03d4f1f 100644 --- a/backend/logs.go +++ b/backend/logs.go @@ -36,6 +36,10 @@ func (d *logData) PubDate() string { return d.PubLocalDate.String() } +func (d *logData) PubDateRSS() string { + return d.PubLocalDate.AsTime(time.Local).Format(time.RFC1123Z) // because RFC822 in go isn't RFC822??? +} + func (d *logData) Title() string { return d.data.Title() } @@ -116,6 +120,10 @@ func HandleLogs(r *chi.Mux) { r.Get("/logs", handleLogList) r.Route("/logs", func(r chi.Router) { r.Get("/", handleLogList) + + r.Get("/rss", handleLogRSS) + r.Get("/rss/", handleLogRSS) + r.Get("/{slug:[a-zA-Z0-9-]+}", handleLog) r.Get("/{slug:[a-zA-Z0-9-]+}/", handleLog) }) @@ -130,6 +138,15 @@ func handleLogList(w http.ResponseWriter, r *http.Request) { d.handleGeneric(w, r, "home_log", d) } +func handleLogRSS(w http.ResponseWriter, r *http.Request) { + d := handleGenericLogsDisplay(w, r, 5) + if d == nil { + return + } + d.title = "logs" + d.handleRSS(w, r, d) +} + func handleLog(w http.ResponseWriter, r *http.Request) { cfg := r.Context().Value(configKey).(*Config) slug := chi.URLParam(r, "slug") |
