internal

package
v0.0.0-...-8e98a47 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeyCell -
	KeyCell = iota
	// ActionCell -
	ActionCell
)

Variables

View Source
var Version string

Version is version of the application

Functions

func CopyFile

func CopyFile(src, dst string) (int64, error)

copy file from src to dst

func GetTime

func GetTime(ts string) string

GetTime returns the timestring formatted as (%h%m < 24 hours < %d)

Types

type Article

type Article struct {
	// contains filtered or unexported fields
}

Article holds the content of a feed item

type Command

type Command struct {
	Key  string
	Cmd  string
	Args string
}

Command is used to parse a custom key->command from configuration file.

type Config

type Config struct {
	Highlights                    []string      `json:"highlights"`
	InputFeeds                    []interface{} `json:"feeds"`
	Feeds                         []Feed        `json:"-"`
	OPMLFile                      string        `json:"opmlFile"`
	FeedWindowSizeRatio           int           `json:"feedWindowSizeRatio"`
	ArticleWindowSizeRatio        int           `json:"articleWindowSizeRatio"`
	PreviewWindowSizeRatio        int           `json:"previewWindowSizeRatio"`
	ArticlePreviewWindowSizeRatio int           `json:"articlePreviewWindowSizeRatio"`
	SecondsBetweenUpdates         int           `json:"secondsBetweenUpdates"`
	SkipArticlesOlderThanDays     int           `json:"skipArticlesOlderThanDays"`
	DaysToKeepDeletedArticlesInDB int           `json:"daysToKeepDeletedArticlesInDB"`
	DaysToKeepReadArticlesInDB    int           `json:"daysToKeepReadArticlesInDB"`
	SkipPreviewInTab              bool          `json:"skipPreviewInTab"`
	KeyOpenLink                   string        `json:"keyOpenLink"`
	KeyMarkLink                   string        `json:"keyMarkLink"`
	KeyOpenMarked                 string        `json:"keyOpenMarked"`
	KeyDeleteArticle              string        `json:"keyDeleteArticle"`
	KeyMoveDown                   string        `json:"keyMoveDown"`
	KeyMoveUp                     string        `json:"keyMoveUp"`
	KeyFeedDown                   string        `json:"keyFeedDown"`
	KeyFeedUp                     string        `json:"keyFeedUp"`
	KeySortByDate                 string        `json:"keySortByDate"`
	KeySortByTitle                string        `json:"keySortByTitle"`
	KeySortByUnread               string        `json:"keySortByUnread"`
	KeySortByFeed                 string        `json:"keySortByFeed"`
	KeyUpdateFeeds                string        `json:"keyUpdateFeeds"`
	KeyMarkAllRead                string        `json:"keyMarkAllRead"`
	KeyMarkAllReadFeed            string        `json:"keyMarkAllReadFeed"`
	KeyMarkAllUnread              string        `json:"keyMarkAllUnread"`
	KeyMarkAllUnreadFeed          string        `json:"keyMarkAllUnreadFeed"`
	KeyTogglePreview              string        `json:"keyTogglePreview"`
	KeySelectFeedWindow           string        `json:"keySelectFeedWindow"`
	KeySelectArticleWindow        string        `json:"keySelectArticleWindow"`
	KeySelectPreviewWindow        string        `json:"keySelectPreviewWindow"`
	KeyToggleHelp                 string        `json:"keyToggleHelp"`
	KeySwitchWindows              string        `json:"keySwitchWindows"`
	KeyQuit                       string        `json:"keyQuit"`
	KeyUndoLastRead               string        `json:"keyUndoLastRead"`
	KeySearchPromt                string        `json:"keySearchPromt"`
	// WebBrowser overrides the default program used to open links. Default one depends on the OS:
	// * `xdg-open` for Linux
	// * `url.dll,FileProtocolHandler` for Windows
	// * `open` for Darwin
	WebBrowser     string    `json:"webBrowser"`
	CustomCommands []Command `json:"customCommands"`
	Notifications  bool      `json:"notifications"`
}

Config load the configuration from JSON file

func LoadConfiguration

func LoadConfiguration(file string) Config

LoadConfiguration takes a filename (configuration) and loads it.

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller handles the logic and keep everything together

func (*Controller) GetArticleForSelection

func (c *Controller) GetArticleForSelection() *Article

