Documentation ¶
Overview ¶
This package provides functions to download content from the https://lds.org and lookup scriptures, magazines, General Conference talks, and much more from the downloaded content. It exports a variety of functions to access all the content.
Index ¶
- Constants
- Variables
- func DlAndOpen(item Item) error
- func Open() error
- func Register(name string, src Source)
- func Search(item Item, keywords []string, c chan<- SearchResult)
- func SetReferenceParseReader(open QueryFileFunc)
- type Closer
- type Content
- type ContentParser
- type Contenter
- type Footnote
- type Item
- type Lang
- type Opener
- type ParagraphStyle
- type QueryFileFunc
- type Reference
- type SearchResult
- type SearchResults
- type Source
- type TextStyle
Constants ¶
const RootPath = "/"
Variables ¶
var DataDirectory = ".ldss"
var ErrNotFound error
Functions ¶
func Search ¶
func Search(item Item, keywords []string, c chan<- SearchResult)
func SetReferenceParseReader ¶
func SetReferenceParseReader(open QueryFileFunc)
Sets a function that will be called to get the ldss reference language file for a passed language. This will likely be from a file, but could be from another source, such as an embedded resource. This should not be set after the first call to Lookup()
Types ¶
type Content ¶
type Content string
Content pulled from a node in the SQlite database. Is the content of the node formatted as HTML
func (Content) Parse ¶
func (c Content) Parse() *ContentParser
func (Content) Search ¶
func (content Content) Search(keywords []string) SearchResult
Search the content for the given keywords and return a search result containing the verses in which the results were found and the a weighted score based on the number of occurrences.
TODO Give extra points to sequences of words in the correct order (ignoring punctuation)
type ContentParser ¶
type ContentParser struct {
// contains filtered or unexported fields
}
func (*ContentParser) NextParagraph ¶
func (c *ContentParser) NextParagraph() bool
func (*ContentParser) NextText ¶
func (c *ContentParser) NextText() bool
func (*ContentParser) ParagraphStyle ¶
func (c *ContentParser) ParagraphStyle() ParagraphStyle
func (*ContentParser) ParagraphVerse ¶
func (c *ContentParser) ParagraphVerse() int
func (*ContentParser) Text ¶
func (c *ContentParser) Text() string
func (*ContentParser) TextStyle ¶
func (c *ContentParser) TextStyle() TextStyle
type Footnote ¶
type Footnote struct { Item Item Name string `json:"name"` LinkName string `json:"linkName"` Content template.HTML `json:"content"` }
func (*Footnote) References ¶
type Item ¶
type Item interface { Name() string Children() []Item Path() string Lang() Lang Parent() Item Next() Item Prev() Item }
func AutoDownload ¶
Calls the open function and downloads any missing content if has not been downloaded yet. If it does download something, it will retry the open function repeatedly until it gets no download errors (or repeated ones). It provides information about these downloads and the final result through a series of messages from the returned channel.
func GenericNextPrevious ¶
Gets the next or previous sibling of an item using it's interface functions. Used to implement Next and Previous on the Item interface. Only pass -1 or 1 to direction.
type Lang ¶
func LookupLanguage ¶
LookupLanguage finds a language by any of the accepted methods, compares ID, Code, and InternalCode
type ParagraphStyle ¶
type ParagraphStyle int
const ( ParagraphStyleNormal ParagraphStyle = iota ParagraphStyleTitle ParagraphStyleChapter ParagraphStyleSummary )
func (ParagraphStyle) String ¶
func (p ParagraphStyle) String() string
type QueryFileFunc ¶
type Reference ¶
type Reference struct { Path string Lang Lang VerseSelected int VersesHighlighted []int VersesExtra []int Small, Name string Keywords []string }
func (Reference) Lookup ¶
Lookup finds an Item by it's path. Expects a fully qualified path. "/" will return the catalog. Will return an error if there is an error loading the item or it is not downloaded.
func (Reference) MarshalJSON ¶
type SearchResult ¶
type SearchResults ¶
type SearchResults []SearchResult
func SearchSort ¶
func SearchSort(item Item, keywords []string) SearchResults
func (SearchResults) Len ¶
func (r SearchResults) Len() int
func (SearchResults) Less ¶
func (r SearchResults) Less(i, j int) bool
func (SearchResults) Swap ¶
func (r SearchResults) Swap(i, j int)