Added Tags to RSS feed as categories
This commit is contained in:
parent
a9c61c5a11
commit
4aa4fff5e8
@ -21,15 +21,17 @@ type Article struct {
|
|||||||
AuthorID int64
|
AuthorID int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: setCh
|
||||||
type ArticleList struct {
|
type ArticleList struct {
|
||||||
addCh chan *Article
|
addCh chan *Article
|
||||||
delCh chan uuid.UUID
|
delCh chan uuid.UUID
|
||||||
retCh chan *Article
|
|
||||||
getCh chan []Article
|
getCh chan []Article
|
||||||
|
retCh chan *Article
|
||||||
articles []*Article
|
articles []*Article
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: setCh
|
||||||
type TagList struct {
|
type TagList struct {
|
||||||
addCh chan string
|
addCh chan string
|
||||||
getCh chan []string
|
getCh chan []string
|
||||||
@ -41,8 +43,8 @@ func initArticleList() *ArticleList {
|
|||||||
return &ArticleList{
|
return &ArticleList{
|
||||||
addCh: make(chan *Article),
|
addCh: make(chan *Article),
|
||||||
delCh: make(chan uuid.UUID),
|
delCh: make(chan uuid.UUID),
|
||||||
retCh: make(chan *Article),
|
|
||||||
getCh: make(chan []Article),
|
getCh: make(chan []Article),
|
||||||
|
retCh: make(chan *Article),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +92,7 @@ func (tl *TagList) start() {
|
|||||||
|
|
||||||
func NewArticleList() *ArticleList {
|
func NewArticleList() *ArticleList {
|
||||||
list := initArticleList()
|
list := initArticleList()
|
||||||
list.articles = []*Article{}
|
list.articles = make([]*Article, 0)
|
||||||
|
|
||||||
list.wg.Add(1)
|
list.wg.Add(1)
|
||||||
go list.start()
|
go list.start()
|
||||||
@ -148,7 +150,7 @@ func LoadArticleList(filename string) (*ArticleList, error) {
|
|||||||
|
|
||||||
func NewTagList() *TagList {
|
func NewTagList() *TagList {
|
||||||
list := initTagList()
|
list := initTagList()
|
||||||
list.tags = []string{}
|
list.tags = make([]string, 0)
|
||||||
|
|
||||||
list.wg.Add(1)
|
list.wg.Add(1)
|
||||||
go list.start()
|
go list.start()
|
||||||
|
@ -22,6 +22,9 @@ func initChannel() *Channel {
|
|||||||
addCh: make(chan *rss.Item),
|
addCh: make(chan *rss.Item),
|
||||||
setCh: make(chan rss.Channel),
|
setCh: make(chan rss.Channel),
|
||||||
getCh: 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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.ParseForm()
|
||||||
|
article.Tags = append(article.Tags, r.Form["tags"]...)
|
||||||
|
|
||||||
session, err := s.Get(r, "cookie")
|
session, err := s.Get(r, "cookie")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tmpl, err := template.ParseFiles("web/templates/login.html")
|
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)
|
article.AuthorID = session.Values["id"].(int64)
|
||||||
|
|
||||||
al.Add(article)
|
al.Add(article)
|
||||||
al.Save("tmp/articles.gob")
|
al.Save("tmp/unpublished-articles.gob")
|
||||||
|
|
||||||
tmpl, err := template.ParseFiles("web/templates/hub.html")
|
tmpl, err := template.ParseFiles("web/templates/hub.html")
|
||||||
tmpl = template.Must(tmpl, err)
|
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),
|
PubDate: article.Created.Format(time.RFC1123Z),
|
||||||
Description: article.Desc,
|
Description: article.Desc,
|
||||||
Content: &rss.Content{Value: article.Content},
|
Content: &rss.Content{Value: article.Content},
|
||||||
|
Categories: article.Tags,
|
||||||
})
|
})
|
||||||
c.Save("tmp/rss.gob")
|
c.Save("tmp/rss.gob")
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module streifling.com/jason/cpolis
|
|||||||
go 1.22.0
|
go 1.22.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.streifling.com/jason/rss v0.0.0-20240305160829-6cd08bb65d2a
|
git.streifling.com/jason/rss v0.0.0-20240305164907-524bf9676188
|
||||||
github.com/go-sql-driver/mysql v1.7.1
|
github.com/go-sql-driver/mysql v1.7.1
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/gorilla/feeds v1.1.2
|
github.com/gorilla/feeds v1.1.2
|
||||||
|
2
go.sum
2
go.sum
@ -4,6 +4,8 @@ git.streifling.com/jason/rss v0.0.0-20240305160544-c8551159fe32 h1:G25NZzsD73rOk
|
|||||||
git.streifling.com/jason/rss v0.0.0-20240305160544-c8551159fe32/go.mod h1:gpZF0nZbQSstMpyHD9DTAvlQEG7v4pjO5c7aIMWM4Jg=
|
git.streifling.com/jason/rss v0.0.0-20240305160544-c8551159fe32/go.mod h1:gpZF0nZbQSstMpyHD9DTAvlQEG7v4pjO5c7aIMWM4Jg=
|
||||||
git.streifling.com/jason/rss v0.0.0-20240305160829-6cd08bb65d2a h1:TWQ9gwe7eWjaLUrZ0CJSc+sUUOw3VoGHlR3F8mH6vqs=
|
git.streifling.com/jason/rss v0.0.0-20240305160829-6cd08bb65d2a h1:TWQ9gwe7eWjaLUrZ0CJSc+sUUOw3VoGHlR3F8mH6vqs=
|
||||||
git.streifling.com/jason/rss v0.0.0-20240305160829-6cd08bb65d2a/go.mod h1:gpZF0nZbQSstMpyHD9DTAvlQEG7v4pjO5c7aIMWM4Jg=
|
git.streifling.com/jason/rss v0.0.0-20240305160829-6cd08bb65d2a/go.mod h1:gpZF0nZbQSstMpyHD9DTAvlQEG7v4pjO5c7aIMWM4Jg=
|
||||||
|
git.streifling.com/jason/rss v0.0.0-20240305164907-524bf9676188 h1:C8M/j3f+cl5Y7YfGpU/ynb/SC/4tTYMDsyGFt3rswM8=
|
||||||
|
git.streifling.com/jason/rss v0.0.0-20240305164907-524bf9676188/go.mod h1:gpZF0nZbQSstMpyHD9DTAvlQEG7v4pjO5c7aIMWM4Jg=
|
||||||
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
|
||||||
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
|
||||||
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
|
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI=
|
||||||
|
2
main.go
2
main.go
@ -47,7 +47,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
store := data.NewCookieStore(key)
|
store := data.NewCookieStore(key)
|
||||||
|
|
||||||
articleList, err := data.LoadArticleList("tmp/articles.gob")
|
articleList, err := data.LoadArticleList("tmp/unpublished-articles.gob")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
articleList = data.NewArticleList()
|
articleList = data.NewArticleList()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user