forked from jason/cpolis
Add profile pic and correct usage of banner link
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
b "streifling.com/jason/cpolis/cmd/backend"
|
||||
@@ -24,7 +23,7 @@ type EditorHTMLData struct {
|
||||
Action string
|
||||
ActionTitle string
|
||||
ActionButton string
|
||||
BannerImage string
|
||||
Image string
|
||||
HTMLContent template.HTML
|
||||
Article *b.Article
|
||||
Tags []*b.Tag
|
||||
@@ -80,7 +79,7 @@ func SubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||
|
||||
article := &b.Article{
|
||||
Title: r.PostFormValue("article-title"),
|
||||
BannerLink: c.Domain + "/image/serve/" + r.PostFormValue("article-banner-url"),
|
||||
BannerLink: r.PostFormValue("article-banner-url"),
|
||||
Summary: r.PostFormValue("article-summary"),
|
||||
Published: false,
|
||||
Rejected: false,
|
||||
@@ -170,11 +169,6 @@ func ResubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
bannerLink := r.PostFormValue("article-banner-url")
|
||||
if len(bannerLink) != 0 {
|
||||
bannerLink = c.Domain + "/image/serve/" + bannerLink
|
||||
}
|
||||
|
||||
summary := r.PostFormValue("article-summary")
|
||||
if len(summary) == 0 {
|
||||
http.Error(w, "Bitte die Beschreibung eingeben.", http.StatusBadRequest)
|
||||
@@ -196,7 +190,7 @@ func ResubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||
|
||||
if err = db.UpdateAttributes(
|
||||
&b.Attribute{Table: "articles", ID: id, AttName: "title", Value: title},
|
||||
&b.Attribute{Table: "articles", ID: id, AttName: "banner_link", Value: bannerLink},
|
||||
&b.Attribute{Table: "articles", ID: id, AttName: "banner_link", Value: r.PostFormValue("article-banner-url")},
|
||||
&b.Attribute{Table: "articles", ID: id, AttName: "summary", Value: summary},
|
||||
&b.Attribute{Table: "articles", ID: id, AttName: "rejected", Value: false},
|
||||
&b.Attribute{Table: "articles", ID: id, AttName: "is_in_issue", Value: r.PostFormValue("issue") == "on"},
|
||||
@@ -341,8 +335,7 @@ func ReviewRejectedArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.Handler
|
||||
return
|
||||
}
|
||||
|
||||
imgURL := strings.Split(data.Article.BannerLink, "/")
|
||||
data.BannerImage = imgURL[len(imgURL)-1]
|
||||
data.Image = data.Article.BannerLink
|
||||
|
||||
articleAbsName := fmt.Sprint(c.ArticleDir, "/", data.Article.ID, ".md")
|
||||
content, err := os.ReadFile(articleAbsName)
|
||||
@@ -612,8 +605,7 @@ func ReviewArticle(c *b.Config, db *b.DB, s *b.CookieStore, action, title, butto
|
||||
return
|
||||
}
|
||||
|
||||
imgURL := strings.Split(article.BannerLink, "/")
|
||||
data.BannerImage = imgURL[len(imgURL)-1]
|
||||
data.Image = article.BannerLink
|
||||
|
||||
data.Article.Summary, err = b.ConvertToPlain(article.Summary)
|
||||
if err != nil {
|
||||
@@ -789,8 +781,7 @@ func EditArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
imgURL := strings.Split(data.Article.BannerLink, "/")
|
||||
data.BannerImage = imgURL[len(imgURL)-1]
|
||||
data.Image = data.Article.BannerLink
|
||||
|
||||
content, err := os.ReadFile(fmt.Sprint(c.ArticleDir, "/", data.Article.ID, ".md"))
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user