atom

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(baseURL string, r io.ReadSeeker, version string) (*model.Feed, error)

Parse returns a normalized feed struct from a Atom feed.

Types

type Atom03Adapter added in v2.1.2

type Atom03Adapter struct {
	// contains filtered or unexported fields
}

func NewAtom03Adapter added in v2.1.2

func NewAtom03Adapter(atomFeed *Atom03Feed) *Atom03Adapter

func (*Atom03Adapter) BuildFeed added in v2.1.2

func (a *Atom03Adapter) BuildFeed(baseURL string) *model.Feed

type Atom03Content added in v2.1.2

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".
	Type string `xml:"type,attr"`

	// Content constructs MAY have a "mode" attribute, whose value indicates the method used to encode the content.
	// When present, this attribute's value MUST be listed below.
	// If not present, its value MUST be considered to be "xml".
	//
	// "xml": A mode attribute with the value "xml" indicates that the element's content is inline xml (for example, namespace-qualified XHTML).
	//
	// "escaped": A mode attribute with the value "escaped" indicates that the element's content is an escaped string.
	// Processors MUST unescape the element's content before considering it as content of the indicated media type.
	//
	// "base64": A mode attribute with the value "base64" indicates that the element's content is base64-encoded [RFC2045].
	// Processors MUST decode the element's content before considering it as content of the the indicated media type.
	Mode string `xml:"mode,attr"`

	CharData string `xml:",chardata"`
	InnerXML string `xml:",innerxml"`
}

func (*Atom03Content) Content added in v2.1.2

func (a *Atom03Content) Content() string

type Atom03Entry added in v2.1.2

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.
	ID string `xml:"id"`

	// 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"`

	// 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.
	// The content of an atom:modified element MUST have a time zone whose value SHOULD be "UTC".
	Modified string `xml:"modified"`

	// The "atom:issued" element is a Date construct that indicates the time that the entry was issued.
	// atom:entry elements MUST contain an atom:issued element, but MUST NOT contain more than one.
	// The content of an atom:issued element MAY omit a time zone.
	Issued string `xml:"issued"`

	// The "atom:created" element is a Date construct that indicates the time that the entry was created.
	// atom:entry elements MAY contain an atom:created element, but MUST NOT contain more than one.
	// The content of an atom:created element MUST have a time zone whose value SHOULD be "UTC".
	// If atom:created is not present, its content MUST considered to be the same as that of atom:modified.
	Created string `xml:"created"`

	// The "atom:link" element is a Link construct that conveys a URI associated with the entry.
	// The nature of the relationship as well as the link itself is determined by the element's content.
	// 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"`

	// 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"`

	// 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"`

	// 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,
	// UNLESS the atom:feed element containing them contains an atom:author element itself.
	// atom:entry elements MUST NOT contain more than one atom:author element.
	Author AtomPerson `xml:"author"`
}

type Atom03Feed added in v2.1.2