GetArticleForSelection returns the article instance for the selected article in the aritcles table.

func (*Controller) GetArticlesFromDB

func (c *Controller) GetArticlesFromDB()

GetArticlesFromDB fetches all articles from the database

func (*Controller) GetConfigKeys

func (c *Controller) GetConfigKeys() map[string]string

GetConfigKeys creates a list of keys that we want to present in the help section.

func (*Controller) Init

func (c *Controller) Init(cfg, theme, db string)

Init initiates the controller with database handles etc. It also starts the update loop and window handling.

func (*Controller) Input

func (c *Controller) Input(e *tcell.EventKey) *tcell.EventKey

Input handles keystrokes

func (c *Controller) OpenLink(link string)

OpenLink opens a link in the default webbrowser.

func (*Controller) Quit

func (c *Controller) Quit()

Quit ends the application

func (*Controller) SelectArticle

func (c *Controller) SelectArticle(row, col int)

SelectArticle is used a hook for article selection

func (*Controller) SelectFeed

func (c *Controller) SelectFeed(row, col int)

SelectFeed is used as a callback for feed selection

func (*Controller) ShowArticles

func (c *Controller) ShowArticles(feed string)

ShowArticles lists all articles for the current feed

func (*Controller) ShowFeeds

func (c *Controller) ShowFeeds()

ShowFeeds updates the feeds window with the current feeds and statuses

func (*Controller) UpdateFeeds

func (c *Controller) UpdateFeeds()

UpdateFeeds updates the articles kept in the controller

func (*Controller) UpdateLoop

func (c *Controller) UpdateLoop()

UpdateLoop updates the feeds and windows

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB holds the database information

func (*DB) All

func (d *DB) All() []Article

All fetches all articles from the database

func (*DB) CleanupDB

func (d *DB) CleanupDB()

CleanupDB removes old and deleted articles

func (*DB) Delete

func (d *DB) Delete(a *Article)

Delete marks an article as deleted. Will not remove it from DB (see CleanupDB)

func (*DB) Init

func (d *DB) Init(c *Controller, dbFile string) error

Init setups the database and creates tables if needed.

func (*DB) MarkAllRead

func (d *DB) MarkAllRead(feed string)

MarkAllRead marks all articles in the database as read

func (*DB) MarkAllUnread

func (d *DB) MarkAllUnread(feed string)

MarkAllUnread marks all articles in the database as not read

func (*DB) MarkRead

func (d *DB) MarkRead(a *Article) error

MarkRead marks an article as read in the database

func (*DB) MarkUnread

func (d *DB) MarkUnread(a Article) error

MarkUnread marks an article as unread in the database

func (*DB) Save

func (d *DB) Save(a Article) error

Save adds a new article to database if the title doesn't already exists.

type Feed

type Feed struct {
	URL  string
	Name string
}

Feed -

type RSS

type RSS struct {
	// contains filtered or unexported fields
}

RSS structure for handle parsing of RSS/Atom feeds

func (*RSS) FetchURL

func (r *RSS) FetchURL(fp *gofeed.Parser, url string) (feed *gofeed.Feed, err error)

FetchURL fetches the feed URL and also fakes the user-agent to be able to retrieve data from sites like reddit.

func (*RSS) GetURLFromOPML

func (r *RSS) GetURLFromOPML(b opml.Outline) string

GetURLFromOPML retrieves any URL from the OPML object

func (*RSS) Init

func (r *RSS) Init(c *Controller)

Init reads an feed related configuration

func (*RSS) Update

func (r *RSS) Update()

Update fetches all articles for all feeds

type Theme

type Theme struct {
	FeedNames          []string `json:"feedNames"`
	Date               string   `json:"date"`
	Time               string   `json:"time"`
	ArticleBorder      string   `json:"articleBorder"`
	PreviewBorder      string   `json:"previewBorder"`
	FeedBorder         string   `json:"feedBorder"`
	ArticleBorderTitle string   `json:"articleBorderTitle"`
	FeedBorderTitle    string   `json:"feedBorderTitle"`
	PreviewBorderTitle string   `json:"previewBorderTitle"`
	Highlights         string   `json:"highlights"`
	TableHead          string   `json:"tableHead"`
	Title              string   `json:"title"`
	UnreadFeedName     string   `json:"unreadFeedName"`
	TotalColumn        string   `json:"totalColumn"`
	UnreadColumn       string   `json:"unreadColumn"`
	PreviewText        string   `json:"previewText"`
	PreviewLink        string   `json:"previewLink"`
	UnreadMarker       string   `json:"unreadMarker"`
	LinkMarker         string   `json:"linkMarker"`
	FeedIcon           string   `json:"feedIcon"`
	ArticleIcon        string   `json:"articleIcon"`
	PreviewIcon        string   `json:"previewIcon"`
	StatusBackground   string   `json:"statusBackground"`
	StatusText         string   `json:"statusText"`
	StatusKey          string   `json:"statusKey"`
	StatusBrackets     string   `json:"statusBrackets"`
}

