ragg

package module
v0.0.0-...-d9b9e8e Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

README

===== ragg: rss feed aggregation ===============================================

ragg is a silly little RSS tool I wrote to support a unified news/blog/friends
feed on my website. It takes in RSS feeds from https/file sources, merges
them into one big feed with a defined template and ordered items (most recent
first) and returns the result as a string.

===== usage ====================================================================

install using: go get jnichols.info/git/ragg.git

additional dependencies (automatically installed) are located in the go.mod
file.

aggregate your feed by doing the following:

a := &ragg.Aggregator{
	Cache:   ragg.Cache(ragg.D_CACHE_DIR, ragg.D_CACHE_TTL),
	Sources: []string{...},
	Template: &feeds.Feed{
		Title: "Test Feed",
		...
	},
}
feed, err := a.Aggregate()

===== sources ==================================================================

sources must be either file://[path] or https://[path] for local and networked
RSS respectively. ragg doesn't currently validate or fix problems, so vet your
sources.

===== cacheing =================================================================

setting a Cache on an aggregator will store a cache file at the target location
and serve that file as long as the TTL hasn't expired and the file exists. If
the cache becomes stale or there's an error fetching the cached feed, the cache
will be invalidated and source will be re-fetched. nil caches are permitted
and will just result in feeds not being cached.

===== credits ==================================================================

thing			copyright						license

mmcdole/gofeed	(c) 2016 mmcdole				MIT
gorilla/feed	(c) 2023 The Gorilla Authors	BSD-3

Documentation

Index

Constants

View Source
const (
	SORT_NONE = SortFlag(iota)
	SORT_TIME_DSC
	SORT_TIME_ASC
)
View Source
const D_CACHE_TTL = time.Hour

Variables

This section is empty.

Functions

func Cache

func Cache(location string, name string, ttl time.Duration) (*cache, error)

Cache creates a cache at location/name/. If location is "", it will use your OS' temp directory (see os.TempDir) and will create a randomly-named folder. If name is "", it will use "ragg-cache".

Types

type Aggregator

type Aggregator struct {
	Cache    *cache
	Sources  []Source
	Sort     SortFlag
	Template *feeds.Feed
	Logger   *slog.Logger
}

func (*Aggregator) Aggregate

func (a *Aggregator) Aggregate() (*feeds.Feed, error)

func (*Aggregator) Log

func (a *Aggregator) Log(l slog.Level, msg string, args ...any)

type SortFlag

type SortFlag int

type Source

type Source struct {
	Source string
	Limit  int
	MaxAge time.Duration
}

Jump to

Keyboard shortcuts

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