mirror of
https://github.com/miniflux/v2.git
synced 2025-09-15 18:57:04 +00:00
refactor: unexport symbols
This commit is contained in:
parent
a4d51b5586
commit
566670cc06
36 changed files with 369 additions and 376 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
// Specs: http://web.archive.org/web/20060811235523/http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html
|
||||
type Atom03Feed struct {
|
||||
type atom03Feed struct {
|
||||
Version string `xml:"version,attr"`
|
||||
|
||||
// The "atom:id" element's content conveys a permanent, globally unique identifier for the feed.
|
||||
|
@ -21,14 +21,14 @@ type Atom03Feed struct {
|
|||
// The "atom:title" element is a Content construct that conveys a human-readable title for the feed.
|
||||
// atom:feed elements MUST contain exactly one atom:title element.
|
||||
// If the feed describes a Web resource, its content SHOULD be the same as that resource's title.
|
||||
Title Atom03Content `xml:"http://purl.org/atom/ns# title"`
|
||||
Title atom03Content `xml:"http://purl.org/atom/ns# title"`
|
||||
|
||||
// The "atom:link" element is a Link construct that conveys a URI associated with the feed.
|
||||
// The nature of the relationship as well as the link itself is determined by the element's content.
|
||||
// atom:feed elements MUST contain at least one atom:link element with a rel attribute value of "alternate".
|
||||
// atom:feed elements MUST NOT contain more than one atom:link element with a rel attribute value of "alternate" that has the same type attribute value.
|
||||
// atom:feed elements MAY contain additional atom:link elements beyond those described above.
|
||||
Links AtomLinks `xml:"http://purl.org/atom/ns# link"`
|
||||
Links atomLinks `xml:"http://purl.org/atom/ns# link"`
|
||||
|
||||
// The "atom:author" element is a Person construct that indicates the default author of the feed.
|
||||
// atom:feed elements MUST contain exactly one atom:author element,
|
||||
|
@ -38,10 +38,10 @@ type Atom03Feed struct {
|
|||
|
||||
// The "atom:entry" element's represents an individual entry that is contained by the feed.
|
||||
// atom:feed elements MAY contain one or more atom:entry elements.
|
||||
Entries []Atom03Entry `xml:"http://purl.org/atom/ns# entry"`
|
||||
Entries []atom03Entry `xml:"http://purl.org/atom/ns# entry"`
|
||||
}
|
||||
|
||||
type Atom03Entry struct {
|
||||
type atom03Entry struct {
|
||||
// The "atom:id" element's content conveys a permanent, globally unique identifier for the entry.
|
||||
// It MUST NOT change over time, even if other representations of the entry (such as a web representation pointed to by the entry's atom:link element) are relocated.
|
||||
// If the same entry is syndicated in two atom:feeds published by the same entity, the entry's atom:id MUST be the same in both feeds.
|
||||
|
@ -50,7 +50,7 @@ type Atom03Entry struct {
|
|||
// The "atom:title" element is a Content construct that conveys a human-readable title for the entry.
|
||||
// atom:entry elements MUST have exactly one "atom:title" element.
|
||||
// If an entry describes a Web resource, its content SHOULD be the same as that resource's title.
|
||||
Title Atom03Content `xml:"title"`
|
||||
Title atom03Content `xml:"title"`
|
||||
|
||||
// The "atom:modified" element is a Date construct that indicates the time that the entry was last modified.
|
||||
// atom:entry elements MUST contain an atom:modified element, but MUST NOT contain more than one.
|
||||
|
@ -73,15 +73,15 @@ type Atom03Entry struct {
|
|||
// atom:entry elements MUST contain at least one atom:link element with a rel attribute value of "alternate".
|
||||
// atom:entry elements MUST NOT contain more than one atom:link element with a rel attribute value of "alternate" that has the same type attribute value.
|
||||
// atom:entry elements MAY contain additional atom:link elements beyond those described above.
|
||||
Links AtomLinks `xml:"link"`
|
||||
Links atomLinks `xml:"link"`
|
||||
|
||||
// The "atom:summary" element is a Content construct that conveys a short summary, abstract or excerpt of the entry.
|
||||
// atom:entry elements MAY contain an atom:created element, but MUST NOT contain more than one.
|
||||
Summary Atom03Content `xml:"summary"`
|
||||
Summary atom03Content `xml:"summary"`
|
||||
|
||||
// The "atom:content" element is a Content construct that conveys the content of the entry.
|
||||
// atom:entry elements MAY contain one or more atom:content elements.
|
||||
Content Atom03Content `xml:"content"`
|
||||
Content atom03Content `xml:"content"`
|
||||
|
||||
// The "atom:author" element is a Person construct that indicates the default author of the entry.
|
||||
// atom:entry elements MUST contain exactly one atom:author element,
|
||||
|
@ -90,7 +90,7 @@ type Atom03Entry struct {
|
|||
Author AtomPerson `xml:"author"`
|
||||
}
|
||||
|
||||
type Atom03Content struct {
|
||||
type atom03Content struct {
|
||||
// Content constructs MAY have a "type" attribute, whose value indicates the media type of the content.
|
||||
// When present, this attribute's value MUST be a registered media type [RFC2045].
|
||||
// If not present, its value MUST be considered to be "text/plain".
|
||||
|
@ -113,7 +113,7 @@ type Atom03Content struct {
|
|||
InnerXML string `xml:",innerxml"`
|
||||
}
|
||||
|
||||
func (a *Atom03Content) Content() string {
|
||||
func (a *atom03Content) content() string {
|
||||
content := ""
|
||||
|
||||
switch a.Mode {
|
||||
|
|
|
@ -14,15 +14,16 @@ import (
|
|||
"miniflux.app/v2/internal/urllib"
|
||||
)
|
||||
|
||||
type Atom03Adapter struct {
|
||||
atomFeed *Atom03Feed
|
||||
type atom03Adapter struct {
|
||||
atomFeed *atom03Feed
|
||||
}
|
||||
|
||||
func NewAtom03Adapter(atomFeed *Atom03Feed) *Atom03Adapter {
|
||||
return &Atom03Adapter{atomFeed}
|
||||
// TODO No need for a constructor, as it's only used in this package
|
||||
func NewAtom03Adapter(atomFeed *atom03Feed) *atom03Adapter {
|
||||
return &atom03Adapter{atomFeed}
|
||||
}
|
||||
|
||||
func (a *Atom03Adapter) BuildFeed(baseURL string) *model.Feed {
|
||||
func (a *atom03Adapter) buildFeed(baseURL string) *model.Feed {
|
||||
feed := new(model.Feed)
|
||||
|
||||
// Populate the feed URL.
|
||||
|
@ -36,7 +37,7 @@ func (a *Atom03Adapter) BuildFeed(baseURL string) *model.Feed {
|
|||
}
|
||||
|
||||
// Populate the site URL.
|
||||
siteURL := a.atomFeed.Links.OriginalLink()
|
||||
siteURL := a.atomFeed.Links.originalLink()
|
||||
if siteURL != "" {
|
||||
if absoluteSiteURL, err := urllib.AbsoluteURL(baseURL, siteURL); err == nil {
|
||||
feed.SiteURL = absoluteSiteURL
|
||||
|
@ -46,7 +47,7 @@ func (a *Atom03Adapter) BuildFeed(baseURL string) *model.Feed {
|
|||
}
|
||||
|
||||
// Populate the feed title.
|
||||
feed.Title = a.atomFeed.Title.Content()
|
||||
feed.Title = a.atomFeed.Title.content()
|
||||
if feed.Title == "" {
|
||||
feed.Title = feed.SiteURL
|
||||
}
|
||||
|
@ -55,7 +56,7 @@ func (a *Atom03Adapter) BuildFeed(baseURL string) *model.Feed {
|
|||
entry := model.NewEntry()
|
||||
|
||||
// Populate the entry URL.
|
||||
entry.URL = atomEntry.Links.OriginalLink()
|
||||
entry.URL = atomEntry.Links.originalLink()
|
||||
if entry.URL != "" {
|
||||
if absoluteEntryURL, err := urllib.AbsoluteURL(feed.SiteURL, entry.URL); err == nil {
|
||||
entry.URL = absoluteEntryURL
|
||||
|
@ -63,13 +64,13 @@ func (a *Atom03Adapter) BuildFeed(baseURL string) *model.Feed {
|
|||
}
|
||||
|
||||
// Populate the entry content.
|
||||
entry.Content = atomEntry.Content.Content()
|
||||
entry.Content = atomEntry.Content.content()
|
||||
if entry.Content == "" {
|
||||
entry.Content = atomEntry.Summary.Content()
|
||||
entry.Content = atomEntry.Summary.content()
|
||||
}
|
||||
|
||||
// Populate the entry title.
|
||||
entry.Title = atomEntry.Title.Content()
|
||||
entry.Title = atomEntry.Title.content()
|
||||
if entry.Title == "" {
|
||||
entry.Title = sanitizer.TruncateHTML(entry.Content, 100)
|
||||
}
|
||||
|
@ -101,7 +102,7 @@ func (a *Atom03Adapter) BuildFeed(baseURL string) *model.Feed {
|
|||
}
|
||||
|
||||
// Generate the entry hash.
|
||||
for _, value := range []string{atomEntry.ID, atomEntry.Links.OriginalLink()} {
|
||||
for _, value := range []string{atomEntry.ID, atomEntry.Links.originalLink()} {
|
||||
if value != "" {
|
||||
entry.Hash = crypto.SHA256(value)
|
||||
break
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
// Specs:
|
||||
// https://tools.ietf.org/html/rfc4287
|
||||
// https://validator.w3.org/feed/docs/atom.html
|
||||
type Atom10Feed struct {
|
||||
type atom10Feed struct {
|
||||
XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"`
|
||||
|
||||
// The "atom:id" element conveys a permanent, universally unique
|
||||
|
@ -37,11 +37,11 @@ type Atom10Feed struct {
|
|||
// readable title for an entry or feed.
|
||||
//
|
||||
// atom:feed elements MUST contain exactly one atom:title element.
|
||||
Title Atom10Text `xml:"http://www.w3.org/2005/Atom title"`
|
||||
Title atom10Text `xml:"http://www.w3.org/2005/Atom title"`
|
||||
|
||||
// The "atom:subtitle" element is a Text construct that
|
||||
// contains a human-readable description or subtitle for the feed.
|
||||
Subtitle Atom10Text `xml:"http://www.w3.org/2005/Atom subtitle"`
|
||||
Subtitle atom10Text `xml:"http://www.w3.org/2005/Atom subtitle"`
|
||||
|
||||
// The "atom:author" element is a Person construct that indicates the
|
||||
// author of the entry or feed.
|
||||
|
@ -49,7 +49,7 @@ type Atom10Feed struct {
|
|||
// atom:feed elements MUST contain one or more atom:author elements,
|
||||
// unless all of the atom:feed element's child atom:entry elements
|
||||
// contain at least one atom:author element.
|
||||
Authors AtomPersons `xml:"http://www.w3.org/2005/Atom author"`
|
||||
Authors atomPersons `xml:"http://www.w3.org/2005/Atom author"`
|
||||
|
||||
// The "atom:icon" element's content is an IRI reference [RFC3987] that
|
||||
// identifies an image that provides iconic visual identification for a
|
||||
|
@ -71,7 +71,7 @@ type Atom10Feed struct {
|
|||
// atom:feed elements MUST NOT contain more than one atom:link
|
||||
// element with a rel attribute value of "alternate" that has the
|
||||
// same combination of type and hreflang attribute values.
|
||||
Links AtomLinks `xml:"http://www.w3.org/2005/Atom link"`
|
||||
Links atomLinks `xml:"http://www.w3.org/2005/Atom link"`
|
||||
|
||||
// The "atom:category" element conveys information about a category
|
||||
// associated with an entry or feed. This specification assigns no
|
||||
|
@ -79,12 +79,12 @@ type Atom10Feed struct {
|
|||
//
|
||||
// atom:feed elements MAY contain any number of atom:category
|
||||
// elements.
|
||||
Categories AtomCategories `xml:"http://www.w3.org/2005/Atom category"`
|
||||
Categories atomCategories `xml:"http://www.w3.org/2005/Atom category"`
|
||||
|
||||
Entries []Atom10Entry `xml:"http://www.w3.org/2005/Atom entry"`
|
||||
Entries []atom10Entry `xml:"http://www.w3.org/2005/Atom entry"`
|
||||
}
|
||||
|
||||
type Atom10Entry struct {
|
||||
type atom10Entry struct {
|
||||
// The "atom:id" element conveys a permanent, universally unique
|
||||
// identifier for an entry or feed.
|
||||
//
|
||||
|
@ -100,7 +100,7 @@ type Atom10Entry struct {
|
|||
// readable title for an entry or feed.
|
||||
//
|
||||
// atom:entry elements MUST contain exactly one atom:title element.
|
||||
Title Atom10Text `xml:"http://www.w3.org/2005/Atom title"`
|
||||
Title atom10Text `xml:"http://www.w3.org/2005/Atom title"`
|
||||
|
||||
// The "atom:published" element is a Date construct indicating an
|
||||
// instant in time associated with an event early in the life cycle of
|
||||
|
@ -118,7 +118,7 @@ type Atom10Entry struct {
|
|||
// atom:entry elements MUST NOT contain more than one atom:link
|
||||
// element with a rel attribute value of "alternate" that has the
|
||||
// same combination of type and hreflang attribute values.
|
||||
Links AtomLinks `xml:"http://www.w3.org/2005/Atom link"`
|
||||
Links atomLinks `xml:"http://www.w3.org/2005/Atom link"`
|
||||
|
||||
// atom:entry elements MUST contain an atom:summary element in either
|
||||
// of the following cases:
|
||||
|
@ -131,17 +131,17 @@ type Atom10Entry struct {
|
|||
//
|
||||
// atom:entry elements MUST NOT contain more than one atom:summary
|
||||
// element.
|
||||
Summary Atom10Text `xml:"http://www.w3.org/2005/Atom summary"`
|
||||
Summary atom10Text `xml:"http://www.w3.org/2005/Atom summary"`
|
||||
|
||||
// atom:entry elements MUST NOT contain more than one atom:content
|
||||
// element.
|
||||
Content Atom10Text `xml:"http://www.w3.org/2005/Atom content"`
|
||||
Content atom10Text `xml:"http://www.w3.org/2005/Atom content"`
|
||||
|
||||
// The "atom:author" element is a Person construct that indicates the
|
||||
// author of the entry or feed.
|
||||
//
|
||||
// atom:entry elements MUST contain one or more atom:author elements
|
||||
Authors AtomPersons `xml:"http://www.w3.org/2005/Atom author"`
|
||||
Authors atomPersons `xml:"http://www.w3.org/2005/Atom author"`
|
||||
|
||||
// The "atom:category" element conveys information about a category
|
||||
// associated with an entry or feed. This specification assigns no
|
||||
|
@ -149,7 +149,7 @@ type Atom10Entry struct {
|
|||
//
|
||||
// atom:entry elements MAY contain any number of atom:category
|
||||
// elements.
|
||||
Categories AtomCategories `xml:"http://www.w3.org/2005/Atom category"`
|
||||
Categories atomCategories `xml:"http://www.w3.org/2005/Atom category"`
|
||||
|
||||
media.MediaItemElement
|
||||
}
|
||||
|
@ -160,14 +160,14 @@ type Atom10Entry struct {
|
|||
// Text: https://datatracker.ietf.org/doc/html/rfc4287#section-3.1.1.1
|
||||
// HTML: https://datatracker.ietf.org/doc/html/rfc4287#section-3.1.1.2
|
||||
// XHTML: https://datatracker.ietf.org/doc/html/rfc4287#section-3.1.1.3
|
||||
type Atom10Text struct {
|
||||
type atom10Text struct {
|
||||
Type string `xml:"type,attr"`
|
||||
CharData string `xml:",chardata"`
|
||||
InnerXML string `xml:",innerxml"`
|
||||
XHTMLRootElement AtomXHTMLRootElement `xml:"http://www.w3.org/1999/xhtml div"`
|
||||
XHTMLRootElement atomXHTMLRootElement `xml:"http://www.w3.org/1999/xhtml div"`
|
||||
}
|
||||
|
||||
func (a *Atom10Text) Body() string {
|
||||
func (a *atom10Text) body() string {
|
||||
var content string
|
||||
|
||||
if strings.EqualFold(a.Type, "xhtml") {
|
||||
|
@ -179,7 +179,7 @@ func (a *Atom10Text) Body() string {
|
|||
return strings.TrimSpace(content)
|
||||
}
|
||||
|
||||
func (a *Atom10Text) Title() string {
|
||||
func (a *atom10Text) title() string {
|
||||
var content string
|
||||
|
||||
switch {
|
||||
|
@ -194,14 +194,14 @@ func (a *Atom10Text) Title() string {
|
|||
return strings.TrimSpace(content)
|
||||
}
|
||||
|
||||
func (a *Atom10Text) xhtmlContent() string {
|
||||
func (a *atom10Text) xhtmlContent() string {
|
||||
if a.XHTMLRootElement.XMLName.Local == "div" {
|
||||
return a.XHTMLRootElement.InnerXML
|
||||
}
|
||||
return a.InnerXML
|
||||
}
|
||||
|
||||
type AtomXHTMLRootElement struct {
|
||||
type atomXHTMLRootElement struct {
|
||||
XMLName xml.Name `xml:"div"`
|
||||
InnerXML string `xml:",innerxml"`
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@ import (
|
|||
)
|
||||
|
||||
type Atom10Adapter struct {
|
||||
atomFeed *Atom10Feed
|
||||
atomFeed *atom10Feed
|
||||
}
|
||||
|
||||
func NewAtom10Adapter(atomFeed *Atom10Feed) *Atom10Adapter {
|
||||
func NewAtom10Adapter(atomFeed *atom10Feed) *Atom10Adapter {
|
||||
return &Atom10Adapter{atomFeed}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ func (a *Atom10Adapter) BuildFeed(baseURL string) *model.Feed {
|
|||
}
|
||||
|
||||
// Populate the site URL.
|
||||
siteURL := a.atomFeed.Links.OriginalLink()
|
||||
siteURL := a.atomFeed.Links.originalLink()
|
||||
if siteURL != "" {
|
||||
if absoluteSiteURL, err := urllib.AbsoluteURL(baseURL, siteURL); err == nil {
|
||||
feed.SiteURL = absoluteSiteURL
|
||||
|
@ -50,13 +50,13 @@ func (a *Atom10Adapter) BuildFeed(baseURL string) *model.Feed {
|
|||
}
|
||||
|
||||
// Populate the feed title.
|
||||
feed.Title = a.atomFeed.Title.Body()
|
||||
feed.Title = a.atomFeed.Title.body()
|
||||
if feed.Title == "" {
|
||||
feed.Title = feed.SiteURL
|
||||
}
|
||||
|
||||
// Populate the feed description.
|
||||
feed.Description = a.atomFeed.Subtitle.Body()
|
||||
feed.Description = a.atomFeed.Subtitle.body()
|
||||
|
||||
// Populate the feed icon.
|
||||
if a.atomFeed.Icon != "" {
|
||||
|
@ -79,7 +79,7 @@ func (a *Atom10Adapter) populateEntries(siteURL string) model.Entries {
|
|||
entry := model.NewEntry()
|
||||
|
||||
// Populate the entry URL.
|
||||
entry.URL = atomEntry.Links.OriginalLink()
|
||||
entry.URL = atomEntry.Links.originalLink()
|
||||
if entry.URL != "" {
|
||||
if absoluteEntryURL, err := urllib.AbsoluteURL(siteURL, entry.URL); err == nil {
|
||||
entry.URL = absoluteEntryURL
|
||||
|
@ -87,16 +87,16 @@ func (a *Atom10Adapter) populateEntries(siteURL string) model.Entries {
|
|||
}
|
||||
|
||||
// Populate the entry content.
|
||||
entry.Content = atomEntry.Content.Body()
|
||||
entry.Content = atomEntry.Content.body()
|
||||
if entry.Content == "" {
|
||||
entry.Content = atomEntry.Summary.Body()
|
||||
entry.Content = atomEntry.Summary.body()
|
||||
if entry.Content == "" {
|
||||
entry.Content = atomEntry.FirstMediaDescription()
|
||||
}
|
||||
}
|
||||
|
||||
// Populate the entry title.
|
||||
entry.Title = atomEntry.Title.Title()
|
||||
entry.Title = atomEntry.Title.title()
|
||||
if entry.Title == "" {
|
||||
entry.Title = sanitizer.TruncateHTML(entry.Content, 100)
|
||||
if entry.Title == "" {
|
||||
|
@ -105,9 +105,9 @@ func (a *Atom10Adapter) populateEntries(siteURL string) model.Entries {
|
|||
}
|
||||
|
||||
// Populate the entry author.
|
||||
authors := atomEntry.Authors.PersonNames()
|
||||
authors := atomEntry.Authors.personNames()
|
||||
if len(authors) == 0 {
|
||||
authors = a.atomFeed.Authors.PersonNames()
|
||||
authors = a.atomFeed.Authors.personNames()
|
||||
}
|
||||
sort.Strings(authors)
|
||||
authors = slices.Compact(authors)
|
||||
|
@ -152,7 +152,7 @@ func (a *Atom10Adapter) populateEntries(siteURL string) model.Entries {
|
|||
}
|
||||
|
||||
// Generate the entry hash.
|
||||
for _, value := range []string{atomEntry.ID, atomEntry.Links.OriginalLink()} {
|
||||
for _, value := range []string{atomEntry.ID, atomEntry.Links.originalLink()} {
|
||||
if value != "" {
|
||||
entry.Hash = crypto.SHA256(value)
|
||||
break
|
||||
|
|
|
@ -30,9 +30,9 @@ func (a *AtomPerson) PersonName() string {
|
|||
return strings.TrimSpace(a.Email)
|
||||
}
|
||||
|
||||
type AtomPersons []*AtomPerson
|
||||
type atomPersons []*AtomPerson
|
||||
|
||||
func (a AtomPersons) PersonNames() []string {
|
||||
func (a atomPersons) personNames() []string {
|
||||
var names []string
|
||||
authorNamesMap := make(map[string]bool)
|
||||
|
||||
|
@ -56,9 +56,9 @@ type AtomLink struct {
|
|||
Title string `xml:"title,attr"`
|
||||
}
|
||||
|
||||
type AtomLinks []*AtomLink
|
||||
type atomLinks []*AtomLink
|
||||
|
||||
func (a AtomLinks) OriginalLink() string {
|
||||
func (a atomLinks) originalLink() string {
|
||||
for _, link := range a {
|
||||
if strings.EqualFold(link.Rel, "alternate") {
|
||||
return strings.TrimSpace(link.Href)
|
||||
|
@ -72,7 +72,7 @@ func (a AtomLinks) OriginalLink() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (a AtomLinks) firstLinkWithRelation(relation string) string {
|
||||
func (a atomLinks) firstLinkWithRelation(relation string) string {
|
||||
for _, link := range a {
|
||||
if strings.EqualFold(link.Rel, relation) {
|
||||
return strings.TrimSpace(link.Href)
|
||||
|
@ -82,7 +82,7 @@ func (a AtomLinks) firstLinkWithRelation(relation string) string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (a AtomLinks) firstLinkWithRelationAndType(relation string, contentTypes ...string) string {
|
||||
func (a atomLinks) firstLinkWithRelationAndType(relation string, contentTypes ...string) string {
|
||||
for _, link := range a {
|
||||
if strings.EqualFold(link.Rel, relation) {
|
||||
for _, contentType := range contentTypes {
|
||||
|
@ -96,7 +96,7 @@ func (a AtomLinks) firstLinkWithRelationAndType(relation string, contentTypes ..
|
|||
return ""
|
||||
}
|
||||
|
||||
func (a AtomLinks) findAllLinksWithRelation(relation string) []*AtomLink {
|
||||
func (a atomLinks) findAllLinksWithRelation(relation string) []*AtomLink {
|
||||
var links []*AtomLink
|
||||
|
||||
for _, link := range a {
|
||||
|
@ -116,7 +116,7 @@ func (a AtomLinks) findAllLinksWithRelation(relation string) []*AtomLink {
|
|||
// meaning to the content (if any) of this element.
|
||||
//
|
||||
// Specs: https://datatracker.ietf.org/doc/html/rfc4287#section-4.2.2
|
||||
type AtomCategory struct {
|
||||
type atomCategory struct {
|
||||
// The "term" attribute is a string that identifies the category to
|
||||
// which the entry or feed belongs. Category elements MUST have a
|
||||
// "term" attribute.
|
||||
|
@ -134,9 +134,9 @@ type AtomCategory struct {
|
|||
Label string `xml:"label,attr"`
|
||||
}
|
||||
|
||||
type AtomCategories []AtomCategory
|
||||
type atomCategories []atomCategory
|
||||
|
||||
func (ac AtomCategories) CategoryNames() []string {
|
||||
func (ac atomCategories) CategoryNames() []string {
|
||||
var categories []string
|
||||
|
||||
for _, category := range ac {
|
||||
|
|
|
@ -15,13 +15,13 @@ import (
|
|||
func Parse(baseURL string, r io.ReadSeeker, version string) (*model.Feed, error) {
|
||||
switch version {
|
||||
case "0.3":
|
||||
atomFeed := new(Atom03Feed)
|
||||
atomFeed := new(atom03Feed)
|
||||
if err := xml_decoder.NewXMLDecoder(r).Decode(atomFeed); err != nil {
|
||||
return nil, fmt.Errorf("atom: unable to parse Atom 0.3 feed: %w", err)
|
||||
}
|
||||
return NewAtom03Adapter(atomFeed).BuildFeed(baseURL), nil
|
||||
return NewAtom03Adapter(atomFeed).buildFeed(baseURL), nil
|
||||
default:
|
||||
atomFeed := new(Atom10Feed)
|
||||
atomFeed := new(atom10Feed)
|
||||
if err := xml_decoder.NewXMLDecoder(r).Decode(atomFeed); err != nil {
|
||||
return nil, fmt.Errorf("atom: unable to parse Atom 1.0 feed: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue