atom

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2023 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const NAME = "Feedme"
View Source
const PKG = "git.sr.ht/~bossley9/feedme"
View Source
const VERSION = "v0.0.4"

Variables

This section is empty.

Functions

func FeedError

func FeedError(message string, rfcSection string) error

Types

type AtomAuthor

type AtomAuthor AtomPersonConstruct

type AtomCategory

type AtomCategory struct {
	XMLName xml.Name `xml:"category"`
	Term    string   `xml:"term,attr"` // required
	Scheme  AtomURI  `xml:"scheme,attr,omitempty"`
	Label   string   `xml:"label,attr,omitempty"` // HTML-escaped
}

self-closing element

func (AtomCategory) Validate

func (category AtomCategory) Validate() error

type AtomContent

type AtomContent struct {
	Type string  `xml:"type,attr,omitempty"` // one of "text", "html", "xhtml", or a MIME media type - default "text"
	Src  AtomURI `xml:"src,attr,omitempty"`
	Text string  `xml:",chardata"`
}

type AtomContributor

type AtomContributor AtomPersonConstruct

type AtomDate

type AtomDate time.Time // datetime reference as defined in RFC 3339

func (AtomDate) MarshalXML

func (date AtomDate) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type AtomEmail

type AtomEmail string // email address as defined in RFC 2822

type AtomEntry

type AtomEntry struct {
	XMLName      xml.Name          `xml:"entry"`
	Authors      []AtomAuthor      `xml:"author"`
	Categories   []AtomCategory    `xml:"category"`
	Content      *AtomContent      `xml:"content"`
	Contributors []AtomContributor `xml:"contributor"`
	Id           AtomID            `xml:"id"` // required
	Links        []AtomLink        `xml:"link"`
	Published    *AtomDate         `xml:"published,omitempty"`
	Rights       *AtomRights       `xml:"rights,omitempty"`
	Source       *AtomSource       `xml:"source,omitempty"`
	Summary      *AtomSummary      `xml:"summary,omitempty"`
	Title        AtomTitle         `xml:"title"`   // required
	Updated      AtomDate          `xml:"updated"` // required
}

func CreateFeedEntry

func CreateFeedEntry(id string, title string, updated time.Time) (*AtomEntry, error)

func (*AtomEntry) AddCategory added in v0.2.0

func (entry *AtomEntry) AddCategory(term string, scheme string, label string) error
func (entry *AtomEntry) AddLink(href string, rel AtomRelType) error

func (*AtomEntry) SetContent

func (entry *AtomEntry) SetContent(content string, contentType string) error

func (*AtomEntry) SetPublished

func (entry *AtomEntry) SetPublished(published time.Time) error

func (*AtomEntry) SetSummary added in v0.2.0

func (entry *AtomEntry) SetSummary(text string, textType string) error

func (AtomEntry) String

func (entry AtomEntry) String() string

func (AtomEntry) Validate

func (entry AtomEntry) Validate() error

type AtomFeed

type AtomFeed struct {
	XMLName      xml.Name          `xml:"http://www.w3.org/2005/Atom feed"`
	Authors      []AtomAuthor      `xml:"author"` // >1 required
	Categories   []AtomCategory    `xml:"category"`
	Contributors []AtomContributor `xml:"contributor"`
	Generator    AtomGenerator     `xml:",omitempty"`
	Icon         AtomIcon          `xml:"icon,omitempty"` // should use aspect ratio 1(h):1(v)
	Id           AtomID            `xml:"id"`             // required
	Links        []AtomLink        `xml:"link"`
	Rights       *AtomRights       `xml:"rights,omitempty"`
	Subtitle     *AtomSubtitle     `xml:"subtitle,omitempty"`
	Title        AtomTitle         `xml:"title"`   // required
	Updated      AtomDate          `xml:"updated"` // required
	Entries      []AtomEntry       `xml:"entry"`
}

func CreateFeed

func CreateFeed(id string, title string, updated time.Time) (*AtomFeed, error)

func (*AtomFeed) AddAuthor

