feed

package
v0.0.0-...-c55a1d0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Feed

type Feed interface {
	Name() string
	Description() string
	URL() string
	// Next returns the next post in the feed.
	//
	// A feed typically models an existing resource, e.g. posts from an RSS feed
	// or posts from a database that is then iterated over using `Next`.
	//
	// An error matching errors.Is(err, io.EOF) indicates that there are no
	// more posts.
	Next() (*Post, error)
	Close() error
}

Feed represent of feed of posts from a given source.

func Merge

func Merge(feeds ...Feed) Feed

Merge returns a special feed that merges the posts from the feeds and presents them as a single Feed to iterate over.

Each feed is assumed to be sorted already (by date descending). Merge only takes care to preserve the order that exists and returns the posts from all feeds in order.

type Notes

type Notes interface {
	Notes() string
}

Notes is an extension that Feeds might implement, which add arbitrary notes to a feed.

They are currently used to add debugging info to a feed, e.g. if there was an error while updating it or if it is cached.

type Open

type Open func(ctx context.Context, name string, search Search) (Feed, error)

Open is a function that opens a feed identified by `name`.

All feeds currently implement this.

type OpenCached

type OpenCached func(ctx context.Context, name string, uncached Open, search Search) (Feed, error)

OpenCached is a function that caches the feed identified by `name`.

database.OpenCached is currently the only implementation, backed by sqlite.

type Post

type Post struct {
	Source          string
	ID              string `xml:"guid"`
	Author          string
	AvatarURL       string
	URL             string   `xml:"link"`
	Title           string   `xml:"title"`
	DescriptionHTML string   `xml:"description"`
	Tags            []string `xml:"category"`
	DateString      string   `xml:"pubDate"`
	Date            time.Time
}

Post is a single post, e.g. a blog post or a tweet.

func (Post) IsReblog

func (p Post) IsReblog() bool

IsReblog returns true if the post is a repost of another post, likely from another source.

type Search struct {
	IsActive bool

	BeforeID string

	NoReblogs    bool
	Skip         bool
	Terms        []string
	Tags         []string
	ExcludeTerms []string
	ExcludeTags  []string

	ForceFresh bool
	// contains filtered or unexported fields
}

Search represents a search in a feed.

func FromRequest

func FromRequest(req *http.Request) Search

FromRequest parses search info from the request.

Search.IsActive if there is a search happening.

func ParseTerms

func ParseTerms(rawSearch string) Search

ParseTerms parses the search terms from the given string.

func (*Search) Matches

func (s *Search) Matches(p *Post) bool

Matches returns true if the post matches the search.

func (*Search) String

func (s *Search) String() string

type Static

type Static struct {
	FeedName        string
	FeedURL         string
	FeedDescription string
	Posts           []Post
}

Static is a feed that contains exactly the Posts specified.

func (*Static) Close

func (s *Static) Close() error

Close implements Feed.Close.

func (*Static) Description

func (s *Static) Description() string

Description implements Feed.Description

func (*Static) Name

func (s *Static) Name() string

Name implements Feed.Name

func (*Static) Next

func (s *Static) Next() (*Post, error)

Next implements Feed.Next.

func (*Static) URL

func (s *Static) URL() string

URL implements Feed.URL

type StatusError

type StatusError struct {
	Code int
}

StatusError is an error with an HTTP status code.

func (StatusError) Error

func (se StatusError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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