Changed visual layout for to-be-published articles

This commit is contained in:
2024-04-03 18:08:56 +02:00
parent 803c5bbdbd
commit d62c5a4078
6 changed files with 80 additions and 31 deletions

View File

@ -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)