fix: Include type for OPML subscriptions
As per [OPML 2.0 specification]: > Each sub-element of the body of the OPML document is a node of type rss or an outline element that contains nodes of type rss. > Required attributes: type, text, xmlUrl. [OPML 2.0 specification]: http://opml.org/spec2.opml#subscriptionLists
This commit is contained in:
parent
538e5305d3
commit
074393d3bf
1 changed files with 17 additions and 0 deletions
|
@ -34,6 +34,23 @@ type opmlOutline struct {
|
|||
Outlines opmlOutlineCollection `xml:"outline,omitempty"`
|
||||
}
|
||||
|
||||
func (outline opmlOutline) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
||||
type opmlOutlineXml opmlOutline
|
||||
|
||||
outlineType := ""
|
||||
if outline.IsSubscription() {
|
||||
outlineType = "rss"
|
||||
}
|
||||
|
||||
return e.EncodeElement(struct {
|
||||
opmlOutlineXml
|
||||
Type string `xml:"type,attr,omitempty"`
|
||||
}{
|
||||
opmlOutlineXml: opmlOutlineXml(outline),
|
||||
Type: outlineType,
|
||||
}, start)
|
||||
}
|
||||
|
||||
func (o *opmlOutline) IsSubscription() bool {
|
||||
return strings.TrimSpace(o.FeedURL) != ""
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue