fetcher

package
v0.0.0-...-cb29121 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTTL uint = 1440

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	// Title is the human readable name of this RSS channel.
	// Required.
	Title string

	// Link is the URL to a website that corresponds to this channel.
	// Required.
	Link string `xml:"link"`

	// Description is a phrase or sentence that describes the contents of
	// this channel.
	// Required.
	Description string

	// PubDate holds the date that this feed was last published.
	PubDate time.Time

	// TTL is the number of minutes that this Channel may be cached before
	// being refreshed.
	//
	// If nil, the default is 1440 (24 hours).
	TTL uint

	// Items holds the entries for this Channel.
	Items []Item

	// URL is the URL that this channel was fetched from.
	URL string
}

Channel holds news items for a Feed. It holds properties that make the feed more human readable and also has all of the content.

func Parse

func Parse(r io.Reader) (Channel, error)

Parse reads a stream of XML and attempts to parse an RSS or an Atom feed.

type Item

type Item struct {
	// Title is the title of this news item.
	Title string

	// Link is the URL that corresponds to this news item.
	Link string

	// Content is a synopsis of an item, or its entire contents.
	Content string

	// ContentType is the type of this content as a MIME.
	//
	// Default: "text/plain".
	ContentType string

	// ContentLink is a link to the actual content.
	// If this is not empty, Content serves as the summary.
	ContentLink string

	// ContentLinkType is the type of the content that may be found at
	// ContentLink.
	// It is used for automatically inserting certain media as the body of
	// the post.
	ContentLinkType string

	// Author is the email address of the author of the item.
	Author string

	// GUID is a globally unique identifier for this item.
	// Required for newsd.
	GUID string

	// PubDate is the date when this item was published.
	PubDate time.Time

	// Channel is the channel that this item came from.
	Channel string
}

Item represents one news item in a Channel.

All fields are optional but one of Title or Description must be present. newsd currently ignores entries without GUIDs because of how the database is implemented.

type RSSChannel

type RSSChannel struct {
	// Title is the human readable name of this RSS channel.
	// Required.
	Title string `xml:"title"`

	// Link is the URL to a website that corresponds to this channel.
	// Required.
	Link string `xml:"link"`

	// Description is a phrase or sentence that describes the contents of
	// this channel.
	// Required.
	Description string `xml:"description"`

	// PubDate is the raw representation of the PubDate element.
	PubDate RSSTime `xml:"pubDate,omitempty"`

	// TTL is the number of minutes that this Channel may be cached before
	// being refreshed.
	//
	// If nil, the default is 1440 (24 hours).
	TTL *uint `xml:"ttl,omitempty"`

	// Items holds the entries for this Channel.
	Items []RSSItem `xml:"item,omitempty"`

	// LastUpdated is the last time this channel was updated.
	// Note that the value of this field is not respected.
	LastUpdated int64 `xml:"-"`
}

RSSChannel holds news items for a Feed. It holds properties that make the feed more human readable and also has all of the content.

type RSSItem

type RSSItem struct {
	// Title is the title of this news item.
	Title string `xml:"title,omitempty"`

	// Link is the URL that corresponds to this news item.
	Link string `xml:"link,omitempty"`

	// Description is the synopsis of the item, or its entire contents in
	// entity-encoded HTML.
	Description string `xml:"description,omitempty"`

	// content is an extension upon RSS that specifies one (1) element:
	// content:encoded.
	// What does it contain? CDATA or entity escaped content.
	//
	// Reference document: http://purl.org/rss/1.0/modules/content/
	// Because encoding/xml sucks, the namespace is not checked.
	//
	// This field will be preferred over Description when
	// len(EncodedContent) > len(Description).
	EncodedContent string `xml:"encoded,omitempty"`

	// Author is the email address of the author of the item.
	Author string `xml:"author,omitempty"`

	// GUID is a globally unique identifier for this item.
	// Required for newsd.
	GUID string `xml:"guid"`

	// PubDate is the raw representation of the PubDate element.
	//
	// If this is empty when the item was fetched, it will default to the
	// time that the entry was processed.
	PubDate RSSTime `xml:"pubDate,omitempty"`
}

RSSItem represents one news item in a Channel.

All fields are optional but one of Title or Description must be present.

type RSSTime

type RSSTime string

RSSTime holds arbitrary times, used in the pubDate field for Channels and Items.

To get the time.Time representation, call Parse().

func (RSSTime) Parse

func (r RSSTime) Parse() time.Time

Jump to

Keyboard shortcuts

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