Documentation ¶
Index ¶
- Constants
- Variables
- func DiscoverFeeds(site string) (feeds []string, err error)
- func Symlink(src, dst string) error
- func WriteTemplate(file string, tmpl *html.Template, vars TemplateVars) error
- type Conf
- type Feed
- type FilterStats
- type Generator
- type Item
- type Settings
- type TemplateFeed
- type TemplateGenerator
- type TemplateVars
Constants ¶
const ( GeneratorName string = "feedloggr" GeneratorVersion string = "v0.5.0" GeneratorLink string = "https://code.larus.se/lmas/feedloggr" )
Basic info about this generator
Variables ¶
var TemplateFuncs = html.FuncMap{ "shortdate": func(t time.Time) string { return t.Format("2006-01-02") }, "prevday": func(t time.Time) time.Time { return t.AddDate(0, 0, -1) }, "nextday": func(t time.Time) time.Time { return t.AddDate(0, 0, 1) }, }
TemplateFuncs contains some simple helper functions available inside a template.
Functions ¶
func DiscoverFeeds ¶
DiscoverFeeds tries to discover any links that looks like feeds, from a site.
func Symlink ¶
Symlink tries to make a new symlink dst pointing to file src.
Types ¶
type Conf ¶
type Conf struct { Settings Settings // General settings PipeCommands []string // List of commands to pipe data to the template Feeds []Feed // Per feed settings }
Conf contains ALL settings for a Generator, usually loaded from a yaml file.
func LoadConf ¶
LoadConf tries to load a Conf from a yaml file.
type Feed ¶
type Feed struct { Title string // User-defined title Link string // Link to the page for finding news items Regexp string `yaml:",omitempty"` // Custom parsing rule, for finding non-feed items }
Feed represents a single news feed and how to download and parse it.
type FilterStats ¶
type FilterStats struct { Capacity uint // Total capacity for the internal series of bloom filters Hashes uint // Number of hash functions for each internal filter FillRatio float64 // Average ratio of set bits across all internal filters }
FilterStats contains basic info about the internal Bloom Filter.
func (FilterStats) String ¶
func (fs FilterStats) String() string
String returns a pretty string of FilterStats.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is used for downloading, parsing and then filtering items from feeds.
func NewGenerator ¶
New creates a new Generator instance, based on conf.
func (*Generator) FetchItems ¶
FetchItems downloads a feed and tries to find any items in it.
func (*Generator) FilterStats ¶
func (g *Generator) FilterStats() FilterStats
FilterStats returns a FilterStats struct with the current state of the internal bloom filter.
type Item ¶
Item represents a single news item in a feed.
type Settings ¶
type Settings struct { Output string // Directory where the feed pages will be saved MaxDays int // Max amount of days to keep generated pages for MaxItems int // Max amount of items per feed and per day Timeout int // Max time in seconds when trying to download a feed Jitter int // Time in seconds used for randomising rate limits. Verbose bool // Verbose, debug output }
Settings contains the general Generator settings.
type TemplateFeed ¶
type TemplateFeed struct { Conf Feed // Basic config for the feed Items []Item // Any parsed and filtered items Error error // Error returned when trying to download/parse the feed }
TemplateFeed contains a feed and it's parsed output (items or an error).
type TemplateGenerator ¶
TemplateGenerator contains the basic info for this generator.
type TemplateVars ¶
TemplateVars is a map of any extra info that can be provided when executing a template.
func LoadTemplate ¶
LoadTemplates tries to parse "template.html" from dir (or use a builtin default), adds some extra helper functions (see TemplateFuncs) and sets up a map of template variables (with optional data from executing cmds, with timeout). Default variables: today (timestamp), generator name/version/link.