type Atom03Feed struct {
	Version string `xml:"version,attr"`

	// The "atom:id" element's content conveys a permanent, globally unique identifier for the feed.
	// It MUST NOT change over time, even if the feed is relocated. atom:feed elements MAY contain an atom:id element,
	// but MUST NOT contain more than one. The content of this element, when present, MUST be a URI.
	ID string `xml:"http://purl.org/atom/ns# id"`

	// 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"`

	// 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"`

	// 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,
	// UNLESS all of the atom:feed element's child atom:entry elements contain an atom:author element.
	// atom:feed elements MUST NOT contain more than one atom:author element.
	Author AtomPerson `xml:"http://purl.org/atom/ns# author"`

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

Specs: http://web.archive.org/web/20060811235523/http://www.mnot.net/drafts/draft-nottingham-atom-format-02.html

type Atom10Adapter added in v2.1.2

type Atom10Adapter struct {
	// contains filtered or unexported fields
}

func NewAtom10Adapter added in v2.1.2

func NewAtom10Adapter(atomFeed *Atom10Feed) *Atom10Adapter

func (*Atom10Adapter) BuildFeed added in v2.1.2

func (a *Atom10Adapter) BuildFeed(baseURL string) *model.Feed

type Atom10Entry added in v2.1.2

type Atom10Entry struct {
	// The "atom:id" element conveys a permanent, universally unique
	// identifier for an entry or feed.
	//
	// Its content MUST be an IRI, as defined by [RFC3987].  Note that the
	// definition of "IRI" excludes relative references.  Though the IRI
	// might use a dereferencable scheme, Atom Processors MUST NOT assume it
	// can be dereferenced.
	//
	// atom:entry elements MUST contain exactly one atom:id element.
	ID string `xml:"http://www.w3.org/2005/Atom id"`

	// The "atom:title" element is a Text construct that conveys a human-
	// 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"`

	// The "atom:published" element is a Date construct indicating an
	// instant in time associated with an event early in the life cycle of
	// the entry.
	Published string `xml:"http://www.w3.org/2005/Atom published"`

	// The "atom:updated" element is a Date construct indicating the most
	// recent instant in time when an entry or feed was modified in a way
	// the publisher considers significant. Therefore, not all
	// modifications necessarily result in a changed atom:updated value.
	//
	// atom:entry elements MUST contain exactly one atom:updated element.
	Updated string `xml:"http://www.w3.org/2005/Atom updated"`

	// 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"`

	// atom:entry elements MUST contain an atom:summary element in either
	// of the following cases:
	// *  the atom:entry contains an atom:content that has a "src"
	//    attribute (and is thus empty).
	// *  the atom:entry contains content that is encoded in Base64;
	//    i.e., the "type" attribute of atom:content is a MIME media type
	//    [MIMEREG], but is not an XML media type [RFC3023], does not
	//    begin with "text/", and does not end with "/xml" or "+xml".
	//
	// atom:entry elements MUST NOT contain more than one atom:summary
	// element.
	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"`

	// 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"`

	// The "atom:category" element conveys information about a category
	// associated with an entry or feed.  This specification assigns no
	// meaning to the content (if any) of this element.
	//
	// atom:entry elements MAY contain any number of atom:category
	// elements.
	Categories AtomCategories `xml:"http://www.w3.org/2005/Atom category"`

	media.MediaItemElement
}

type Atom10Feed added in v2.1.2

type Atom10Feed struct {
	XMLName xml.Name `xml:"http://www.w3.org/2005/Atom feed"`

	// The "atom:id" element conveys a permanent, universally unique
	// identifier for an entry or feed.
	//
	// Its content MUST be an IRI, as defined by [RFC3987].  Note that the
	// definition of "IRI" excludes relative references.  Though the IRI
	// might use a dereferencable scheme, Atom Processors MUST NOT assume it
	// can be dereferenced.
	//
	// atom:feed elements MUST contain exactly one atom:id element.
	ID string `xml:"http://www.w3.org/2005/Atom id"`

	// The "atom:title" element is a Text construct that conveys a human-
	// 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"`

	// The "atom:author" element is a Person construct that indicates the
	// author of the entry or feed.
	//
	// 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"`

	// The "atom:icon" element's content is an IRI reference [RFC3987] that
	// identifies an image that provides iconic visual identification for a
	// feed.
	//
	// atom:feed elements MUST NOT contain more than one atom:icon element.
	Icon string `xml:"http://www.w3.org/2005/Atom icon"`

	// identifies an image that provides visual identification for a feed.
	//
	// atom:feed elements MUST NOT contain more than one atom:logo element.
	Logo string `xml:"http://www.w3.org/2005/Atom logo"`

	// atom:feed elements SHOULD contain one atom:link element with a rel
	// attribute value of "self". This is the preferred URI for
	// retrieving Atom Feed Documents representing this Atom feed.
	//
	// 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"`

	// The "atom:category" element conveys information about a category
	// associated with an entry or feed.  This specification assigns no
	// meaning to the content (if any) of this element.
	//
	// atom:feed elements MAY contain any number of atom:category
	// elements.
	Categories AtomCategories `xml:"http://www.w3.org/2005/Atom category"`

	Entries []Atom10Entry `xml:"http://www.w3.org/2005/Atom entry"`
}

The "atom:feed" element is the document (i.e., top-level) element of an Atom Feed Document, acting as a container for metadata and data associated with the feed. Its element children consist of metadata elements followed by zero or more atom:entry child elements.

Specs: https://tools.ietf.org/html/rfc4287 https://validator.w3.org/feed/docs/atom.html

type Atom10Text added in v2.1.2

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

A Text construct contains human-readable text, usually in small quantities. The content of Text constructs is Language-Sensitive. Specs: https://datatracker.ietf.org/doc/html/rfc4287#section-3.1 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

func (*Atom10Text) Body added in v2.1.2

func (a *Atom10Text) Body() string

func (*Atom10Text) Title added in v2.1.2

func (a *Atom10Text) Title() string

type AtomCategories added in v2.1.2

type AtomCategories []AtomCategory

func (AtomCategories) CategoryNames added in v2.1.2

func (ac AtomCategories) CategoryNames() []string

type AtomCategory added in v2.1.2

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.
	Term string `xml:"term,attr"`

	// The "scheme" attribute is an IRI that identifies a categorization
	// scheme. Category elements MAY have a "scheme" attribute.
	Scheme string `xml:"scheme,attr"`

	// The "label" attribute provides a human-readable label for display in
	// end-user applications. The content of the "label" attribute is
	// Language-Sensitive. Entities such as "&" and "<" represent
	// their corresponding characters ("&" and "<", respectively), not
	// markup. Category elements MAY have a "label" attribute.
	Label string `xml:"label,attr"`
}

