feeds

package
v0.4.134 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 20 Imported by: ? modules, 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 feeds keeps the RSS and Atom feeds the owner chose for the dashboard's footer (CasaOS#180) and their latest headlines. A box whose owner never saved the settings shows the distribution's own releases (DefaultFeed); turned off, or with no feed, it fetches nothing. Reading the headlines never waits on the network: it answers what is cached and, when that is older than refreshEvery, starts a refresh in the background. Feeds are fetched by the box, never toward an address of the box itself or of its networks (guard.go).

Index

Constants

View Source
const ConfigFile = "/var/lib/casaos/feeds.json"

ConfigFile holds the switch and the feeds (root, 0600: a private feed's URL can carry its token).

View Source
const DefaultFeed = "https://github.com/ReCasaOS/CasaOS-Install/releases.atom"

DefaultFeed is what a box whose owner never saved the settings shows: the distribution's releases.

Variables

View Source
var Default = New("/")

Default is the box's own.

View Source
var ErrInvalid = errors.New("invalid feeds settings")

ErrInvalid is a PUT body that is not one: too many feeds, or one that is not an http(s) URL. Nothing is written.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled bool     `json:"enabled"`
	Feeds   []string `json:"feeds"`
}

Config is feeds.json.

type Hub

type Hub struct {
	Root   string
	Now    func() time.Time
	Client *http.Client
	// contains filtered or unexported fields
}

Hub is the feeds of one box.

func New

func New(root string) *Hub

New keeps feeds.json under root and fetches through the guarded client.

func (*Hub) Status

func (h *Hub) Status() Status

Status answers the settings and the cached headlines, and starts a refresh when they are due. Off, or with no feed, it starts nothing.

func (*Hub) Update

func (h *Hub) Update(c Config) (Status, error)

Update replaces the settings. Feeds are trimmed, and a feed given twice is kept once. More than maxFeeds, or a feed that is not an http(s) URL, is ErrInvalid.

type Item

type Item struct {
	Title  string `json:"title"`
	Link   string `json:"link"`
	Source string `json:"source"`
}

Item is one headline: its title as plain text, an http(s) link, and the feed it came from.

type Status

type Status struct {
	Enabled bool     `json:"enabled"`
	Feeds   []string `json:"feeds"`
	Items   []Item   `json:"items"`
	// why the last read of a feed failed, by feed; absent for a feed read fine or not read yet
	Errors map[string]string `json:"errors,omitempty"`
}

Status is what GET and PUT /v1/sys/feeds answer: the settings and the cached headlines of the feeds set now, in their order.

Jump to

Keyboard shortcuts

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