feeds

package
v0.0.0-...-7bc4eb1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2016 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToXML

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

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

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

Types

type Atom

type Atom struct {
	*Feed
}

func (*Atom) AtomFeed

func (a *Atom) AtomFeed() *AtomFeed

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

func (*Atom) FeedXml

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

return an XML-Ready object for an Atom object

type AtomAuthor

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

type AtomContent

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

type AtomContributor

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

type AtomEntry

type AtomEntry struct {
	XMLName     xml.Name `xml:"entry"`
	Xmlns       string   `xml:"xmlns,attr,omitempty"`
	Title       string   `xml:"title"`   // required
	Updated     string   `xml:"updated"` // required
	Id          string   `xml:"id"`      // required
	Category    string   `xml:"category,omitempty"`
	Content     *AtomContent
	Rights      string `xml:"rights,omitempty"`
	Source      string `xml:"source,omitempty"`
	Published   string `xml:"published,omitempty"`
	Contributor *AtomContributor
	Link        *AtomLink    // required if no child 'content' elements
	Summary     *AtomSummary // required if content has src or content is base64
	Author      *AtomAuthor  // required if feed lacks an author
}

type AtomFeed

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
	Category    string   `xml:"category,omitempty"`
	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
}

func (*AtomFeed) FeedXml

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

return 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"`
}

type AtomPerson

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

type AtomSummary

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

type Author

type Author struct {
	Name, Email string
}

type Feed

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

func (*Feed) Add

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

add a new Item to a Feed

func (*Feed) ToAtom

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

creates an Atom representation of this feed

func (*Feed) ToRss

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

creates an Rss representation of this feed

func (*Feed) WriteAtom

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

Writes an Atom representation of this feed to the writer.

func (*Feed) WriteRss

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

Writes an RSS representation of this feed to the writer.

type Item

type Item struct {
	Title       string
	Link        *Link
	Author      *Author
	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
	Media       []*Media
}
type Link struct {
	Href, Rel, Type, Length string
}

type Media

type Media struct {
	Medium string
	Url    string
	Height string
	Width  string
}

type Rss

type Rss struct {
	*Feed
}

func (*Rss) FeedXml

func (r *Rss) FeedXml() interface{}

return an XML-Ready object for an Rss object

func (*Rss) RssFeed

func (r *Rss) RssFeed() *RssFeed

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

type RssEnclosure

type RssEnclosure struct {
	//RSS 2.0 <enclosure url="http://example.com/file.mp3" length="123456789" type="audio/mpeg" />
	XMLName xml.Name `xml:"enclosure"`
	Url     string   `xml:"url,attr"`
	Length  string   `xml:"length,attr"`
	Type    string   `xml:"type,attr"`
}

type RssFeed

type RssFeed struct {
	XMLName        xml.Name `xml:"channel"`
	Title          string   `xml:"title"`       // required
	Link           string   `xml:"link"`        // required
	Description    string   `xml:"description"` // required
	Language       string   `xml:"language,omitempty"`
	Copyright      string   `xml:"copyright,omitempty"`
	ManagingEditor string   `xml:"managingEditor,omitempty"` // Author used
	WebMaster      string   `xml:"webMaster,omitempty"`
	PubDate        string   `xml:"pubDate,omitempty"`       // created or updated
	LastBuildDate  string   `xml:"lastBuildDate,omitempty"` // updated used
	Category       string   `xml:"category,omitempty"`
	Generator      string   `xml:"generator,omitempty"`
	Docs           string   `xml:"docs,omitempty"`
	Cloud          string   `xml:"cloud,omitempty"`
	Ttl            int      `xml:"ttl,omitempty"`
	Rating         string   `xml:"rating,omitempty"`
	SkipHours      string   `xml:"skipHours,omitempty"`
	SkipDays       string   `xml:"skipDays,omitempty"`
	Image          *RssImage
	TextInput      *RssTextInput
	Items          []*RssItem
}

func (*RssFeed) FeedXml

func (r *RssFeed) FeedXml() interface{}

return an XML-ready object for an RssFeed object

type RssImage

type RssImage struct {
	XMLName xml.Name `xml:"image"`
	Url     string   `xml:"url"`
	Title   string   `xml:"title"`
	Link    string   `xml:"link"`
	Width   string   `xml:"width,omitempty"`
	Height  string   `xml:"height,omitempty"`
}

type RssItem

type RssItem struct {
	XMLName      xml.Name `xml:"item"`
	Title        string   `xml:"title"`       // required
	Link         string   `xml:"link"`        // required
	Description  string   `xml:"description"` // required
	Author       string   `xml:"author,omitempty"`
	Category     string   `xml:"category,omitempty"`
	Comments     string   `xml:"comments,omitempty"`
	Enclosure    *RssEnclosure
	Guid         string         `xml:"guid,omitempty"`    // Id used
	PubDate      string         `xml:"pubDate,omitempty"` // created or updated
	Source       string         `xml:"source,omitempty"`
	MediaGroup   *RssMediaGroup `xml:"media:group,omitempty"`
	MediaContent *RssMedia      `xml:"media:content,omitempty"`
}

type RssMedia

type RssMedia struct {
	XMLName xml.Name `xml:"media:content"`
	Medium  string   `xml:"medium,attr,omitempty"`
	Url     string   `xml:"url,attr,omitempty"`
	Height  string   `xml:"height,attr,omitempty"`
	Width   string   `xml:"width,attr,omitempty"`
}

type RssMediaGroup

type RssMediaGroup struct {
	XMLName      xml.Name `xml:"media:group"`
	MediaContent []*RssMedia
}

type RssTextInput

type RssTextInput struct {
	XMLName     xml.Name `xml:"textInput"`
	Title       string   `xml:"title"`
	Description string   `xml:"description"`
	Name        string   `xml:"name"`
	Link        string   `xml:"link"`
}

type UUID

type UUID [16]byte

func NewUUID

func NewUUID() *UUID

create a new uuid v4

func (*UUID) String

func (u *UUID) String() string

type XmlFeed

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