From d62c5a4078a76e21d4766cd3043031e72e361678 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Wed, 3 Apr 2024 18:08:56 +0200 Subject: [PATCH] Changed visual layout for to-be-published articles --- cmd/main.go | 4 ++-- cmd/view/articles.go | 37 ++++++++++++++++++++++++++---- tailwind.config.js | 4 +++- web/templates/editor.html | 15 +++++++----- web/templates/rework-article.html | 17 ++++++++------ web/templates/to-be-published.html | 34 +++++++++++++++++++-------- 6 files changed, 80 insertions(+), 31 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 886e518..e9242c8 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -54,7 +54,9 @@ 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-article/{id}/", view.PublishArticle(args, db, store)) mux.HandleFunc("GET /publish-issue/", view.PublishLatestIssue(args, db, store)) + mux.HandleFunc("GET /reject-article/{id}/", view.RejectArticle(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)) @@ -73,8 +75,6 @@ func main() { 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 /submit-article/", view.SubmitArticle(args, db, store)) mux.HandleFunc("POST /update-user/", view.UpdateUser(args, db, store)) diff --git a/cmd/view/articles.go b/cmd/view/articles.go index 532e8ef..20b7b85 100644 --- a/cmd/view/articles.go +++ b/cmd/view/articles.go @@ -197,26 +197,53 @@ func ShowRejectedArticles(c *control.CliArgs, db *model.DB, s *control.CookieSto func ReviewUnpublishedArticle(c *control.CliArgs, db *model.DB, s *control.CookieStore) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { type htmlData struct { - Article *model.Article - Tags []*model.Tag + Title string + Description string + Content template.HTML + Tags []*model.Tag + ID int64 } + + var err error data := new(htmlData) - id, err := strconv.ParseInt(r.PathValue("id"), 10, 64) + data.ID, err = strconv.ParseInt(r.PathValue("id"), 10, 64) if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) return } - data.Article, err = db.GetArticle(id) + article, err := db.GetArticle(data.ID) if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) return } - data.Tags, err = db.GetArticleTags(id) + data.Title, err = control.ConvertToPlain(article.Title) + if err != nil { + log.Println(err) + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + data.Description, err = control.ConvertToPlain(article.Description) + if err != nil { + log.Println(err) + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + content, err := control.ConvertToHTML(article.Content) + if err != nil { + log.Println(err) + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + data.Content = template.HTML(content) + + data.Tags, err = db.GetArticleTags(data.ID) if err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) diff --git a/tailwind.config.js b/tailwind.config.js index 74cd5d4..9e17d63 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -4,5 +4,7 @@ module.exports = { theme: { extend: {} }, - plugins: [], + plugins: [ + require('@tailwindcss/typography') + ], } diff --git a/web/templates/editor.html b/web/templates/editor.html index 7a530d9..e0c7c0a 100644 --- a/web/templates/editor.html +++ b/web/templates/editor.html @@ -14,13 +14,16 @@ -
- {{range .}} -
- - +
+ Tags +
+ {{range .}} +
+ + +
+ {{end}}
- {{end}}
diff --git a/web/templates/rework-article.html b/web/templates/rework-article.html index 6bd4c72..bcdaf6f 100644 --- a/web/templates/rework-article.html +++ b/web/templates/rework-article.html @@ -14,14 +14,17 @@
-
- {{range .Tags}} -
- - +
+ Tags +
+ {{range .Tags}} +
+ + +
+ {{end}}
- {{end}}
diff --git a/web/templates/to-be-published.html b/web/templates/to-be-published.html index fa9226c..f28dffc 100644 --- a/web/templates/to-be-published.html +++ b/web/templates/to-be-published.html @@ -1,21 +1,35 @@ {{define "page-content"}} -
-

{{.Article.Title}}

-

{{.Article.Description}}

- {{.Article.Content}} +
+ Titel +
+ {{.Title}} +
-

+ Beschreibung +

+ {{.Description}} +
+ + Artikel +
+
+ {{.Content}} +
+
+ + Tags +
{{range .Tags}} {{.Name}} +
{{end}} -

+
- - +
- +
{{end}}