From cddd88d2f633bad418a9f989f8870e489e987d04 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Fri, 30 Aug 2024 15:42:53 +0200 Subject: [PATCH] restructure routes --- cmd/main.go | 60 ++++++++++++------------- web/templates/add-user.html | 2 +- web/templates/current-articles.html | 2 +- web/templates/edit-self.html | 2 +- web/templates/edit-user.html | 2 +- web/templates/editor.html | 4 +- web/templates/first-user.html | 2 +- web/templates/hub.html | 20 ++++----- web/templates/published-articles.html | 2 +- web/templates/rework-article.html | 4 +- web/templates/to-be-deleted.html | 2 +- web/templates/to-be-published.html | 4 +- web/templates/unpublished-articles.html | 2 +- 13 files changed, 54 insertions(+), 54 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 718ebec..8a131f4 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -49,42 +49,42 @@ func main() { http.FileServer(http.Dir(config.WebDir+"/static/")))) mux.HandleFunc("/", f.HomePage(config, db, store)) + mux.HandleFunc("GET /article/all-published", f.ShowPublishedArticles(config, db, store)) + mux.HandleFunc("GET /article/all-rejected", f.ShowRejectedArticles(config, db, store)) + mux.HandleFunc("GET /article/all-unpublished", f.ShowUnpublishedArticles(config, db, store)) + mux.HandleFunc("GET /article/delete/{id}", f.DeleteArticle(config, db, store)) + mux.HandleFunc("GET /article/publish/{id}", f.PublishArticle(config, db, store)) + mux.HandleFunc("GET /article/reject/{id}", f.RejectArticle(config, db, store)) + mux.HandleFunc("GET /article/review-deletion/{id}", f.ReviewArticleForDeletion(config, db, store)) + mux.HandleFunc("GET /article/review-rejected/{id}", f.ReviewRejectedArticle(config, db, store)) + mux.HandleFunc("GET /article/review-unpublished/{id}", f.ReviewUnpublishedArticle(config, db, store)) mux.HandleFunc("GET /article/serve/{id}", c.ServeArticle(config, db)) - mux.HandleFunc("GET /create-tag", f.CreateTag(config, store)) - mux.HandleFunc("GET /create-user", f.CreateUser(config, store)) - mux.HandleFunc("GET /delete-article/{id}", f.DeleteArticle(config, db, store)) - mux.HandleFunc("GET /delete-user/{id}", f.DeleteUser(config, db, store)) - mux.HandleFunc("GET /edit-self", f.EditSelf(config, db, store)) - mux.HandleFunc("GET /edit-user/{id}", f.EditUser(config, db, store)) + mux.HandleFunc("GET /article/write", f.WriteArticle(config, db, store)) mux.HandleFunc("GET /hub", f.ShowHub(config, db, store)) + mux.HandleFunc("GET /issue/publish", f.PublishLatestIssue(config, db, store)) + mux.HandleFunc("GET /issue/this", f.ShowCurrentArticles(config, db, store)) mux.HandleFunc("GET /logout", f.Logout(config, store)) mux.HandleFunc("GET /pdf/get-list", c.ServePDFList(config)) - mux.HandleFunc("GET /pdf/{id}", c.ServePDF(config)) - mux.HandleFunc("GET /pics/{pic}", f.ServeImage(config, store)) - mux.HandleFunc("GET /publish-article/{id}", f.PublishArticle(config, db, store)) - mux.HandleFunc("GET /publish-issue", f.PublishLatestIssue(config, db, store)) - mux.HandleFunc("GET /published-articles", f.ShowPublishedArticles(config, db, store)) - mux.HandleFunc("GET /reject-article/{id}", f.RejectArticle(config, db, store)) - mux.HandleFunc("GET /rejected-articles", f.ShowRejectedArticles(config, db, store)) - mux.HandleFunc("GET /review-article-for-deletion/{id}", f.ReviewArticleForDeletion(config, db, store)) - mux.HandleFunc("GET /review-rejected-article/{id}", f.ReviewRejectedArticle(config, db, store)) - mux.HandleFunc("GET /review-unpublished-article/{id}", f.ReviewUnpublishedArticle(config, db, store)) - mux.HandleFunc("GET /rss", c.ServeRSS(config)) - mux.HandleFunc("GET /show-all-users-edit", f.ShowAllUsers(config, db, store, "edit-user")) - mux.HandleFunc("GET /show-all-users-delete", f.ShowAllUsers(config, db, store, "delete-user")) - mux.HandleFunc("GET /this-issue", f.ShowCurrentArticles(config, db, store)) - mux.HandleFunc("GET /unpublished-articles", f.ShowUnpublishedArticles(config, db, store)) - mux.HandleFunc("GET /write-article", f.WriteArticle(config, db, store)) + mux.HandleFunc("GET /pdf/serve/{id}", c.ServePDF(config)) + mux.HandleFunc("GET /pic/serve/{pic}", f.ServeImage(config, store)) + mux.HandleFunc("GET /rss/serve", c.ServeRSS(config)) + mux.HandleFunc("GET /tag/create", f.CreateTag(config, store)) + mux.HandleFunc("GET /user/create", f.CreateUser(config, store)) + mux.HandleFunc("GET /user/delete/{id}", f.DeleteUser(config, db, store)) + mux.HandleFunc("GET /user/edit/{id}", f.EditUser(config, db, store)) + mux.HandleFunc("GET /user/edit/self", f.EditSelf(config, db, store)) + mux.HandleFunc("GET /user/show-all/delete", f.ShowAllUsers(config, db, store, "delete-user")) + mux.HandleFunc("GET /user/show-all/edit", f.ShowAllUsers(config, db, store, "edit-user")) - mux.HandleFunc("POST /add-first-user", f.AddFirstUser(config, db, store)) - mux.HandleFunc("POST /add-tag", f.AddTag(config, db, store)) - mux.HandleFunc("POST /add-user", f.AddUser(config, db, store)) + mux.HandleFunc("POST /article/resubmit/{id}", f.ResubmitArticle(config, db, store)) + mux.HandleFunc("POST /article/submit", f.SubmitArticle(config, db, store)) mux.HandleFunc("POST /login", f.Login(config, db, store)) - mux.HandleFunc("POST /resubmit-article/{id}", f.ResubmitArticle(config, db, store)) - mux.HandleFunc("POST /submit-article", f.SubmitArticle(config, db, store)) - mux.HandleFunc("POST /update-self", f.UpdateSelf(config, db, store)) - mux.HandleFunc("POST /update-user/{id}", f.UpdateUser(config, db, store)) - mux.HandleFunc("POST /upload-image", f.UploadImage(config, store)) + mux.HandleFunc("POST /pic/upload", f.UploadImage(config, store)) + mux.HandleFunc("POST /tag/add", f.AddTag(config, db, store)) + mux.HandleFunc("POST /user/add", f.AddUser(config, db, store)) + mux.HandleFunc("POST /user/add-first", f.AddFirstUser(config, db, store)) + mux.HandleFunc("POST /user/update/{id}", f.UpdateUser(config, db, store)) + mux.HandleFunc("POST /user/update/self", f.UpdateSelf(config, db, store)) log.Fatalln(http.ListenAndServe(config.Port, mux)) } diff --git a/web/templates/add-user.html b/web/templates/add-user.html index 10376e1..a3c9cf7 100644 --- a/web/templates/add-user.html +++ b/web/templates/add-user.html @@ -45,7 +45,7 @@
- +
diff --git a/web/templates/current-articles.html b/web/templates/current-articles.html index c0a25e4..991622e 100644 --- a/web/templates/current-articles.html +++ b/web/templates/current-articles.html @@ -11,7 +11,7 @@
- +
{{end}} diff --git a/web/templates/edit-self.html b/web/templates/edit-self.html index f9beb0f..ee4bdf0 100644 --- a/web/templates/edit-self.html +++ b/web/templates/edit-self.html @@ -35,7 +35,7 @@
-
diff --git a/web/templates/edit-user.html b/web/templates/edit-user.html index 819f6df..d998f7b 100644 --- a/web/templates/edit-user.html +++ b/web/templates/edit-user.html @@ -49,7 +49,7 @@
-
diff --git a/web/templates/editor.html b/web/templates/editor.html index 2dccc55..043fec8 100644 --- a/web/templates/editor.html +++ b/web/templates/editor.html @@ -29,7 +29,7 @@
- +
@@ -46,7 +46,7 @@ var formData = new FormData(); formData.append('article-image', file); - fetch('/upload-image', { + fetch('/pic/upload', { method: 'POST', body: formData }) diff --git a/web/templates/first-user.html b/web/templates/first-user.html index dace772..9f045a6 100644 --- a/web/templates/first-user.html +++ b/web/templates/first-user.html @@ -26,7 +26,7 @@
- +
diff --git a/web/templates/hub.html b/web/templates/hub.html index 5b29fa7..c63eca6 100644 --- a/web/templates/hub.html +++ b/web/templates/hub.html @@ -6,10 +6,10 @@

Autor

- - + + RSS Feed - +
{{end}} @@ -18,10 +18,10 @@

Redakteur

- - +
{{end}} @@ -30,8 +30,8 @@

Herausgeber

- - + +
{{end}} @@ -40,9 +40,9 @@

Administrator

- - - + + +
{{end}} diff --git a/web/templates/published-articles.html b/web/templates/published-articles.html index b2d04cf..4a12863 100644 --- a/web/templates/published-articles.html +++ b/web/templates/published-articles.html @@ -3,7 +3,7 @@
{{range .}} - diff --git a/web/templates/rework-article.html b/web/templates/rework-article.html index a833587..70d0252 100644 --- a/web/templates/rework-article.html +++ b/web/templates/rework-article.html @@ -30,7 +30,7 @@
-
@@ -48,7 +48,7 @@ var formData = new FormData(); formData.append('article-image', file); - fetch('/upload-image', { + fetch('/pic/upload', { method: 'POST', body: formData }) diff --git a/web/templates/to-be-deleted.html b/web/templates/to-be-deleted.html index 47f753d..32967a2 100644 --- a/web/templates/to-be-deleted.html +++ b/web/templates/to-be-deleted.html @@ -28,7 +28,7 @@
-
diff --git a/web/templates/to-be-published.html b/web/templates/to-be-published.html index 7820093..e1607a7 100644 --- a/web/templates/to-be-published.html +++ b/web/templates/to-be-published.html @@ -28,9 +28,9 @@
- - +
diff --git a/web/templates/unpublished-articles.html b/web/templates/unpublished-articles.html index c189e87..9013e3d 100644 --- a/web/templates/unpublished-articles.html +++ b/web/templates/unpublished-articles.html @@ -3,7 +3,7 @@
{{range .}} -