Documentation
¶
Index ¶
- Constants
- Variables
- func CheckWaitInterval(iTime time.Time, wait time.Duration) (time.Time, bool)
- func ClearScreen()
- func FmtHelp(src string, appName string, version string, releaseDate string, ...) string
- func JSONMarshal(data interface{}) ([]byte, error)
- func JSONMarshalIndent(data interface{}, prefix string, indent string) ([]byte, error)
- func JSONUnmarshal(src []byte, data interface{}) error
- func OpenInBrowser(in io.Reader, out io.Writer, eout io.Writer, link string) error
- func ParseURLList(fName string, src []byte) (map[string]*FeedSource, error)
- func ProgressETA(t0 time.Time, i int, tot int) string
- func ProgressIPS(t0 time.Time, i int, timeUnit time.Duration) string
- func SaveChannel(db *sql.DB, link string, feedLabel string, channel *gofeed.Feed) error
- func SaveItem(db *sql.DB, feedLabel string, item *gofeed.Item) error
- func SetupScreen(out io.Writer)
- type FeedSource
- type Html2Skim
- type Skim2Html
- type Skim2Md
- type Skimmer
- func (app *Skimmer) ChannelsToUrls(db *sql.DB) ([]byte, error)
- func (app *Skimmer) DisplayItem(link string, title string, description string, enclosures string, ...) error
- func (app *Skimmer) Download(db *sql.DB) error
- func (app *Skimmer) ItemCount(db *sql.DB) (int, error)
- func (app *Skimmer) LoadCfg(userAgent string, limit int, prune bool, interactive bool, asUrls bool) error
- func (app *Skimmer) MarkItem(db *sql.DB, link string, val string) error
- func (app *Skimmer) PruneItems(db *sql.DB, pruneDT time.Time) error
- func (app *Skimmer) ReadUrls(fName string) error
- func (app *Skimmer) ResetChannels(db *sql.DB) error
- func (app *Skimmer) Run(in io.Reader, out io.Writer, eout io.Writer, args []string) error
- func (app *Skimmer) RunInteractive(db *sql.DB) error
- func (app *Skimmer) Setup(fPath string) error
- func (app *Skimmer) TagItem(db *sql.DB, link string, tag string) error
- func (app *Skimmer) Write(db *sql.DB) error
Constants ¶
const ( EnvHttpBrowser = "SKIM_HTTP_BROWSER" EnvGopherBrowser = "SKIM_GOPHER_BROWSER" EnvGemeniBrowser = "SKIM_GEMINI_BROWSER" EnvFtpBrowser = "SKIM_FTP_BROWSER" )
const ( // Version number of release Version = "0.0.23" // ReleaseDate, the date version.go was generated ReleaseDate = "2025-08-17" // ReleaseHash, the Git hash when version.go was generated ReleaseHash = "28b79f3" LicenseText = `` /* 34525-byte string literal not displayed */ )
Variables ¶
var ( // SQLCreateTables provides the statements that are use to create our tables // It has two percent s, first is feed list name, second is datetime scheme // was generated. SQLCreateTables = `` /* 651-byte string literal not displayed */ // SQLResetChannels clear the channels talbe SQLResetChannels = `DELETE FROM channels;` // Update the channels in the skimmer file SQLUpdateChannel = `` /* 221-byte string literal not displayed */ // Update a feed item in the items table SQLUpdateItem = `` /* 302-byte string literal not displayed */ // Return link and title for Urls formatted output SQLChannelsAsUrls = `SELECT link, title FROM channels ORDER BY link;` // SQLItemCount returns a list of items in the items table SQLItemCount = `SELECT COUNT(*) FROM items;` // SQLItemStats returns a list of rows with totals per status SQLItemStats = `SELECT IIF(status = '', 'unread', status) AS status, COUNT(*) FROM items GROUP BY status ORDER BY status` // SQLDisplayItems returns a list of items in decending chronological order. SQLDisplayItems = `` /* 183-byte string literal not displayed */ SQLMarkItem = `UPDATE items SET status = ? WHERE link = ?;` SQLTagItem = `UPDATE items SET tags = ? WHERE link = ?;` // SQLPruneItems will prune our items table for all items that have easier // a updated or publication date early than the timestamp provided. SQLPruneItems = `` /* 167-byte string literal not displayed */ )
Functions ¶
func CheckWaitInterval ¶
CheckWaitInterval checks to see if an interval of time has been met or exceeded. It returns the remaining time interval (possibly reset) and a boolean. The boolean is true when the time interval has been met or exceeded, false otherwise.
``` tot := len(something) // calculate the total number of items to process t0 := time.Now() iTime := time.Now() reportProgress := false
for i, key := range records {
// ... process stuff ...
if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress {
log.Printf("%s", ProgressETA(t0, i, tot))
}
}
```
func ClearScreen ¶ added in v0.0.3
func ClearScreen()
func FmtHelp ¶
func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string
FmtHelp lets you process a text block with simple curly brace markup.
func JSONMarshal ¶ added in v0.0.3
JSONMarshal provides provide a custom json encoder to solve a an issue with HTML entities getting converted to UTF-8 code points by json.Marshal(), json.MarshalIndent().
func JSONMarshalIndent ¶ added in v0.0.3
JSONMarshalIndent provides provide a custom json encoder to solve a an issue with HTML entities getting converted to UTF-8 code points by json.Marshal(), json.MarshalIndent().
func JSONUnmarshal ¶ added in v0.0.3
JSONUnmarshal is a custom JSON decoder so we can treat numbers easier
func OpenInBrowser ¶ added in v0.0.5
func ParseURLList ¶
func ParseURLList(fName string, src []byte) (map[string]*FeedSource, error)
ParseURLList takes a filename and byte slice source, parses the contents returning a map of urls to labels and an error value.
func ProgressETA ¶
ProgressETA returns a string with the percentage processed and estimated time remaining. It requires the a counter of records processed, the total count of records and a time zero value.
``` tot := len(something) // calculate the total number of items to process t0 := time.Now() iTime := time.Now() reportProgress := false
for i, key := range records {
// ... process stuff ...
if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress {
log.Printf("%s", ProgressETA(t0, i, tot))
}
}
```
func ProgressIPS ¶
ProgressIPS returns a string with the elapsed time and increments per second. Takes a time zero, a counter and time unit. Returns a string with count, running time and increments per time unit. ``` t0 := time.Now() iTime := time.Now() reportProgress := false
for i, key := range records {
// ... process stuff ...
if iTime, reportProgress = CheckWaitInterval(rptTime, (30 * time.Second)); reportProgress || i = 0 {
log.Printf("%s", ProgressIPS(t0, i, time.Second))
}
}
```
func SaveChannel ¶ added in v0.0.8
SaveChannel will write the Channel information to a skimmer channel table.
func SaveItem ¶ added in v0.0.8
SaveItem saves a gofeed item to the item table in the skimmer database
func SetupScreen ¶ added in v0.0.3
Types ¶
type FeedSource ¶ added in v0.0.8
type FeedSource struct {
Url string `json:"url,omitempty"`
Label string `json:"label,omitempty"`
UserAgent string `json:"user_agent,omitempty"`
}
FeedSource describes the source of a feed. It includes the URL, an optional label, user agent string.
type Html2Skim ¶ added in v0.0.8
type Html2Skim struct {
// AppName holds the name of the application
AppName string `json:"app_name,omitempty"`
// DbName holds the path to the SQLite3 database
DBName string `json:"db_name,omitempty"`
// URL holds the URL to visit to collect items from
URL string `json:"url,omitempty"`
// Selector holds the HTML selector to used to retrieve links
// an empty page will result looking for all href in the page document
Selector string `json:"selector,omitempty"`
// Title holds channel title for the psuedo feed created by scraping
Title string `json:"title,omitempty"`
// Description holds the channel description for the pseudo feed created by scraping
Description string `json:"description,omitempty"`
// Link set the feed link for channel, this is useful if you render a pseudo feed to RSS
Link string `json:"link,omitempty"`
// Generator lets you set the generator value for the channel
Generator string `json:"generator,omitempty"`
// LastBuildDate sets the date for the channel being built
LastBuildDate string `json:"last_build_date,omitempty"`
// contains filtered or unexported fields
}
Htm2Skim uses the Coly Golang package to scrape a website and turn it into an RSS feed.
Html2Skim struct holds the configuration for scraping a webpage and and updating a skimmer database populating both the channel table and items table based on how the struct is set.
func NewHtml2Skim ¶ added in v0.0.8
NewHtml2Skim initialized a new Html2Skim struct
type Skim2Html ¶ added in v0.0.22
type Skim2Html struct {
// AppName holds the name of the application
// used when generating the "generator" metadata
AppName string `json:"app_name,omitempty" yaml:"app_name,omitempty"`
// Version holds the version of the appliction
// used when generating the "generator" metadata
Version string `json:"version,omitempty" yaml:"version,omitempty"`
// DbName holds the path to the SQLite3 database
DBName string `json:"db_name,omitempty" yaml:"db_name,omitempty"`
// Title if this is set the title will be included
// when generating the markdown of saved items
Title string `json:"title,omitempty" yaml:"title,omitempty"`
// Description, included as metadata in head element
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// CSS is the path to a CSS file
CSS string `json:"css,omitempty" yaml:"css,omitempty"`
// Modules is a list for ES6 diles
Modules []string `json:"modules,omitempty" yaml:"modules,omitempty"`
// Header hold the HTML markdup of the Header element. If not included
// then it will be generated using the Title and timestamp
Header string `json:"header,omitempty" yaml:"header,omitempty"`
Nav string `json:"nav,omitempty" yaml:"nav,omitempty"`
Footer string `json:"footer,omitempty" yaml:"footer,omitempty"`
// contains filtered or unexported fields
}
Skim2Html supports the skim2html cli.
func NewSkim2Html ¶ added in v0.0.22
NewSkim2Html initialized a new Skim2Html struct
func (*Skim2Html) DisplayItem ¶ added in v0.0.22
type Skim2Md ¶ added in v0.0.5
type Skim2Md struct {
// AppName holds the name of the application
AppName string `json:"app_name,omitempty"`
// DbName holds the path to the SQLite3 database
DBName string `json:"db_name,omitempty"`
// Title if this is set the title will be included
// when generating the markdown of saved items
Title string `json:"title,omitempty"`
// FrontMatter, if true insert Frontmatter block in Markdown output
FrontMatter bool `json:"frontmatter,omitempty"`
// PocketButton, if true insert a "save to pocket" button for each RSS item output
PocketButton bool
// contains filtered or unexported fields
}
Skim2Md supports the skim2md cli.
func NewSkim2Md ¶ added in v0.0.5
NewSkim2Md initialized a new Skim2Md struct
func (*Skim2Md) DisplayItem ¶ added in v0.0.5
type Skimmer ¶
type Skimmer struct {
// AppName holds the name of the application
AppName string `json:"app_name,omitempty" yaml:"app_name,omitempty"`
// UserAgent holds the user agent string used by skimmer.
// Right now I plan to default it to
// app.AppName + "/" + app.Version + " (" + ReleaseDate + "." + ReleaseHash + ")"
UserAgent string `json:"user_agent,omitempty" yaml:"user_agent,omitempty"`
// DbName holds the path to the SQLite3 database
DBName string `json:"db_name,omitempty" yaml:"db_name,omitempty"`
// Urls are the map of urls to labels to be fetched or read
Urls map[string]*FeedSource `json:"urls,omitempty" yaml:"urls,omitempty"`
// Limit contrains the number of items shown
Limit int `json:"limit,omitempty" yaml:"limit,omitempty"`
// Prune contains the date to use to prune the database.
Prune bool `json:"prune,omitempty" yaml:"prune,omitempty"`
// Interactive if true causes Run to display one item at a time with a minimal of input
Interactive bool `json:"interactive,omitempty" yaml:"interactive,omitempty"`
// AsUrls, output the skimmer feeds as a newsboat style url file
AsUrls bool `json:"as_urls,omitempty" yaml:"as_urls,omitempty"`
// contains filtered or unexported fields
}
Skimmer is the application structure that holds configuration and ties the app to the runner for the cli.
func NewSkimmer ¶
func (*Skimmer) ChannelsToUrls ¶ added in v0.0.3
ChannelsToUrls converts the current channels table to Urls formated output and refreshes app.Urls data structure.
func (*Skimmer) DisplayItem ¶ added in v0.0.5
func (*Skimmer) LoadCfg ¶ added in v0.0.23
func (app *Skimmer) LoadCfg(userAgent string, limit int, prune bool, interactive bool, asUrls bool) error
LoadCfg takes the command line options, a configuration file and updates the app object.
func (*Skimmer) PruneItems ¶
PruneItems takes a timestamp and performs a row delete on the table for items that are older than the timestamp.
func (*Skimmer) ReadUrls ¶
ReadUrls reads urls or OPML file provided and updates the feeds in the skimmer skimmer file.
Newsboat's url file format is `<URL><SPACE>"~<LABEL>"` one entry per line The hash mark, "#" at the start of the line indicates a comment line.
OPML is documented at http://opml.org
func (*Skimmer) Run ¶
Run provides the runner for skimmer. It allows for testing of much of the cli functionality
func (*Skimmer) RunInteractive ¶ added in v0.0.3
RunInteractive provides a sliver of interactive UI, basically displaying an item then prompting for an action.
func (*Skimmer) Setup ¶
Setup checks to see if anything needs to be setup (or fixed) for skimmer to run.