Documentation
¶
Overview ¶
Package rss is a pure-Go (CGO=0) reimplementation of Ruby's standard library RSS module (gem rss 0.3.2, shipped with MRI 4.0.5).
It parses and generates the three feed dialects MRI's RSS supports:
- RSS 2.0 (and the historical 0.9x family), rooted at <rss>;
- RSS 1.0, the RDF dialect rooted at <rdf:RDF>;
- Atom (RFC 4287), rooted at <feed>.
Parser.Parse auto-detects the dialect from the document's root element, exactly like RSS::Parser.parse. The generated XML is byte-for-byte compatible with MRI's to_s for the round-trip (parse a feed, re-serialize it) on the supported element set, including MRI's 2-space indentation, its always-on namespace declarations on the root element, and its date formats (RFC822 for RSS <pubDate>/<lastBuildDate>, W3CDTF/RFC3339 for <dc:date> and every Atom date).
The XML layer (tokenizing on parse, attribute/text escaping) is shared with github.com/go-ruby-rexml/rexml, mirroring how MRI's RSS sits on REXML.
Bundled modules: Dublin Core (dc:), content (content:encoded) and syndication (sy:) — the common modules MRI bundles and emits by default. See the package documentation in the repository README for the exact element coverage boundary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AtomCategory ¶
AtomCategory mirrors RSS::Atom::*::Category.
type AtomEntry ¶
type AtomEntry struct {
ID string
Title string
Summary string
Content string
Updated *time.Time
Published *time.Time
Rights string
Authors []*AtomPerson
Links []*AtomLink
Categories []*AtomCategory
}
AtomEntry mirrors RSS::Atom::Feed::Entry.
type AtomFeed ¶
type AtomFeed struct {
ID string
Title string
Subtitle string
Updated *time.Time // W3CDTF
Rights string
Generator string
Authors []*AtomPerson
Links []*AtomLink
Categories []*AtomCategory
Entries []*AtomEntry
// contains filtered or unexported fields
}
AtomFeed is the <feed> document of Atom (RFC 4287). It mirrors RSS::Atom::Feed.
func (*AtomFeed) String ¶
String serializes the Atom feed to MRI-compatible XML.
MRI declares the default Atom namespace plus the Dublin Core namespace on the root <feed> (xmlns, then xmlns:dc), and emits child elements in this fixed order: author, category, contributor, generator, icon, id, link, logo, rights, subtitle, title, updated, then the entries. Atom dates use W3CDTF (RFC3339).
type AtomPerson ¶
AtomPerson mirrors an Atom person construct (author/contributor).
type Channel ¶
type Channel struct {
Title string
Link string
Description string
Language string
Copyright string
ManagingEditor string
WebMaster string
PubDate *time.Time // <pubDate>, RFC822
LastBuildDate *time.Time // <lastBuildDate>, RFC822
Generator string
Docs string
TTL string
Image *Image
Categories []string
DCDate *time.Time // dc:date, W3CDTF
SyUpdatePeriod string // sy:updatePeriod
SyUpdateFrequency string // sy:updateFrequency
SyUpdateBase string // sy:updateBase
Items []*Item
}
Channel mirrors RSS::Rss::Channel.
type Feed ¶
type Feed interface {
// FeedType is "rss", "rss" (for 1.0 too, via RDF) or "atom" — see the
// concrete types for the exact value. Use the type switch for dispatch.
FeedType() string
// String serializes the feed to MRI-compatible XML.
String() string
}
Feed is the common interface returned by Parser.Parse. The concrete type is *Rss (RSS 0.9x/2.0), *RDF (RSS 1.0) or *AtomFeed (Atom). FeedType reports the dialect, mirroring RSS feed#feed_type.
type Guid ¶
Guid mirrors RSS::Rss::Channel::Item::Guid. IsPermaLink is a tri-state in MRI (nil/true/false); HasPermaLink reports whether the attribute is set.
type Item ¶
type Item struct {
Title string
Link string
Description string
Author string
Comments string
PubDate *time.Time // <pubDate>, RFC822
Guid *Guid
Categories []string
DCDate *time.Time // dc:date, W3CDTF
DCCreator string // dc:creator
DCSubject string // dc:subject
ContentEncoded string // content:encoded
}
Item mirrors RSS::Rss::Channel::Item.
type RDF ¶
type RDF struct {
Channel *RDFChannel
Image *RDFImage
Items []*RDFItem
Textinput *RDFTextinput
// contains filtered or unexported fields
}
RDF is the <rdf:RDF> document of RSS 1.0. It mirrors RSS::RDF.
func (*RDF) String ¶
String serializes the RSS 1.0 RDF document to MRI-compatible XML.
MRI declares, on the root <rdf:RDF>, the default RSS 1.0 namespace and the rdf: namespace first, then the bundled-module namespaces (content, dc, image, slash, sy, taxo, trackback) in that fixed order, regardless of use. Children appear as <channel>, then <image>, then the <item> sequence, then <textinput>. The channel carries an <items><rdf:Seq><rdf:li resource=…/> table of item URIs.
type RDFChannel ¶
type RDFChannel struct {
About string
Title string
Link string
Description string
DCDate *time.Time
DCCreator string
SyUpdatePeriod string
SyUpdateFrequency string
SyUpdateBase string
ImageResource string // <image rdf:resource="..."/>, when an image is present
// ItemResources is the <items><rdf:Seq><rdf:li resource="..."/> sequence.
ItemResources []string
TextinputResource string
}
RDFChannel mirrors RSS::RDF::Channel. About is the rdf:about attribute.
type RDFItem ¶
type RDFItem struct {
About string
Title string
Link string
Description string
DCDate *time.Time
DCCreator string
DCSubject string
ContentEncoded string
}
RDFItem mirrors RSS::RDF::Item.
type RDFTextinput ¶
RDFTextinput mirrors RSS::RDF::Textinput.
type Rss ¶
type Rss struct {
Version string // e.g. "2.0"
Channel *Channel
// contains filtered or unexported fields
}
Rss is the <rss> document of RSS 0.91/0.92/2.0. It mirrors RSS::Rss.
func (*Rss) String ¶
String serializes the RSS 2.0/0.9x document to MRI-compatible XML.
MRI declares the bundled-module namespaces on the root <rss> element unconditionally (content, dc, itunes, trackback), in that fixed order, regardless of whether the modules are used; this method reproduces that.
