Documentation ¶
Overview ¶
package core implements the structs and other necessary resources for storing and managing feeds and pages
Index ¶
- Variables
- func Init(dataPath string, localizer *localizations.Localizer, days int) error
- func TranslateString(template, localizerTag string, replacements *localizations.Replacements) string
- func TranslateStringLocalizer(localizer *localizations.Localizer, template, localizerTag string, ...) string
- type Feed
- type FullData
- func (d *FullData) InsertFeed(new *Feed, remote string)
- func (d *FullData) InsertPage(new *Page, remote string)
- func (j *FullData) Lock()
- func (j *FullData) RLock()
- func (j *FullData) RUnlock()
- func (j *FullData) Unlock()
- func (d *FullData) WriteFeed(dataPath string) error
- func (d *FullData) WriteJSON(dataPath string) error
- func (d *FullData) WriteSubs(dataPath string) error
- type Item
- type Page
- type PageEntries
- type PageEntry
Constants ¶
This section is empty.
Variables ¶
var ( Header string )
the Header and Footer of feeds.gmi. set in Init, either to the contents of header.gmi or to the default string
var ( Version = "Unknown" Commit = "Unknown" )
These variables are set by the linker. They can be modified in the Makefile.
Global instance of FullData
var HistoryDays time.Time
Number of days of history to keep
var Localizer *localizations.Localizer
var Timeout int
Timeout for requests
Functions ¶
func Init ¶
func Init(dataPath string, localizer *localizations.Localizer, days int) error
have to do this instead of the automatically called init() because initialization stuff requires parsing of command line args first
func TranslateString ¶ added in v1.7.0
func TranslateString(template, localizerTag string, replacements *localizations.Replacements) string
TranslateString takes a template string, a localizer tag, and a localizer replacement set and will get the localized string from the localizer tag, replace everything using the localizer replacements, and then substitute that string into the template string.
func TranslateStringLocalizer ¶ added in v1.7.0
func TranslateStringLocalizer(localizer *localizations.Localizer, template, localizerTag string, replacements *localizations.Replacements) string
TranslateStringLocalizer takes a localizations.Localizer, template string, a localizer tag, and a localizer replacement set and will get the localized string from the localizer tag, replace everything using the localizer replacements, and then substitute that string into the template string. Should not be used once core.Init() is called, instead use TranslateString().
Types ¶
type Feed ¶
type Feed struct { Title string `json:"title,omitempty"` Link string `json:"link,omitempty"` // link to the human-readable page for the feed. same as FeedLink for gemini feeds. FeedLink string `json:"feedlink,omitempty"` // link to the feed itself. Updated time.Time `json:"updated,omitempty"` Items []*Item `json:"items,omitempty"` }
Feed holds all the necessary fields when storing a feed
func GofeedConvert ¶
gofeedConvert converts a gofeed.Feed into a Feed struct
type FullData ¶
type FullData struct { Feeds map[string]*Feed `json:"feeds,omitempty"` Pages map[string]*Page `json:"pages,omitempty"` FeedsMu *sync.RWMutex `json:"-"` PagesMu *sync.RWMutex `json:"-"` }
FullData is used for both reading from json and for storing the global feeds map. contains read mutexes so concurrency can be used.
func (*FullData) InsertFeed ¶
InsertFeed will insert or update a core.Feed in a core.FullData
func (*FullData) InsertPage ¶
InsertPage will insert or update a core.Page in a core.FullData
func (*FullData) RUnlock ¶
func (j *FullData) RUnlock()
RUnlock read-unlocks both feed and page mutexes.
type Item ¶
type Item struct { Title string `json:"title,omitempty"` // if empty, use Link as title Content string `json:"content,omitempty"` Link string `json:"link,omitempty"` Published time.Time `json:"updated,omitempty"` }
Item is a single item from a subscripton
type Page ¶
type Page struct { Title string `json:"title,omitempty"` Link string `json:"link,omitempty"` Updated time.Time `json:"updated,omitempty"` Hash string `json:"hash,omitempty"` }
Page holds all the necessary fields when storing a page being watched for changes.
type PageEntries ¶
type PageEntries struct {
Entries []*PageEntry
}
PageEntries is reverse chronological list of entries used when generating subs.
func (*PageEntries) Less ¶
func (e *PageEntries) Less(i, j int) bool
Less compares the Published if Entries[i], Entries[j] and returns true if Entries[i] is /after/ Entries[j] (for reverse chronological sorting)
func (*PageEntries) Swap ¶
func (e *PageEntries) Swap(i, j int)
Swap swaps Entries[i] and Entries[j]