Documentation
¶
Overview ¶
Package endive is the root package of endive.
It defines the main interfaces. It manages the configuration file and also deals with the internal database of already imported files (tracked through their SHA256 hashes). It also contains functions that are used by other endive subpackages.
Index ¶
- Constants
- func AskForISBN(ui i.UserInterface) (string, error)
- func CleanISBN(full string) (isbn13 string, err error)
- func GetArchiveUniqueName(filename string) (archive string, err error)
- func GetConfigPath() (configFile string, err error)
- func GetIndexPath() (path string)
- func GetKnownHashesPath() (hashesFile string, err error)
- func RemoveLock() (err error)
- func SetLock() (err error)
- func TabulateMap(input map[string]int, firstHeader string, secondHeader string) (table string)
- func TabulateRows(rows [][]string, headers ...string) (table string)
- type Collection
- type Config
- type Database
- type EpubCandidate
- type EpubCandidates
- type Error
- type GenericBook
- type Indexer
- type KnownHashes
Constants ¶
const ( // Endive is the name of this program. Endive = "endive" // XdgLogPath is the path for the main log file. XdgLogPath = Endive + "/" + Endive + ".log" // XdgLockPath is the path for the db lock. XdgLockPath = Endive + "/" + Endive + ".lock" // XdgArchiveDir is the path where database archives are kept XdgArchiveDir = Endive + "/archives/" )
const ( // EpubExtension is the lowercase extension for all epubs. EpubExtension = ".epub" // True as string True = "true" // False as string False = "false" // EmptyIndexError for Indexer EmptyIndexError = "Index is empty" )
Variables ¶
This section is empty.
Functions ¶
func AskForISBN ¶
func AskForISBN(ui i.UserInterface) (string, error)
AskForISBN when not found in epub
func GetArchiveUniqueName ¶
GetArchiveUniqueName in the endive archive directory.
func GetConfigPath ¶
GetConfigPath gets the default path for configuration.
func GetKnownHashesPath ¶
GetKnownHashesPath gets the default path for known hashes.
func TabulateMap ¶
TabulateMap of map[string]int.
func TabulateRows ¶
TabulateRows of map[string]int.
Types ¶
type Collection ¶
type Collection interface { // contents Books() []GenericBook Add(...GenericBook) Propagate(i.UserInterface, Config) RemoveByID(int) error Diff(Collection, Collection, Collection, Collection) // Check() error // search FindByID(int) (GenericBook, error) FindByHash(string) (GenericBook, error) FindByMetadata(string, string, string) (GenericBook, error) FindByFullPath(string) (GenericBook, error) // extracting information Retail() Collection NonRetailOnly() Collection Exported() Collection Progress(string) Collection Incomplete() Collection WithID(...int) Collection Authors() map[string]int Publishers() map[string]int Tags() map[string]int Series() map[string]int // output Table() string Sort(string) First(int) Collection Last(int) Collection }
Collection interface for slices of Books
type Config ¶
type Config struct { Filename string DatabaseFile string LibraryRoot string RetailSource []string NonRetailSource []string EpubFilenameFormat string AuthorAliases map[string][]string TagAliases map[string][]string PublisherAliases map[string][]string EReaderMountPoint string GoodReadsAPIKey string }
Config holds all relevant information
func (*Config) Check ¶
Check if the paths in the configuration file are valid, and if the EpubFilename Format is ok.
func (*Config) ListAuthorAliases ¶
ListAuthorAliases from the configuration file.
type Database ¶
type Database interface { SetPath(string) Path() string Equals(Database) bool Load(Collection) error Save(Collection) (bool, error) Backup(string) error }
Database is the interface for loading/saving Book information
type EpubCandidate ¶
EpubCandidate for import/export/refresh
func NewCandidate ¶
func NewCandidate(filename string, knownHashes KnownHashes, collection Collection) *EpubCandidate
NewCandidate returns a filled epubCandidate struct
func ScanForEpubs ¶
func ScanForEpubs(root string, knownHashes KnownHashes, collection Collection) ([]EpubCandidate, error)
ScanForEpubs recursively in folder.
func (EpubCandidate) String ¶
func (c EpubCandidate) String() string
String representation for EpubCandidate
type EpubCandidates ¶
type EpubCandidates []EpubCandidate
EpubCandidates is a slice of EpubCandidates.
func (EpubCandidates) Importable ¶
func (c EpubCandidates) Importable() EpubCandidates
Importable EpubCandidate-s in EpubCandidates
func (EpubCandidates) Missing ¶
func (c EpubCandidates) Missing() EpubCandidates
Missing EpubCandidate-s in EpubCandidates
func (EpubCandidates) New ¶
func (c EpubCandidates) New() EpubCandidates
New EpubCandidate-s in EpubCandidates
type Error ¶
type Error int
Error handles errors found in configuration
const ( ErrorConfigFileCreated Error = iota ErrorCannotLockDB ErrorLibraryRootDoesNotExist ErrorLibraryRootUnknown ErrorBadFormat WarningGoodReadsAPIKeyMissing WarningRetailSourceDoesNotExist WarningNonRetailSourceDoesNotExist )
Constant Error values which can be compared to determine the type of error
type GenericBook ¶
type GenericBook interface { ID() int HasHash(string) bool HasEpub() bool FullPath() string String() string CleanFilename() string Refresh() ([]bool, []string, error) AddEpub(string, bool, string) (bool, error) Check() (bool, bool, error) SetExported(bool) }
GenericBook interface for Books
type Indexer ¶
type Indexer interface { SetPath(path string) Rebuild(Collection) error Update(Collection, Collection, Collection) error Check(Collection) error Query(query string) ([]string, error) Count() uint64 }
Indexer provides an interface for indexing books.
type KnownHashes ¶
type KnownHashes struct { Filename string `json:"-"` Hashes []string `json:"hashes"` Count int `json:"-"` }
KnownHashes keeps track of the hashes of already imported epubs.
func (*KnownHashes) Add ¶
func (k *KnownHashes) Add(hash string) (added bool, err error)
Add a hash to the database.
func (*KnownHashes) IsIn ¶
func (k *KnownHashes) IsIn(hash string) (isIn bool)
IsIn checks whether a hash is known.
func (*KnownHashes) Save ¶
func (k *KnownHashes) Save() (modified bool, err error)
Save the known hashes database.