Theme holds all colors for the theme

func LoadTheme

func LoadTheme(file string) Theme

LoadTheme loads a theme file and parses it.

type Window

type Window struct {
	// contains filtered or unexported fields
}

Window holds all information regarding the Window layout and functionality

func (*Window) AddPreview

func (w *Window) AddPreview(a *Article)

AddPreview shows an article in the preview window

func (*Window) AddToArticles

func (w *Window) AddToArticles(a *Article, markedWeb bool)

AddToArticles adds an article to the article window

func (*Window) AddToFeeds

func (w *Window) AddToFeeds(name, displayName string, unread, total int, ref *Article)

AddToFeeds add a new feed to the feed window

func (*Window) ArticlesHasFocus

func (w *Window) ArticlesHasFocus() bool

ArticlesHasFocus returns true if the aricles window has focus

func (*Window) AskQuit

func (w *Window) AskQuit()

AskQuit asks the user to quit or not.

func (*Window) ClearArticles

func (w *Window) ClearArticles()

ClearArticles resets the articles window

func (*Window) ClearFeeds

func (w *Window) ClearFeeds()

ClearFeeds resets the feed window

func (*Window) ClearPreview

func (w *Window) ClearPreview()

ClearPreview clears the preview window

func (*Window) Init

func (w *Window) Init(inputFunc func(*tcell.EventKey) *tcell.EventKey, c *Controller)

Init sets up all information regarding widgets

func (*Window) MoveDown

func (w *Window) MoveDown(focus tview.Primitive)

MoveDown handles a keypress for moving down in feeds/articles

func (*Window) MoveUp

func (w *Window) MoveUp(focus tview.Primitive)

MoveUp handles a keypress for moving up in feeds/articles

func (*Window) RegisterSelectedFeedFunc

func (w *Window) RegisterSelectedFeedFunc(f func(r, c int))

RegisterSelectedFeedFunc registers a hook function for selecting feed

func (*Window) RegisterSelectedFunc

func (w *Window) RegisterSelectedFunc(f func(r, c int))

RegisterSelectedFunc registers a hook function for selected article

func (*Window) RegisterSelectionChangedFunc

func (w *Window) RegisterSelectionChangedFunc(f func(r, c int))

RegisterSelectionChangedFunc registers a hook for change events for articles

func (*Window) Search

func (w *Window) Search()

Search asks the user to input search query

func (*Window) SelectArticleWindow

func (w *Window) SelectArticleWindow()

SelectArticleWindow selects the article window (focus)

func (*Window) SelectFeedWindow

func (w *Window) SelectFeedWindow()

SelectFeedWindow selects the feed window (focus)

func (*Window) SelectPreviewWindow

func (w *Window) SelectPreviewWindow()

SelectPreviewWindow selects the preview window (focus)

func (*Window) SetupWindow

func (w *Window) SetupWindow()

SetupWindow initiates the window layout

func (*Window) Start

func (w *Window) Start()

Start initiates the application for the window system and sets its root

func (*Window) StatusUpdate

func (w *Window) StatusUpdate()

StatusUpdate updates the status window with updated information

func (*Window) SwitchFocus

func (w *Window) SwitchFocus()

SwitchFocus switches the focus between windows in a round-robin manner

func (*Window) ToggleHelp

func (w *Window) ToggleHelp()

ToggleHelp shows/hides the keyboard shortchuts

func (*Window) TogglePreview

func (w *Window) TogglePreview()

TogglePreview shows/hides the preview window for an article

func (*Window) UpdateStatusTicker

func (w *Window) UpdateStatusTicker()

UpdateStatusTicker calls StatusUpdate periodically

Jump to

Keyboard shortcuts

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