Simply provide RSS feed when GET request is received

This commit is contained in:
Jason Streifling 2024-04-04 17:13:42 +02:00
parent 532bc6490a
commit e3ce1d7b55
3 changed files with 2 additions and 17 deletions

View File

@ -60,7 +60,7 @@ func main() {
mux.HandleFunc("GET /rejected-articles", view.ShowRejectedArticles(args, db, store)) mux.HandleFunc("GET /rejected-articles", view.ShowRejectedArticles(args, db, store))
mux.HandleFunc("GET /review-rejected-article/{id}", view.ReviewRejectedArticle(args, db, store)) mux.HandleFunc("GET /review-rejected-article/{id}", view.ReviewRejectedArticle(args, db, store))
mux.HandleFunc("GET /review-unpublished-article/{id}", view.ReviewUnpublishedArticle(args, db, store)) mux.HandleFunc("GET /review-unpublished-article/{id}", view.ReviewUnpublishedArticle(args, db, store))
mux.HandleFunc("GET /rss", view.ShowRSS(args)) mux.HandleFunc("GET /rss", func(w http.ResponseWriter, r *http.Request) { http.ServeFile(w, r, args.RSSFile) })
mux.HandleFunc("GET /this-issue", view.ShowCurrentArticles(args, db)) mux.HandleFunc("GET /this-issue", view.ShowCurrentArticles(args, db))
mux.HandleFunc("GET /unpublished-articles", view.ShowUnpublishedArticles(args, db)) mux.HandleFunc("GET /unpublished-articles", view.ShowUnpublishedArticles(args, db))
mux.HandleFunc("GET /write-article", view.WriteArticle(args, db)) mux.HandleFunc("GET /write-article", view.WriteArticle(args, db))

View File

@ -1,15 +0,0 @@
package view
import (
"net/http"
"path/filepath"
"streifling.com/jason/cpolis/cmd/control"
)
func ShowRSS(c *control.CliArgs) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("Content-Disposition", "attachment; filename=\""+filepath.Base(c.RSSFile)+"\"")
http.ServeFile(w, r, c.RSSFile)
}
}

View File

@ -7,7 +7,7 @@
<div class="grid grid-cols-2 gap-x-4 gap-y-2"> <div class="grid grid-cols-2 gap-x-4 gap-y-2">
<button class="btn" hx-get="/write-article" hx-target="#page-content">Artikel schreiben</button> <button class="btn" hx-get="/write-article" hx-target="#page-content">Artikel schreiben</button>
<button class="btn" hx-get="/rejected-articles" hx-target="#page-content">Abgelehnte Artikel</button> <button class="btn" hx-get="/rejected-articles" hx-target="#page-content">Abgelehnte Artikel</button>
<a class="btn text-center" href="/rss" download="download">RSS Feed</a> <a class="btn text-center" href="/rss">RSS Feed</a>
<button class="btn" hx-get="/edit-user" hx-target="#page-content">Benutzer bearbeiten</button> <button class="btn" hx-get="/edit-user" hx-target="#page-content">Benutzer bearbeiten</button>
</div> </div>
</div> </div>