backend

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCacheDuration = 24 * time.Hour

DefaultCacheDuration is the default duration for which an item is cached

View Source
var DefaultCacheSize = 100

DefaultCacheSize is the default size of the cache

Functions

func DeleteItem

func DeleteItem(sender tab.Tab, key string) tea.Cmd

DeleteItem is a function to tell the main model that a new item needs to be removed from the list

func DownloadItem added in v1.1.0

func DownloadItem(key string, index int) tea.Cmd

DownloadItem is a function to tell the main model that a new item needs to be downloaded

func MakeChoice added in v1.3.0

func MakeChoice(question string, defaultChoice bool) tea.Cmd

MakeChoice is a function to tell the main model that a choice needs to be made

func NewItem

func NewItem(sender tab.Tab, editing bool, fields []string) tea.Cmd

NewItem is a function to tell the main model that a new item needs to be added to the list

Types

type Backend

type Backend struct {
	Rss   *rss.Rss
	Cache *Cache
}

Backend uses a local cache to get all the feeds and their articles

func New

func New(urlPath, cachePath string, resetCache bool) (*Backend, error)

New creates a new Cache Backend

func (Backend) Close

func (b Backend) Close() error

Close closes the backend

func (Backend) DownloadItem added in v1.1.0

func (b Backend) DownloadItem(key string, index int) tea.Cmd

DownloadItem returns a tea.Cmd which downloads an item

func (Backend) FetchAllArticles added in v1.0.2

func (b Backend) FetchAllArticles(_ string) tea.Cmd

FetchAllArticles returns a tea.Cmd which gets all the articles from the backend

func (Backend) FetchArticles

func (b Backend) FetchArticles(feedName string) tea.Cmd

FetchArticles returns a tea.Cmd which gets the articles from the backend via a string key

func (Backend) FetchCategories

func (b Backend) FetchCategories() tea.Cmd

FetchCategories returns a tea.Cmd which gets the category list from the backend

func (Backend) FetchDownloadedArticles added in v1.1.0

func (b Backend) FetchDownloadedArticles(_ string) tea.Cmd

FetchDownloaded returns a tea.Cmd which gets all the downloaded articles from the backend

func (Backend) FetchFeeds

func (b Backend) FetchFeeds(catName string) tea.Cmd

FetchFeeds returns a tea.Cmd which gets the feed list from the backend via a string key

func (Backend) RemoveDownload added in v1.2.0

func (b Backend) RemoveDownload(key string) error

RemoveDownload tries to remove a download from the backend

func (*Backend) SetOfflineMode added in v1.2.0

func (b *Backend) SetOfflineMode(mode bool)

SetOfflineMode sets the offline mode of the backend

type Cache

type Cache struct {
	Content    map[string]Entry `json:"content"`
	Downloaded SortableArticles `json:"downloaded"`
	// contains filtered or unexported fields
}

Cache handles the caching of feeds and storing downloaded articles

type DeleteItemMsg added in v1.3.0

type DeleteItemMsg struct {
	Sender tab.Tab
	Key    string
}

DeleteItemMsg is a message to tell the main model that a new item needs to be removed from the list

type DownloadItemMsg added in v1.3.0

type DownloadItemMsg struct {
	Key   string
	Index int
}

DownloadItemMsg is a message to tell the main model that a new item needs to be downloaded

type Entry added in v1.2.0

type Entry struct {
	Expire   time.Time        `json:"expire"`
	Articles SortableArticles `json:"articles"`
}

Entry is a cache entry

type FetchArticleSuccessMsg added in v1.3.0

type FetchArticleSuccessMsg struct {
	Items           []list.Item
	ArticleContents []string
}

FetchArticleSuccessMsg is a message that is sent when the fetching of the articles was successful

type FetchErrorMsg added in v1.3.0

type FetchErrorMsg struct {
	Description string
	Err         error
}

FetchErrorMsgssage that is sent when the fetching of the categories or feeds failed

type FetchSuccessMsg added in v1.3.0

type FetchSuccessMsg struct {
	Items []list.Item
}

FetchSuccessMsg is a message that is sent when the fetching of the categories or feeds was successful

type MakeChoiceMsg added in v1.3.0

type MakeChoiceMsg struct {
	Question string
	Default  bool
}

MakeChoiceMsg is a message to tell the main model that a choice needs to be made

type NewItemMsg added in v1.3.0

type NewItemMsg struct {
	Sender    tab.Tab
	Editing   bool
	OldFields []string
}

NewItemMsg is a message to tell the main model that a new item needs to be added to the list

type SortableArticles added in v1.2.0

type SortableArticles []gofeed.Item

SortableArticles is a sortable list of articles

func (SortableArticles) Len added in v1.2.0

func (sa SortableArticles) Len() int

Len returns the length of the item list, needed for sorting

func (SortableArticles) Less added in v1.2.0

func (sa SortableArticles) Less(a, b int) bool

Less returns true if the item at index i is less than the item at index j, needed for sorting

func (SortableArticles) Swap added in v1.2.0

func (sa SortableArticles) Swap(a, b int)

Swap swaps the items at index i and j, needed for sorting

Jump to

Keyboard shortcuts

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