entities

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBookName added in v1.12.0

func BuildBookName(book *Book) (res string)

func BuildBookURL added in v1.12.0

func BuildBookURL(path, urlPrefix, pathPrefix string) string

func NewBookIndexMapping

func NewBookIndexMapping() *mapping.IndexMappingImpl

func ParseFB2 added in v1.12.0

func ParseFB2(reader io.Reader, encoder LibEncodeType,
	rules ...xmlparse.Rule,
) (res fb2.File, err error)

func ParseYear added in v1.12.0

func ParseYear(date string) (res uint16)

func SliceHasString added in v1.12.0

func SliceHasString(haystack []string, needle string) bool

func TransformStr added in v1.12.0

func TransformStr(vals ...string) string

Types

type Book added in v1.14.0

type Book struct {
	ID             string            `json:"id"`
	Offset         uint64            `json:"from,omitempty"`
	Size           uint64            `json:"size,omitempty"`
	SizeCompressed uint64            `json:"sizec,omitempty"`
	Lib            string            `json:"lib,omitempty"`
	Src            string            `json:"src,omitempty"`
	Info           BookMeta          `json:"info,omitempty"`
	OrigInfo       *BookMeta         `json:"oinfo,omitempty"`
	PublInfo       []BookPublisher   `json:"pinfo,omitempty"`
	Match          map[string]string `json:"-"`
}

func (*Book) Authors added in v1.14.0

func (b *Book) Authors() []string

func (*Book) Genres added in v1.14.0

func (b *Book) Genres() []string

func (*Book) Index added in v1.14.0

func (b *Book) Index() (res BookIndex)

func (*Book) ReadFB2 added in v1.14.0

func (b *Book) ReadFB2(data *fb2.File)

func (*Book) Series added in v1.14.0

func (b *Book) Series() []string

func (*Book) Titles added in v1.14.0

func (b *Book) Titles() []string

func (*Book) Translators added in v1.14.0

func (b *Book) Translators() []string

type BookIndex

type BookIndex struct {
	ID         string `json:"id,omitempty"`
	Year       uint16 `json:"year,omitempty"`
	ISBN       string `json:"isbn,omitempty"`
	Title      string `json:"title,omitempty"`
	Author     string `json:"auth,omitempty"`
	Translator string `json:"transl,omitempty"`
	Serie      string `json:"seq,omitempty"`
	Date       string `json:"date,omitempty"`
	Genre      string `json:"genre,omitempty"`
	Publisher  string `json:"publ,omitempty"`
	Lang       string `json:"lng,omitempty"`
	Keywords   string `json:"kwds,omitempty"`
	Lib        string `json:"lib,omitempty"`
}

type BookMeta added in v1.14.0

type BookMeta struct {
	Annotation  string      `json:"annot,omitempty"`
	Lang        string      `json:"lang,omitempty"`
	SrcLang     string      `json:"slang,omitempty"`
	Title       string      `json:"title,omitempty"`
	Keywords    string      `json:"kwds,omitempty"`
	Date        string      `json:"date,omitempty"`
	Genres      []string    `json:"genres,omitempty"`
	Authors     []string    `json:"auth,omitempty"`
	Translators []string    `json:"transl,omitempty"`
	Sequences   []string    `json:"seq,omitempty"`
	CoverID     string      `json:"cover,omitempty"`
	Cover       *fb2.Binary `json:"-"`
}

func NewBookMeta added in v1.14.0

func NewBookMeta(data []fb2.TitleInfo, bin []fb2.Binary) (res BookMeta)

type BookPublisher added in v1.14.0

type BookPublisher struct {
	Title     string   `json:"title,omitempty"`
	Publisher string   `json:"publ,omitempty"`
	Year      string   `json:"year,omitempty"`
	ISBN      string   `json:"isbn,omitempty"`
	Authors   []string `json:"auth,omitempty"`
	Sequences []string `json:"seqs,omitempty"`
}

func NewBookPublisher added in v1.14.0

func NewBookPublisher(data fb2.Publisher) (res BookPublisher)
type BreadCrumb struct {
	Title string
	Link  string
}
type BreadCrumbs []BreadCrumb
func (b BreadCrumbs) Push(title, link string) BreadCrumbs

type CntAtomic32

type CntAtomic32 uint32

func (*CntAtomic32) Inc

func (c *CntAtomic32) Inc(delta uint32) uint32

func (*CntAtomic32) Total

func (c *CntAtomic32) Total() uint32

type FreqsItems added in v1.14.0

type FreqsItems []ItemFreq

func (FreqsItems) Len added in v1.14.0