func (feed *AtomFeed) AddAuthor(name string, uri string, email string) error

func (*AtomFeed) AddCategory added in v0.2.0

func (feed *AtomFeed) AddCategory(term string, scheme string, label string) error

func (*AtomFeed) AddEntry

func (feed *AtomFeed) AddEntry(entry *AtomEntry) error
func (feed *AtomFeed) AddLink(href string, rel AtomRelType) error

func (*AtomFeed) SetCopyright added in v0.2.0

func (feed *AtomFeed) SetCopyright(text string, textType string) error
func (feed *AtomFeed) SetLogo(uri string) error

func (*AtomFeed) SetSubtitle

func (feed *AtomFeed) SetSubtitle(text string, textType string) error

func (*AtomFeed) SetTitle added in v0.2.0

func (feed *AtomFeed) SetTitle(text string, textType string) error

func (*AtomFeed) SetUpdated added in v0.2.0

func (feed *AtomFeed) SetUpdated(date time.Time) error

func (AtomFeed) String

func (feed AtomFeed) String() string

func (AtomFeed) Validate

func (feed AtomFeed) Validate() error

type AtomGenerator

type AtomGenerator struct {
	Uri     AtomURI `xml:"uri,attr"`
	Version string  `xml:"version,attr"`
	Text    string  `xml:",innerxml"`
}

func (AtomGenerator) MarshalXML

func (generator AtomGenerator) MarshalXML(e *xml.Encoder, _ xml.StartElement) error

type AtomID

type AtomID AtomURI

atom:id elements must ALWAYS assure uniqueness. See https://datatracker.ietf.org/doc/html/rfc4287#section-4.2.6 for strategies on generating unique id elements.

type AtomIcon

type AtomIcon AtomURI

type AtomLanguageTag

type AtomLanguageTag string // language type as defined in RFC 3066
type AtomLink struct {
	XMLName  xml.Name        `xml:"link"`
	Href     AtomURI         `xml:"href,attr"` // required
	Rel      AtomRelType     `xml:"rel,attr,omitempty"`
	Type     AtomMediaType   `xml:"type,attr,omitempty"`
	HrefLang AtomLanguageTag `xml:"hreflang,attr,omitempty"`
	Title    string          `xml:"title,attr,omitempty"` // HTML-escaped
	Length   uint            `xml:"length,attr,omitempty"`
}

self-closing element

func (AtomLink) Validate

func (link AtomLink) Validate() error
type AtomLogo AtomURI

type AtomMediaType

type AtomMediaType string // MIME media type

type AtomName

type AtomName string

type AtomPersonConstruct

type AtomPersonConstruct struct {
	Name  AtomName  `xml:"name"` // required
	Uri   AtomURI   `xml:"uri,omitempty"`
	Email AtomEmail `xml:"email,omitempty"`
}

func (AtomPersonConstruct) Validate

func (person AtomPersonConstruct) Validate() error

type AtomRelType

type AtomRelType int
const (
	RelUnknown AtomRelType = iota
	RelAlternate
	RelRelated
	RelSelf
	RelEnclosure
	RelVia
)

func (AtomRelType) MarshalText

func (rel AtomRelType) MarshalText() ([]byte, error)

type AtomRights

type AtomRights AtomTextConstruct

type AtomSource

type AtomSource struct{} // extension of atom:feed without entries

unimplemented due to language constraints

type AtomSubtitle

type AtomSubtitle AtomTextConstruct

type AtomSummary

type AtomSummary AtomTextConstruct

type AtomTextConstruct

type AtomTextConstruct struct {
	Type AtomTextType `xml:"type,attr,omitempty"`
	Text string       `xml:",chardata"` // required
}

func (AtomTextConstruct) Validate

func (text AtomTextConstruct) Validate() error

type AtomTextType

type AtomTextType string // one of "text", "html", "xhtml" - default "text"

type AtomTitle

type AtomTitle AtomTextConstruct

type AtomURI

type AtomURI string // IRI reference as defined in RFC 3987

Jump to

Keyboard shortcuts

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