Make banner link and summary optional
This commit is contained in:
parent
0dd2101a08
commit
1fbc0ddcf6
@ -30,12 +30,25 @@ func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
|
|||||||
}
|
}
|
||||||
entry := atom.NewEntry(articleTitle)
|
entry := atom.NewEntry(articleTitle)
|
||||||
entry.ID = atom.NewID(fmt.Sprint("urn:entry:", article.ID))
|
entry.ID = atom.NewID(fmt.Sprint("urn:entry:", article.ID))
|
||||||
entry.Content = atom.NewContent(atom.OutOfLine, "text/hmtl", article.ContentLink)
|
|
||||||
entry.Published = atom.NewDate(article.Created)
|
entry.Published = atom.NewDate(article.Created)
|
||||||
|
|
||||||
|
if article.AutoGenerated {
|
||||||
|
entry.Content = atom.NewContent(atom.InlineText, "text", "")
|
||||||
|
} else {
|
||||||
|
entry.Content = atom.NewContent(atom.OutOfLine, "text/hmtl", article.ContentLink)
|
||||||
|
|
||||||
|
articleSummary, err := ConvertToPlain(article.Summary)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error converting description to plain text for Atom feed: %v", err)
|
||||||
|
}
|
||||||
|
entry.Summary = atom.NewText("text", articleSummary)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(article.BannerLink) > 0 {
|
||||||
linkID := entry.AddLink(atom.NewLink(article.BannerLink))
|
linkID := entry.AddLink(atom.NewLink(article.BannerLink))
|
||||||
entry.Links[linkID].Rel = "enclosure"
|
entry.Links[linkID].Rel = "enclosure"
|
||||||
entry.Links[linkID].Type = "image/webp"
|
entry.Links[linkID].Type = "image/webp"
|
||||||
|
}
|
||||||
|
|
||||||
user, err := db.GetUser(c, article.AuthorID)
|
user, err := db.GetUser(c, article.AuthorID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -43,15 +56,6 @@ func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
|
|||||||
}
|
}
|
||||||
entry.AddAuthor(atom.NewPerson(user.FirstName + " " + user.LastName))
|
entry.AddAuthor(atom.NewPerson(user.FirstName + " " + user.LastName))
|
||||||
|
|
||||||
articleSummary, err := ConvertToPlain(article.Summary)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("error converting description to plain text for Atom feed: %v", err)
|
|
||||||
}
|
|
||||||
if article.AutoGenerated {
|
|
||||||
articleSummary = "auto generated"
|
|
||||||
}
|
|
||||||
entry.Summary = atom.NewText("text", articleSummary)
|
|
||||||
|
|
||||||
tags, err := db.GetArticleTags(article.ID)
|
tags, err := db.GetArticleTags(article.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error getting tags for articles for Atom feed: %v", err)
|
return nil, fmt.Errorf("error getting tags for articles for Atom feed: %v", err)
|
||||||
|
@ -80,7 +80,7 @@ func SubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
|
|
||||||
article := &b.Article{
|
article := &b.Article{
|
||||||
Title: r.PostFormValue("article-title"),
|
Title: r.PostFormValue("article-title"),
|
||||||
BannerLink: r.PostFormValue("article-banner-url"),
|
BannerLink: c.Domain + "/image/serve/" + r.PostFormValue("article-banner-url"),
|
||||||
Summary: r.PostFormValue("article-summary"),
|
Summary: r.PostFormValue("article-summary"),
|
||||||
Published: false,
|
Published: false,
|
||||||
Rejected: false,
|
Rejected: false,
|
||||||
@ -94,17 +94,6 @@ func SubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(article.BannerLink) == 0 {
|
|
||||||
http.Error(w, "Bitte ein Titelbild einfügen.", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
article.BannerLink = c.Domain + "/image/serve/" + article.BannerLink
|
|
||||||
|
|
||||||
if len(article.Summary) == 0 {
|
|
||||||
http.Error(w, "Bitte die Beschreibung eingeben.", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
article.ID, err = db.AddArticle(article)
|
article.ID, err = db.AddArticle(article)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
@ -185,17 +174,11 @@ func ResubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bannerLink := r.PostFormValue("article-banner-url")
|
bannerLink := r.PostFormValue("article-banner-url")
|
||||||
if len(bannerLink) == 0 {
|
if len(bannerLink) != 0 {
|
||||||
http.Error(w, "Bitte ein Titelbild einfügen.", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
bannerLink = c.Domain + "/image/serve/" + bannerLink
|
bannerLink = c.Domain + "/image/serve/" + bannerLink
|
||||||
|
}
|
||||||
|
|
||||||
summary := r.PostFormValue("article-summary")
|
summary := r.PostFormValue("article-summary")
|
||||||
if len(summary) == 0 {
|
|
||||||
http.Error(w, "Bitte die Beschreibung eingeben.", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
content := r.PostFormValue("article-content")
|
content := r.PostFormValue("article-content")
|
||||||
if len(content) == 0 {
|
if len(content) == 0 {
|
||||||
|
@ -41,10 +41,6 @@ func PublishLatestIssue(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFun
|
|||||||
http.Error(w, "Bitte den Titel eingeben.", http.StatusBadRequest)
|
http.Error(w, "Bitte den Titel eingeben.", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(article.BannerLink) == 0 {
|
|
||||||
http.Error(w, "Bitte ein Titelbild einfügen.", http.StatusBadRequest)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
article.ID, err = db.AddArticle(article)
|
article.ID, err = db.AddArticle(article)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user