Documentation
¶
Overview ¶
Package reader is the Reader module: RSS and Atom feeds the owner follows, read in a window of their own. Entries are kept as plain text (markup removed, scripts never kept), at most 300 per feed with starred ones always kept, fetched in the background with conditional requests from public addresses only.
Ported from Basalisk's Reader (internal/feeds, frontend/src/apps/reader). Basalisk's library half (Fragments Engine's read-it-later items, collections and the video player) is not here.
Index ¶
- Constants
- Variables
- func Discover(page []byte) string
- func Plain(s string) string
- type Entry
- type Feed
- type Parsed
- type Query
- type Store
- func (s *Store) Add(ctx context.Context, client *http.Client, raw, folder string) (Feed, error)
- func (s *Store) Entries(ctx context.Context, q Query) ([]Entry, error)
- func (s *Store) Entry(ctx context.Context, id string) (Entry, error)
- func (s *Store) Feeds(ctx context.Context) ([]Feed, error)
- func (s *Store) Mark(ctx context.Context, id string, read, starred, saved *bool) error
- func (s *Store) MarkAllRead(ctx context.Context, feed string) error
- func (s *Store) Refresh(ctx context.Context, client *http.Client, id string, older time.Duration) error
- func (s *Store) Remove(ctx context.Context, id string) error
- func (s *Store) Update(ctx context.Context, id string, title, folder *string) error
Constants ¶
const MaxText = 64 << 10
MaxText bounds an entry's kept text.
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound means there is no such feed or entry.
Functions ¶
Types ¶
type Entry ¶
type Entry struct {
ID string `json:"id"`
FeedID string `json:"feed_id"`
GUID string `json:"-"`
URL string `json:"url"`
Title string `json:"title"`
Author string `json:"author,omitempty"`
Published time.Time `json:"published"`
// Text is the entry's summary or content as plain text (markup removed).
Text string `json:"text"`
Image string `json:"image,omitempty"`
Read bool `json:"read"`
Starred bool `json:"starred"`
Saved bool `json:"saved"`
Feed string `json:"feed,omitempty"` // the feed's title, in listings
}
Entry is one item of a feed.
type Feed ¶
type Feed struct {
ID string `json:"id"`
URL string `json:"url"`
Title string `json:"title"`
Site string `json:"site,omitempty"`
Folder string `json:"folder,omitempty"`
AddedAt time.Time `json:"added_at"`
FetchedAt time.Time `json:"fetched_at"`
// Error is why the last fetch failed; empty when it worked.
Error string `json:"error,omitempty"`
Unread int `json:"unread"`
}
Feed is a feed the owner follows.
type Query ¶
type Query struct {
Feed string
Unread bool
Starred bool
Text string
Before string // the last entry of the previous page: "published|id" (or its published time alone)
Limit int
}
Query narrows a listing of entries.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store keeps feeds and their entries, in the module's own database (migrations/).
func (*Store) Add ¶
Add follows a feed. The address may be the feed itself or a page that names one.
func (*Store) MarkAllRead ¶
MarkAllRead marks every entry of a feed (or of all feeds, with "") read.
func (*Store) Refresh ¶
func (s *Store) Refresh(ctx context.Context, client *http.Client, id string, older time.Duration) error
Refresh fetches one feed again (id) or every feed not fetched within `older`.