Added Tags to RSS feed as categories
This commit is contained in:
@ -21,15 +21,17 @@ type Article struct {
|
||||
AuthorID int64
|
||||
}
|
||||
|
||||
// TODO: setCh
|
||||
type ArticleList struct {
|
||||
addCh chan *Article
|
||||
delCh chan uuid.UUID
|
||||
retCh chan *Article
|
||||
getCh chan []Article
|
||||
retCh chan *Article
|
||||
articles []*Article
|
||||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
// TODO: setCh
|
||||
type TagList struct {
|
||||
addCh chan string
|
||||
getCh chan []string
|
||||
@ -41,8 +43,8 @@ func initArticleList() *ArticleList {
|
||||
return &ArticleList{
|
||||
addCh: make(chan *Article),
|
||||
delCh: make(chan uuid.UUID),
|
||||
retCh: make(chan *Article),
|
||||
getCh: make(chan []Article),
|
||||
retCh: make(chan *Article),
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,7 +92,7 @@ func (tl *TagList) start() {
|
||||
|
||||
func NewArticleList() *ArticleList {
|
||||
list := initArticleList()
|
||||
list.articles = []*Article{}
|
||||
list.articles = make([]*Article, 0)
|
||||
|
||||
list.wg.Add(1)
|
||||
go list.start()
|
||||
@ -148,7 +150,7 @@ func LoadArticleList(filename string) (*ArticleList, error) {
|
||||
|
||||
func NewTagList() *TagList {
|
||||
list := initTagList()
|
||||
list.tags = []string{}
|
||||
list.tags = make([]string, 0)
|
||||
|
||||
list.wg.Add(1)
|
||||
go list.start()
|
||||
|
@ -22,6 +22,9 @@ func initChannel() *Channel {
|
||||
addCh: make(chan *rss.Item),
|
||||
setCh: make(chan rss.Channel),
|
||||
getCh: make(chan rss.Channel),
|
||||
channel: rss.Channel{
|
||||
Items: make([]*rss.Item, 0),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,9 @@ func FinishArticle(al *data.ArticleList, s *data.CookieStore) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
r.ParseForm()
|
||||
article.Tags = append(article.Tags, r.Form["tags"]...)
|
||||
|
||||
session, err := s.Get(r, "cookie")
|
||||
if err != nil {
|
||||
tmpl, err := template.ParseFiles("web/templates/login.html")
|
||||
@ -71,7 +74,7 @@ func FinishArticle(al *data.ArticleList, s *data.CookieStore) http.HandlerFunc {
|
||||
article.AuthorID = session.Values["id"].(int64)
|
||||
|
||||
al.Add(article)
|
||||
al.Save("tmp/articles.gob")
|
||||
al.Save("tmp/unpublished-articles.gob")
|
||||
|
||||
tmpl, err := template.ParseFiles("web/templates/hub.html")
|
||||
tmpl = template.Must(tmpl, err)
|
||||
@ -147,6 +150,7 @@ func PublishArticle(c *data.Channel, al *data.ArticleList, s *data.CookieStore)
|
||||
PubDate: article.Created.Format(time.RFC1123Z),
|
||||
Description: article.Desc,
|
||||
Content: &rss.Content{Value: article.Content},
|
||||
Categories: article.Tags,
|
||||
})
|
||||
c.Save("tmp/rss.gob")
|
||||
|
||||
|
Reference in New Issue
Block a user