mirror of
https://github.com/miniflux/v2.git
synced 2025-07-12 16:58:36 +00:00
Improve OPML package to be more idiomatic
This commit is contained in:
parent
e91a9b4f13
commit
c26787f476
7 changed files with 50 additions and 40 deletions
|
@ -17,13 +17,13 @@ func Serialize(subscriptions SubcriptionList) string {
|
|||
writer := bufio.NewWriter(&b)
|
||||
writer.WriteString(xml.Header)
|
||||
|
||||
opml := new(Opml)
|
||||
opml.Version = "2.0"
|
||||
feeds := new(opml)
|
||||
feeds.Version = "2.0"
|
||||
for categoryName, subs := range groupSubscriptionsByFeed(subscriptions) {
|
||||
outline := Outline{Text: categoryName}
|
||||
category := outline{Text: categoryName}
|
||||
|
||||
for _, subscription := range subs {
|
||||
outline.Outlines = append(outline.Outlines, Outline{
|
||||
category.Outlines = append(category.Outlines, outline{
|
||||
Title: subscription.Title,
|
||||
Text: subscription.Title,
|
||||
FeedURL: subscription.FeedURL,
|
||||
|
@ -31,12 +31,12 @@ func Serialize(subscriptions SubcriptionList) string {
|
|||
})
|
||||
}
|
||||
|
||||
opml.Outlines = append(opml.Outlines, outline)
|
||||
feeds.Outlines = append(feeds.Outlines, category)
|
||||
}
|
||||
|
||||
encoder := xml.NewEncoder(writer)
|
||||
encoder.Indent(" ", " ")
|
||||
if err := encoder.Encode(opml); err != nil {
|
||||
if err := encoder.Encode(feeds); err != nil {
|
||||
log.Println(err)
|
||||
return ""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue