feed

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToXML added in v1.1.0

func ToXML(feed XmlFeed) (string, error)

turn a feed object (either a Feed, AtomFeed, or RssFeed) into xml returns an error if xml marshaling fails

func WriteXML added in v1.1.0

func WriteXML(feed XmlFeed, w io.Writer) error

WriteXML writes a feed object (either a Feed, AtomFeed, or RssFeed) as XML into the writer. Returns an error if XML marshaling fails.

Types

type Atom added in v1.1.0

type Atom struct {
	*Feed
}

func (*Atom) AtomFeed added in v1.1.0

func (a *Atom) AtomFeed() *AtomFeed

create a new AtomFeed with a generic Feed struct's data

func (*Atom) FeedXml added in v1.1.0

func (a *Atom) FeedXml() interface{}

FeedXml returns an XML-Ready object for an Atom object

type AtomAuthor added in v1.1.0

type AtomAuthor struct {
	XMLName xml.Name `xml:"author"`
	AtomPerson
}

type AtomCategories added in v1.1.0

type AtomCategories []string

type AtomContent added in v1.1.0

type AtomContent struct {
	XMLName xml.Name `xml:"content"`
	Content string   `xml:",chardata"`
	Type    string   `xml:"type,attr"`
}

type AtomContributor added in v1.1.0

type AtomContributor struct {
	XMLName xml.Name `xml:"contributor"`
	AtomPerson
}

type AtomEntry added in v1.1.0

type AtomEntry struct {
	Content     *AtomContent
	Author      *AtomAuthor
	Summary     *AtomSummary
	Contributor *AtomContributor
	XMLName     xml.Name `xml:"entry"`
	Updated     string   `xml:"updated"`
	Rights      string   `xml:"rights,omitempty"`
	Source      string   `xml:"source,omitempty"`
	Published   string   `xml:"published,omitempty"`
	Id          string   `xml:"id"`
	Title       string   `xml:"title"`
	Xmlns       string   `xml:"xmlns,attr,omitempty"`
	Links       []AtomLink
	Categories  AtomCategories `xml:"category,omitempty"`
}

type AtomFeed added in v1.1.0

type AtomFeed struct {
	XMLName     xml.Name `xml:"feed"`
	Xmlns       string   `xml:"xmlns,attr"`
	Title       string   `xml:"title"`   // required
	Id          string   `xml:"id"`      // required
	Updated     string   `xml:"updated"` // required
	Icon        string   `xml:"icon,omitempty"`
	Rights      string   `xml:"rights,omitempty"` // copyright used
	Subtitle    string   `xml:"subtitle,omitempty"`
	Link        *AtomLink
	Author      *AtomAuthor `xml:"author,omitempty"`
	Contributor *AtomContributor
	Entries     []*AtomEntry `xml:"entry"`
}

func (*AtomFeed) FeedXml added in v1.1.0

func (a *AtomFeed) FeedXml() interface{}

FeedXml returns an XML-ready object for an AtomFeed object

type AtomLink struct {
	// Atom 1.0 <link rel="enclosure" type="audio/mpeg" title="MP3" href="http://www.example.org/myaudiofile.mp3" length="1234" />
	XMLName xml.Name `xml:"link"`
	Href    string   `xml:"href,attr"`
	Rel     string   `xml:"rel,attr,omitempty"`
	Type    string   `xml:"type,attr,omitempty"`
	Length  string   `xml:"length,attr,omitempty"`
}

Multiple links with different rel can coexist

type AtomPerson added in v1.1.0

type AtomPerson struct {
	Name  string `xml:"name,omitempty"`
	Uri   string `xml:"uri,omitempty"`
	Email string `xml:"email,omitempty"`
}

type AtomSummary added in v1.1.0

type AtomSummary struct {
	XMLName xml.Name `xml:"summary"`
	Content string   `xml:",chardata"`
	Type    string   `xml:"type,attr"`
}

type Author added in v1.1.0

type Author struct {
	Name, Email string
}

type Enclosure added in v1.1.0

type Enclosure struct {
	Url, Length, Type string
}

type Feed added in v1.1.0

type Feed struct {
	Updated     time.Time
	Created     time.Time
	Link        *Link
	Author      *Author
	Image       *Image
	Title       string
	Description string
	Id          string
	Subtitle    string
	Copyright   string
	Items       []*Item
}

func (*Feed) Add added in v1.1.0

func (f *Feed) Add(item *Item)

add a new Item to a Feed

func (*Feed) Sort added in v1.1.0

func (f *Feed) Sort(less func(a, b *Item) bool)

Sort sorts the Items in the feed with the given less function.

func (*Feed) ToAtom added in v1.1.0

func (f *Feed) ToAtom() (string, error)

// creates an Atom representation of this feed

func (*Feed) WriteAtom added in v1.1.0

func (f *Feed) WriteAtom(w io.Writer) error

WriteAtom writes an Atom representation of this feed to the writer.

type Image added in v1.1.0

type Image struct {
	Url, Title, Link string
	Width, Height    int
}

type Item added in v1.1.0

type Item struct {
	Link        *Link
	Source      *Link
	Author      *Author
	Enclosure   *Enclosure
	Title       string
	Description string // used as description in rss, summary in atom
	Id          string // used as guid in rss, id in atom
	Updated     time.Time
	Created     time.Time
	Content     string
	Categories  []string
}
type Link struct {
	Href, Rel, Type, Length string
}

type Meta added in v0.1.1

type Meta struct {
	C      *config.Config
	D      map[string]entry.Entry
	InDir  string
	OutDir string
	IsDry  bool
}

func (*Meta) ConstructFeed added in v0.1.1

func (m *Meta) ConstructFeed() (string, error)

func (*Meta) SaveFeed added in v0.1.1

func (m *Meta) SaveFeed(atom string) error

type UUID added in v1.1.0

type UUID [16]byte

func NewUUID added in v1.1.0

func NewUUID() *UUID

create a new uuid v4

func (*UUID) String added in v1.1.0

func (u *UUID) String() string

type XmlFeed added in v1.1.0

type XmlFeed interface {
	FeedXml() interface{}
}

interface used by ToXML to get a object suitable for exporting XML.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL