From 7e7de28b143805b6b32d70dd62d1acefdc2cf257 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Mon, 1 Apr 2024 15:42:51 +0200 Subject: [PATCH] Streamlined selection of rejected and unpublished articles --- cmd/main.go | 24 ++++++++++++------- cmd/view/articles.go | 4 ++-- web/templates/rejected-articles.html | 31 +++++++++---------------- web/templates/unpublished-articles.html | 29 +++++++---------------- 4 files changed, 38 insertions(+), 50 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 79edb58..e152ecf 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -54,8 +54,14 @@ func main() { mux.HandleFunc("GET /edit-user/", view.EditUser(args, db, store)) mux.HandleFunc("GET /hub/", view.ShowHub(args, db, store)) mux.HandleFunc("GET /logout/", view.Logout(args, store)) - mux.HandleFunc("GET /publish-issue/", view.PublishLatestIssue(args, db, store)) - mux.HandleFunc("GET /rejected-articles/", view.ShowRejectedArticles(args, db, store)) + mux.HandleFunc("GET /publish-issue/", + view.PublishLatestIssue(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-unpublished-article/{id}/", + view.ReviewUnpublishedArticle(args, db, store)) mux.HandleFunc("GET /rss/", view.ShowRSS(args, db, "Freimaurer Distrikt Niedersachsen und Sachsen-Anhalt", @@ -63,17 +69,19 @@ func main() { "Freiheit, Gleichheit, Brüderlichkeit, Toleranz und Humanität", )) 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("POST /add-tag/", view.AddTag(args, db, store)) mux.HandleFunc("POST /add-user/", view.AddUser(args, db, store)) mux.HandleFunc("POST /login/", view.Login(args, db, store)) - mux.HandleFunc("POST /publish-article/{id}/", view.PublishArticle(args, db, store)) - mux.HandleFunc("POST /reject-article/{id}/", view.RejectArticle(args, db, store)) - mux.HandleFunc("POST /resubmit-article/{id}/", view.ResubmitArticle(args, db, store)) - mux.HandleFunc("POST /review-rejected-article/", view.ReviewRejectedArticle(args, db, store)) - mux.HandleFunc("POST /review-unpublished-article/", view.ReviewUnpublishedArticle(args, db, store)) + mux.HandleFunc("POST /publish-article/{id}/", + view.PublishArticle(args, db, store)) + mux.HandleFunc("POST /reject-article/{id}/", + view.RejectArticle(args, db, store)) + mux.HandleFunc("POST /resubmit-article/{id}/", + view.ResubmitArticle(args, db, store)) mux.HandleFunc("POST /submit-article/", view.SubmitArticle(args, db, store)) mux.HandleFunc("POST /update-user/", view.UpdateUser(args, db, store)) mux.HandleFunc("POST /upload-image/", view.UploadImage(args)) diff --git a/cmd/view/articles.go b/cmd/view/articles.go index 7633102..532e8ef 100644 --- a/cmd/view/articles.go +++ b/cmd/view/articles.go @@ -202,7 +202,7 @@ func ReviewUnpublishedArticle(c *control.CliArgs, db *model.DB, s *control.Cooki } data := new(htmlData) - id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64) + id, err := strconv.ParseInt(r.PathValue("id"), 10, 64) if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) @@ -238,7 +238,7 @@ func ReviewRejectedArticle(c *control.CliArgs, db *model.DB, s *control.CookieSt } data := new(htmlData) - id, err := strconv.ParseInt(r.PostFormValue("id"), 10, 64) + id, err := strconv.ParseInt(r.PathValue("id"), 10, 64) if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/web/templates/rejected-articles.html b/web/templates/rejected-articles.html index e2ddf10..ba4dc71 100644 --- a/web/templates/rejected-articles.html +++ b/web/templates/rejected-articles.html @@ -1,23 +1,14 @@ {{define "page-content"}} -
-
- {{range .RejectedArticles}} -
- {{if index $.MyIDs .ID}} - - - {{end}} -
- {{end}} -
+
+ {{range .RejectedArticles}} + {{if index $.MyIDs .ID}} + + {{end}} + {{end}} -
- - -
- + +
{{end}} diff --git a/web/templates/unpublished-articles.html b/web/templates/unpublished-articles.html index 9622dd9..e8a417a 100644 --- a/web/templates/unpublished-articles.html +++ b/web/templates/unpublished-articles.html @@ -1,22 +1,11 @@ {{define "page-content"}} -
-
- {{range .}} -
- - -
- {{end}} -
- -
- - -
-
- +
+ {{range .}} + + {{end}} + +
{{end}}