mirror of
https://github.com/miniflux/v2.git
synced 2025-08-26 18:21:01 +00:00
Remove some duplicated code in RSS parser
This commit is contained in:
parent
dd4fb660c1
commit
4834e934f2
4 changed files with 227 additions and 64 deletions
|
@ -3,41 +3,18 @@
|
|||
|
||||
package rss // import "miniflux.app/v2/internal/reader/rss"
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"miniflux.app/v2/internal/reader/atom"
|
||||
)
|
||||
|
||||
type AtomAuthor struct {
|
||||
Author AtomPerson `xml:"http://www.w3.org/2005/Atom author"`
|
||||
Author atom.AtomPerson `xml:"http://www.w3.org/2005/Atom author"`
|
||||
}
|
||||
|
||||
func (a *AtomAuthor) String() string {
|
||||
return a.Author.String()
|
||||
}
|
||||
|
||||
type AtomPerson struct {
|
||||
Name string `xml:"name"`
|
||||
Email string `xml:"email"`
|
||||
}
|
||||
|
||||
func (a *AtomPerson) String() string {
|
||||
var name string
|
||||
|
||||
switch {
|
||||
case a.Name != "":
|
||||
name = a.Name
|
||||
case a.Email != "":
|
||||
name = a.Email
|
||||
}
|
||||
|
||||
return strings.TrimSpace(name)
|
||||
}
|
||||
|
||||
type AtomLink struct {
|
||||
URL string `xml:"href,attr"`
|
||||
Type string `xml:"type,attr"`
|
||||
Rel string `xml:"rel,attr"`
|
||||
Length string `xml:"length,attr"`
|
||||
func (a *AtomAuthor) PersonName() string {
|
||||
return a.Author.PersonName()
|
||||
}
|
||||
|
||||
type AtomLinks struct {
|
||||
Links []*AtomLink `xml:"http://www.w3.org/2005/Atom link"`
|
||||
Links []*atom.AtomLink `xml:"http://www.w3.org/2005/Atom link"`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue