reader

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 24 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const MaxText = 64 << 10

MaxText bounds an entry's kept text.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound means there is no such feed or entry.

Functions

func Discover

func Discover(page []byte) string

Discover finds a feed address in a web page's head (<link rel="alternate" type="application/rss+xml">).

func Plain

func Plain(s string) string

Plain is markup as plain text: tags removed, entities decoded, paragraphs kept apart.

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 Parsed

type Parsed struct {
	Title   string
	Site    string
	Entries []Entry
}

Parsed is a feed as fetched: its title, its site, its entries.

func Parse

func Parse(data []byte) (Parsed, error)

Parse reads an RSS 2.0 (or RDF-like) or Atom document.

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

func (s *Store) Add(ctx context.Context, client *http.Client, raw, folder string) (Feed, error)

Add follows a feed. The address may be the feed itself or a page that names one.

func (*Store) Entries

func (s *Store) Entries(ctx context.Context, q Query) ([]Entry, error)

Entries lists entries newest first.

func (*Store) Entry

func (s *Store) Entry(ctx context.Context, id string) (Entry, error)

Entry is one entry with its whole text.

func (*Store) Feeds

func (s *Store) Feeds(ctx context.Context) ([]Feed, error)

Feeds lists the feeds with their unread counts, by folder then title.

func (*Store) Mark

func (s *Store) Mark(ctx context.Context, id string, read, starred, saved *bool) error

Mark sets an entry's flags (nil leaves one as it is).

func (*Store) MarkAllRead

func (s *Store) MarkAllRead(ctx context.Context, feed string) error

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`.

func (*Store) Remove

func (s *Store) Remove(ctx context.Context, id string) error

Remove stops following a feed and forgets its entries.

func (*Store) Update

func (s *Store) Update(ctx context.Context, id string, title, folder *string) error

Update renames a feed or moves it to a folder (nil leaves a field as it is).

Jump to

Keyboard shortcuts

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