The "atom:category" element conveys information about a category associated with an entry or feed. This specification assigns no meaning to the content (if any) of this element.

Specs: https://datatracker.ietf.org/doc/html/rfc4287#section-4.2.2

type AtomLink struct {
	Href   string `xml:"href,attr"`
	Type   string `xml:"type,attr"`
	Rel    string `xml:"rel,attr"`
	Length string `xml:"length,attr"`
	Title  string `xml:"title,attr"`
}

Specs: https://datatracker.ietf.org/doc/html/rfc4287#section-4.2.7

type AtomLinks []*AtomLink
func (a AtomLinks) OriginalLink() string

type AtomPerson added in v2.1.2

type AtomPerson struct {
	// The "atom:name" element's content conveys a human-readable name for the author.
	// It MAY be the name of a corporation or other entity no individual authors can be named.
	// Person constructs MUST contain exactly one "atom:name" element, whose content MUST be a string.
	Name string `xml:"name"`

	// The "atom:email" element's content conveys an e-mail address associated with the Person construct.
	// Person constructs MAY contain an atom:email element, but MUST NOT contain more than one.
	// Its content MUST be an e-mail address [RFC2822].
	// Ordering of the element children of Person constructs MUST NOT be considered significant.
	Email string `xml:"email"`
}

Specs: https://datatracker.ietf.org/doc/html/rfc4287#section-3.2

func (*AtomPerson) PersonName added in v2.1.2

func (a *AtomPerson) PersonName() string

type AtomPersons added in v2.1.2

type AtomPersons []*AtomPerson

func (AtomPersons) PersonNames added in v2.1.2

func (a AtomPersons) PersonNames() []string

type AtomXHTMLRootElement added in v2.1.2

type AtomXHTMLRootElement struct {
	XMLName  xml.Name `xml:"div"`
	InnerXML string   `xml:",innerxml"`
}

Jump to

Keyboard shortcuts

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