Compare commits
50 Commits
e95871ee70
...
v0.13.3
Author | SHA1 | Date | |
---|---|---|---|
5dc5590da9 | |||
81c046c1b0 | |||
364112a0a4 | |||
1e9fdd2ab9 | |||
a38523e933 | |||
1fbc0ddcf6 | |||
0dd2101a08 | |||
200672dae2 | |||
3d3aad88c8 | |||
e4e43d1a83 | |||
737a9ec314 | |||
1ebe0380ee | |||
d62d71b5d1 | |||
b36e0ea503 | |||
bc4d8fa37e | |||
d2b21e7405 | |||
e3c192359f | |||
46532e4c85 | |||
c722135a56 | |||
887fa863bc | |||
74d71cfb6a | |||
ca7e7cddd3 | |||
94431a2aa9 | |||
5b1f20c5bc | |||
d0c566f8df | |||
5e586aa49a | |||
66b2743d3d | |||
3723b2b5e6 | |||
ce788bfd50 | |||
230a6278cc | |||
42d6e0c198 | |||
e1af2979af | |||
f6dedc6f10 | |||
cdf0a49550 | |||
c3c0650210 | |||
d077f700d8 | |||
ec752b1c66 | |||
46aef4f12f | |||
1b29e328cf | |||
e50cb819f3 | |||
c32e38ca10 | |||
d7c8c7a43a | |||
1cd3edc90c | |||
0e768c9f61 | |||
1fcd775cc5 | |||
203a1ed147 | |||
ef1914ee5c | |||
084b101e31 | |||
b2db128aa9 | |||
081e880fb6 |
@ -8,8 +8,6 @@ import (
|
|||||||
"git.streifling.com/jason/atom"
|
"git.streifling.com/jason/atom"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Feed struct{ *atom.Feed }
|
|
||||||
|
|
||||||
func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
|
func GenerateAtomFeed(c *Config, db *DB) (*string, error) {
|
||||||
feed := atom.NewFeed(c.Title)
|
feed := atom.NewFeed(c.Title)
|
||||||
feed.ID = atom.NewID("urn:feed:1")
|
feed.ID = atom.NewID("urn:feed:1")
|
||||||
@ -32,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)
|
||||||
|
|
||||||
linkID := entry.AddLink(atom.NewLink(article.BannerLink))
|
if article.AutoGenerated {
|
||||||
entry.Links[linkID].Rel = "enclosure"
|
entry.Content = atom.NewContent(atom.InlineText, "text", "")
|
||||||
entry.Links[linkID].Type = "image/webp"
|
} 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))
|
||||||
|
entry.Links[linkID].Rel = "enclosure"
|
||||||
|
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 {
|
||||||
@ -45,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)
|
||||||
|
@ -52,7 +52,7 @@ func newConfig() *Config {
|
|||||||
PDFDir: "/var/www/cpolis/pdfs",
|
PDFDir: "/var/www/cpolis/pdfs",
|
||||||
PicsDir: "/var/www/cpolis/pics",
|
PicsDir: "/var/www/cpolis/pics",
|
||||||
Port: ":8080",
|
Port: ":8080",
|
||||||
Version: "v0.13.2",
|
Version: "v0.13.3",
|
||||||
WebDir: "/var/www/cpolis/web",
|
WebDir: "/var/www/cpolis/web",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
@ -93,13 +93,6 @@ func SubmitArticle(c *b.Config, db *b.DB, s *b.CookieStore) http.HandlerFunc {
|
|||||||
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.BannerLink = c.Domain + "/image/serve/" + article.BannerLink
|
|
||||||
|
|
||||||
if len(article.Summary) == 0 {
|
if len(article.Summary) == 0 {
|
||||||
http.Error(w, "Bitte die Beschreibung eingeben.", http.StatusBadRequest)
|
http.Error(w, "Bitte die Beschreibung eingeben.", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
@ -185,11 +178,9 @@ 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)
|
bannerLink = c.Domain + "/image/serve/" + bannerLink
|
||||||
return
|
|
||||||
}
|
}
|
||||||
bannerLink = c.Domain + "/image/serve/" + bannerLink
|
|
||||||
|
|
||||||
summary := r.PostFormValue("article-summary")
|
summary := r.PostFormValue("article-summary")
|
||||||
if len(summary) == 0 {
|
if len(summary) == 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 {
|
||||||
|
Reference in New Issue
Block a user