func (g FreqsItems) Len() int

func (FreqsItems) Less added in v1.14.0

func (g FreqsItems) Less(i, j int) bool

func (FreqsItems) Swap added in v1.14.0

func (g FreqsItems) Swap(i, j int)

type IBooksInfoRepo added in v1.12.0

type IBooksInfoRepo interface {
	io.Closer
	GetByID(bookID string) (*Book, error)
	FindBooks(queryStr string, idxField IndexField, idxFieldVal string, pager pagination.IPager) ([]Book, error)
	Remove(bookID string) error
	GetSeriesBooks(limit int, series []string, except *Book) (res []Book, err error)
	GetAuthorsBooks(limit int, authors []string, except *Book) (res []Book, err error)
	GetAuthorsSeries(authors []string, except []string) (res map[string]int, err error)
	GetBooksCnt() (uint64, error)
	GetAuthorsCnt() (uint64, error)
	GetGenresCnt() (uint64, error)
	GetSeriesCnt() (uint64, error)
	GetGenres(pager pagination.IPager) (FreqsItems, error)
	GetSeriesByChar(char rune) (FreqsItems, error)
	GetAuthorsByChar(char rune) (FreqsItems, error)
	SaveBook(book *Book) error
}

type IBooksLibraryRepo added in v1.12.0

type IBooksLibraryRepo interface {
	GetFB2(Book) (fb2.File, error)
}

type IMarshal added in v1.12.0

type IMarshal func(any) ([]byte, error)

type ISearchIndex

type ISearchIndex interface {
	io.Closer
	DocCount() (uint64, error)
	Search(req *bleve.SearchRequest) (*bleve.SearchResult, error)
	Index(id string, data interface{}) error
	Name() string
	NewBatch() *bleve.Batch
	Batch(b *bleve.Batch) error
	Delete(string) error
}

type IUnmarshal added in v1.12.0

type IUnmarshal func([]byte, any) error

type IndexField added in v1.14.0

type IndexField string
const (
	IdxFUndefined  IndexField = ""
	IdxFID         IndexField = "id"
	IdxFYear       IndexField = "year"
	IdxFISBN       IndexField = "isbn"
	IdxFTitle      IndexField = "title"
	IdxFAuthor     IndexField = "auth"
	IdxFTranslator IndexField = "transl"
	IdxFSerie      IndexField = "seq"
	IdxFDate       IndexField = "date"
	IdxFGenre      IndexField = "genre"
	IdxFPublisher  IndexField = "publ"
	IdxFLang       IndexField = "lng"
	IdxFKeywords   IndexField = "kwds"
	IdxFLib        IndexField = "lib"
)

type IndexRules added in v1.14.0

type IndexRules map[string]map[string]struct{}

func NewIndexRules added in v1.14.0

func NewIndexRules(cfgKey string, cfg *viper.Viper) (res IndexRules, err error)

func (IndexRules) Check added in v1.14.0

func (r IndexRules) Check(book *Book) error

type ItemFreq added in v1.14.0

type ItemFreq struct {
	Val  string `json:"val,omitempty"`
	Freq int    `json:"frq,omitempty"`
}

type ItemFreqMap added in v1.14.0

type ItemFreqMap map[string]ItemFreq

func (ItemFreqMap) Put added in v1.14.0

func (m ItemFreqMap) Put(val string, freq int)

type LibEncodeType added in v1.12.0

type LibEncodeType string
const (
	LibEncodeMarshaler LibEncodeType = "marshaler"
	LibEncodeParser    LibEncodeType = "parser"
)

type LibItem added in v1.13.0

type LibItem struct {
	Item string
	Lib  string
}

type Libraries added in v1.12.0

type Libraries map[string]Library

func NewLibraries added in v1.12.0

func NewLibraries(cfgKey string, cfg *viper.Viper) (Libraries, error)

func (*Libraries) GetItems added in v1.12.0

func (l *Libraries) GetItems() (res []LibItem, err error)

func (*Libraries) GetSize added in v1.12.0

func (l *Libraries) GetSize() (res int64)

type Library added in v1.12.0

type Library struct {
	Name     string
	Disabled bool          `mapstructure:"disabled"`
	Order    int           `mapstructure:"order"`
	Dir      string        `mapstructure:"dir"`
	Encoder  LibEncodeType `mapstructure:"encoder"`
	Types    []string      `mapstructure:"types"`
}

func (*Library) GetItems added in v1.12.0

func (l *Library) GetItems() (res []string, err error)

func (*Library) GetSize added in v1.12.0

func (l *Library) GetSize() int64

Jump to

Keyboard shortcuts

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