rss

package module
v0.0.0-...-434c345 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: GPL-2.0 Imports: 16 Imported by: 0

README

A simple, non-persistent, RSS client. I use this primarily to keep up with news.

Currently, it requires both Vim and Firefox to be installed, in order to be able to edit the subscription list and render pages in interactive mode.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Display

func Display(w io.Writer, feedItems []FeedItem, displayMode DisplayMode, opts ...DisplayOption) error

Display writes the feed items to the given writer in the provided display mode. Returns any error encountered by writing to w.

func GetFeedsAsync

func GetFeedsAsync(urls []string) <-chan *Feed

GetFeedsAsync makes requests to the hosts in parallel and writes the results to the returned channel as they are received.

func GetURLs

func GetURLs(r io.Reader) []string

GetURLs reads the given Reader and returns a list of the urls from which feeds can be fetched.

func RunApp

func RunApp(feeds <-chan *Feed, mode DisplayMode, opts ...AppOption) error

Types

type AppOption

type AppOption func(*appOptions)

func WithDisplayOptions

func WithDisplayOptions(opts ...DisplayOption) AppOption

func WithFilters

func WithFilters(filters ...Filter) AppOption

type Browser

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

func NewBrowser

func NewBrowser() (*Browser, error)

func (*Browser) NewPage

func (b *Browser) NewPage(url string) (*Page, error)

func (*Browser) Stop

func (b *Browser) Stop()

func (*Browser) WriteText

func (b *Browser) WriteText(url string, w io.Writer) error

WriteText fetches the page at the given URL and writes its text to the given Writer.

type Channel

type Channel struct {
	XMLName     xml.Name `xml:"channel"`
	Title       string   `xml:"title"`
	Link        string   `xml:"link"`
	Description string   `xml:"description"`
	Generator   string   `xml:"generator"`
	Language    string   `xml:"language"`
	Items       []Item   `xml:"item"`
}

type Colour

type Colour string

type DisplayMode

type DisplayMode func([]FeedItem) []FeedItem

type DisplayOption

type DisplayOption func(FeedItem) FeedItem

func ColourAfter

func ColourAfter(t time.Time) DisplayOption

type Feed

type Feed struct {
	URL string
	RSS
}

func GetFeeds

func GetFeeds(urls []string) []*Feed

GetFeeds makes requests to the hosts in parallel and collects the results into a slice.

type FeedItem

type FeedItem struct {
	Title       string
	Description string
	PublishTime time.Time
	Links       []string
	Feed        string
	Channel     string
}

func GetFeedItems

func GetFeedItems(feeds []*Feed, filters ...Filter) []FeedItem

GetFeedItems unpacks the items within the given feeds, applying filters if given.

func Grouped

func Grouped(feedItems []FeedItem) []FeedItem

func ReverseChronological

func ReverseChronological(feedItems []FeedItem) []FeedItem

func UnpackFeed

func UnpackFeed(feed *Feed, filters ...Filter) []FeedItem

func (FeedItem) Format

func (fi FeedItem) Format() string

type Filter

type Filter func(FeedItem) bool

func Deduplicate

func Deduplicate() Filter

Deduplicate ensures that each feed item only appears in the output once.

func MaxItems

func MaxItems(n int) Filter

MaxItems enforces a limit on the total number of items in the result. Passing zero in results in no limit.

func MaxItemsPerChannel

func MaxItemsPerChannel(n int) Filter

MaxItemsPerChannel puts a limit on the number of items per channel. Passing zero in results in no limit

func OldestItem

func OldestItem(maxAge time.Duration) Filter

OldestItem ensures that the output feed items are less than the max age given.

type Filters

type Filters []Filter

func (Filters) Apply

func (fs Filters) Apply(fi FeedItem) bool

Apply applies all the filters to an item and returns true if they all pass, otherwise false.

type Item

type Item struct {
	XMLName xml.Name `xml:"item"`
	Title   string   `xml:"title"`
	Link    string   `xml:"link"`
	PubDate string   `xml:"pubDate"`
	GUID    string   `xml:"guid"`
	// Comments provide a link to a dedicated comments page e.g. hackernews
	Comments    string `xml:"comments"`
	Description []byte `xml:"description"`
}

type Page

type Page struct {
	*bytes.Buffer
}

type RSS

type RSS struct {
	XMLName xml.Name `xml:"rss"`
	Channel Channel  `xml:"channel"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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