subscriptions

package
v0.0.0-...-e184c4b Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSaving           = errors.New("couldn't save JSON to disk")
	ErrNotSuccess       = errors.New("status 20 not returned")
	ErrNotFeed          = errors.New("not a valid feed")
	ErrTooManyRedirects = errors.New("redirected more than 5 times")
)
View Source
var LastUpdated time.Time

LastUpdated is the time when the in-memory data was last updated. It can be used to know if the subscriptions page should be regenerated.

Functions

func AddFeed

func AddFeed(url string, feed *gofeed.Feed) error

AddFeed stores a feed. It can be used to update a feed for a URL, although the package will handle that on its own.

func AddPage

func AddPage(url string, r io.Reader) error

AddPage stores a page to track for changes. It can be used to update the page as well, although the package will handle that on its own.

func AllURLS

func AllURLS() []string

AllURLs returns all the subscribed-to URLS.

func GetFeed

func GetFeed(mediatype, filename string, r io.Reader) (*gofeed.Feed, bool)

GetFeed returns a Feed object and a bool indicating whether the passed content was actually recognized as a feed.

func Init

func Init() error

Init should be called after config.Init.

func IsSubscribed

func IsSubscribed(url string) bool

IsSubscribed returns true if the URL is already subscribed to, whether a feed or page.

func Remove

func Remove(u string) error

Remove removes a subscription from memory and from the disk. The URL must be provided. It will do nothing if the URL is not an actual subscription.

It returns any errors that occurred when saving to disk.

Types

type PageEntries

type PageEntries struct {
	Entries []*PageEntry
}

PageEntries is new-to-old list of Entry structs, used to create a subscriptions page. It should always be assumed to be sorted when used in other packages, by post time, from newest to oldest.

func GetPageEntries

func GetPageEntries() *PageEntries

GetPageEntries returns the current list of PageEntries for use in rendering a page. The contents of the returned entries will never change, so this function needs to be called again to get updates. It always returns sorted entries - by post time, from newest to oldest.

func (*PageEntries) Len

func (e *PageEntries) Len() int

func (*PageEntries) Less

func (e *PageEntries) Less(i, j int) bool

func (*PageEntries) Swap

func (e *PageEntries) Swap(i, j int)

type PageEntry

type PageEntry struct {
	Prefix    string // Feed/log title, author, etc - something before the post title
	Title     string
	URL       string
	Published time.Time
}

PageEntry is a single item on a subscriptions page. It is used for both feeds and pages.

Jump to

Keyboard shortcuts

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