Documentation
¶
Index ¶
- Constants
- Variables
- func DiscoverFeeds(site string) (feeds []string, err error)
- func LoadTemplate(file string) (tmpl *html.Template, err error)
- func Symlink(src, dst string) error
- func WriteTemplate(file string, tmpl *html.Template, vars interface{}) error
- type Conf
- type Feed
- type FilterStats
- type Generator
- type Item
- type Parser
- type Settings
- type TemplateFeed
- type TemplateGenerator
- type TemplateVars
Constants ¶
const ( GeneratorName string = "feedloggr" GeneratorVersion string = "v0.4.2" GeneratorSource string = "https://github.com/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 ¶ added in v0.4.0
DiscoverFeeds tries to discover any URLs that looks like feeds, from a site.
func LoadTemplate ¶ added in v0.4.0
LoadTemplates tries to parse a template from file or use a default template. The returned template has no name and has some helper functions declared.
Types ¶
type Conf ¶
Conf contains ALL settings for a Generator, usually loaded from a yaml file.
type Feed ¶
type Feed struct {
Title string // Custom title
Url string // URL to feed
Parser Parser `yaml:",omitempty"` // Custom parsing rule.
}
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 ¶ added in v0.4.0
New creates a new Generator instance, based on conf.
func (*Generator) FetchItems ¶ added in v0.4.0
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 Parser ¶
type Parser struct {
Rule string // Regexp rule for gragging items' title/url fields in a feed body
Host string // Optional prefix the item urls with this host
}
Parser contains a custom regexp rule for parsing non- atom/rss/json feeds.
type Settings ¶
type Settings struct {
Output string // Dir to output the feeds and internal bloom filter
Template string // Filepath to custom HTML template
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 ¶ added in v0.4.0
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 ¶ added in v0.4.0
TemplateGenerator contains the basic info for this generator.
type TemplateVars ¶ added in v0.4.0
type TemplateVars struct {
Today time.Time // Current time
Generator TemplateGenerator // Basic generator info
Feeds []TemplateFeed // List of feeds and their config, items and errors
}
TemplateVars is a set of basic info that can be provided when executing/writing a template.
func NewTemplateVars ¶ added in v0.4.0
func NewTemplateVars() TemplateVars
NewTemplateVars creates a new instance and adds current time and generator info to it. The Feeds field will be empty and has to be manually updated.