Documentation ¶
Overview ¶
Package config abstracts all program configuration.
Index ¶
- Constants
- func CleanFileName(in string) string
- func EnableColorOutput(stream *os.File) bool
- func FindConverter(_ string) string
- type AuthorName
- type Config
- func (conf *Config) GetActualBytes() ([]byte, error)
- func (conf *Config) GetBytes() ([]byte, error)
- func (conf *Config) GetKindlegenPath() (string, error)
- func (conf *Config) GetOverwrite(name string) *MetaInfo
- func (conf *Config) GetTransformation(name string) *Transformation
- func (conf *Config) PrepareLog() (*zap.Logger, error)
- type Doc
- type Fb2Epub
- type Fb2Mobi
- type Logger
- type MetaInfo
- type SMTPConfig
- type Transformation
Constants ¶
const ( MhlNone int = iota MhlEpub MhlMobi MhlUnknown )
Internal constants defining if program was invoked via MyHomeLib wrappers.
const ( VigBeforeTitle = "before_title" VigAfterTitle = "after_title" VigChapterEnd = "chapter_end" )
names of supported vignettes
Variables ¶
This section is empty.
Functions ¶
func CleanFileName ¶
CleanFileName removes not allowed characters form file name.
func EnableColorOutput ¶
EnableColorOutput checks if colorized output is possible.
func FindConverter ¶
FindConverter - used on Windows to support myhomelib
Types ¶
type AuthorName ¶
type AuthorName struct { First string `json:"first_name"` Middle string `json:"middle_name"` Last string `json:"last_name"` }
AuthorName is parsed author name from book metainfo.
func (*AuthorName) String ¶
func (a *AuthorName) String() string
type Config ¶
type Config struct { // Internal implementation - keep it local, could be replaced Path string // Actual configuration used everywhere - immutable ConsoleLogger Logger FileLogger Logger Doc Doc SMTPConfig SMTPConfig Fb2Mobi Fb2Mobi Fb2Epub Fb2Epub Overwrites map[string]MetaInfo // contains filtered or unexported fields }
Config keeps all configuration values.
func BuildConfig ¶
BuildConfig loads configuration.
func (*Config) GetActualBytes ¶
GetActualBytes returns actual configuration, including fields initialized by default.
func (*Config) GetBytes ¶
GetBytes returns configuration the way it was read from various sources, before unmarshaling.
func (*Config) GetKindlegenPath ¶
GetKindlegenPath provides platform specific path to the kindlegen executable.
func (*Config) GetOverwrite ¶
GetOverwrite returns pointer to information to be used instead of parsed data.
func (*Config) GetTransformation ¶
func (conf *Config) GetTransformation(name string) *Transformation
GetTransformation returns pointer to named text transformation of nil if none eavailable.
type Doc ¶
type Doc struct { TitleFormat string `json:"title_format"` AuthorFormat string `json:"author_format"` AuthorFormatMeta string `json:"author_format_meta"` AuthorFormatFileName string `json:"author_format_file_name"` TransliterateMeta bool `json:"transliterate_meta"` OpenFromCover bool `json:"open_from_cover"` ChapterPerFile bool `json:"chapter_per_file"` ChapterLevel int `json:"chapter_level"` SeqNumPos int `json:"series_number_positions"` RemovePNGTransparency bool `json:"remove_png_transparency"` ImagesScaleFactor float64 `json:"images_scale_factor"` Stylesheet string `json:"style"` CharsPerPage int `json:"characters_per_page"` PagesPerFile int `json:"pages_per_file"` ChapterDividers []string `json:"chapter_subtitle_dividers"` Hyphenate bool `json:"insert_soft_hyphen"` NoNBSP bool `json:"ignore_nonbreakable_space"` UseBrokenImages bool `json:"use_broken_images"` FileNameFormat string `json:"file_name_format"` FileNameTransliterate bool `json:"file_name_transliterate"` FixZip bool `json:"fix_zip_format"` // DropCaps struct { Create bool `json:"create"` IgnoreSymbols string `json:"ignore_symbols"` } `json:"dropcaps"` Notes struct { BodyNames []string `json:"body_names"` Mode string `json:"mode"` Renumber bool `json:"renumber"` Format string `json:"link_format"` } `json:"notes"` Annotation struct { Create bool `json:"create"` AddToToc bool `json:"add_to_toc"` Title string `json:"title"` } `json:"annotation"` TOC struct { Type string `json:"type"` Title string `json:"page_title"` Placement string `json:"page_placement"` MaxLevel int `json:"page_maxlevel"` NoTitleChapters bool `json:"include_chapters_without_title"` BookTitleFromMeta bool `json:"book_title_from_meta"` } `json:"toc"` Cover struct { Default bool `json:"default"` ImagePath string `json:"image_path"` Width int `json:"width"` Height int `json:"height"` Resize string `json:"resize"` Placement string `json:"stamp_placement"` Font string `json:"stamp_font"` } `json:"cover"` Vignettes struct { Create bool `json:"create"` Images map[string]map[string]string `json:"images"` } `json:"vignettes"` // Transformations map[string]map[string]string `json:"transform"` // Kindlegen struct { Path string `json:"path"` CompressionLevel int `json:"compression_level"` Verbose bool `json:"verbose"` NoOptimization bool `json:"no_mobi_optimization"` RemovePersonal bool `json:"remove_personal_label"` PageMap string `json:"generate_apnx"` ForceASIN bool `json:"force_asin_on_azw3"` } `json:"kindlegen"` }
Doc format configuration for book processor.
type Fb2Epub ¶
type Fb2Epub struct {
OutputFormat string `json:"output_format"`
}
Fb2Epub provides special support for MyHomeLib.
type Fb2Mobi ¶
type Fb2Mobi struct { OutputFormat string `json:"output_format"` SendToKindle bool `json:"send_to_kindle"` }
Fb2Mobi provides special support for MyHomeLib.
type Logger ¶
type Logger struct { Level string `json:"level"` Destination string `json:"destination"` Mode string `json:"mode"` }
Logger configuration for single logger.
type MetaInfo ¶
type MetaInfo struct { ID string `json:"id"` ASIN string `json:"asin"` Title string `json:"title"` Lang string `json:"language"` Genres []string `json:"genres"` Authors []*AuthorName `json:"authors"` SeqName string `json:"sequence"` SeqNum int `json:"sequence_number"` Date string `json:"date"` CoverImage string `json:"cover_image"` }
MetaInfo keeps book meta-info overwrites from configuration.
type SMTPConfig ¶
type SMTPConfig struct { DeleteOnSuccess bool `json:"delete_sent_book"` Server string `json:"smtp_server"` Port int `json:"smtp_port"` User string `json:"smtp_user"` Password string `json:"smtp_password"` From string `json:"from_mail"` To string `json:"to_mail"` }
SMTPConfig keeps STK configuration.
func (*SMTPConfig) IsValid ¶
func (c *SMTPConfig) IsValid() bool
IsValid checks if we have enough smtp parameters to attempt sending mail. It does not attempt actual connection.
type Transformation ¶
Transformation is used to specify additional text processsing during conversion.