Documentation ¶
Overview ¶
Package kaliber implements a server for the `Calibre` library software.
Copyright © 2019 M.Watermann, 10247 Berlin, Germany All rights reserved EMail : <support@mwat.de>
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the GNU General Public License along with this program. If not, see the [GNU General Public License](http://www.gnu.org/licenses/gpl.html) for details.
Index ¶
- Variables
- func AddUser(aUser, aFilename string)
- func CalibreCachePath() string
- func CalibreDatabaseName() string
- func CalibreDatabasePath() string
- func CalibreLibraryPath() string
- func CalibrePreferencesPath() string
- func CheckUser(aUser, aFilename string)
- func DBopen(aFilename string) error
- func DeleteUser(aUser, aFilename string)
- func GetVirtLibOptions(aSelected string) string
- func ListUser(aFilename string)
- func RemoveWhiteSpace(aPage []byte) []byte
- func SQLtraceFile() string
- func SetCalibreCachePath(aPath string) string
- func SetCalibreLibraryPath(aPath string) string
- func SetSQLtraceFile(aFilename string)
- func SetThumbWidth(aWidth uint) uint
- func ShowHelp()
- func ThumbWidth() uint
- func Thumbnail(aDoc *TDocument) (string, error)
- func ThumbnailName(aDoc *TDocument) string
- func ThumbnailRemove(aDoc *TDocument) error
- func ThumbnailUpdate()
- func URLparts(aURL string) (rDir, rPath string)
- func UpdateUser(aUser, aFilename string)
- type TDocList
- type TDocument
- func (doc *TDocument) Authors() *TEntityList
- func (doc *TDocument) Comment() template.HTML
- func (doc *TDocument) Cover() string
- func (doc *TDocument) DocLink() string
- func (doc *TDocument) Filename(aFormat string) string
- func (doc *TDocument) Filenames() *TPathList
- func (doc *TDocument) Files() *TEntityList
- func (doc *TDocument) Formats() *TEntityList
- func (doc *TDocument) Identifiers() *TEntityList
- func (doc *TDocument) Language() *TEntity
- func (doc *TDocument) PubDate() string
- func (doc *TDocument) Publisher() *TEntity
- func (doc *TDocument) Series() *TEntity
- func (doc *TDocument) SeriesIndex() string
- func (doc *TDocument) Tags() *TEntityList
- func (doc *TDocument) Thumb() string
- func (doc *TDocument) Timestamp() string
- type TEntity
- type TEntityList
- type TID
- type TPageHandler
- type TPathList
- type TQueryOptions
- func (qo *TQueryOptions) DecLimit() *TQueryOptions
- func (qo *TQueryOptions) IncLimit() *TQueryOptions
- func (qo *TQueryOptions) Scan(aString string) *TQueryOptions
- func (qo *TQueryOptions) SelectLanguageOptions() *TStringMap
- func (qo *TQueryOptions) SelectLayoutOptions() *TStringMap
- func (qo *TQueryOptions) SelectLimitOptions() *TStringMap
- func (qo *TQueryOptions) SelectOrderOptions() *TStringMap
- func (qo *TQueryOptions) SelectSortByOptions() *TStringMap
- func (qo *TQueryOptions) SelectThemeOptions() *TStringMap
- func (qo *TQueryOptions) SelectVirtLibOptions() string
- func (qo *TQueryOptions) String() string
- func (qo *TQueryOptions) Update(aRequest *http.Request) *TQueryOptions
- type TSearch
- type TStringMap
- type TView
- type TViewList
- type TVirtLibStruct
- type TemplateData
- type TvirtLibMap
Constants ¶
This section is empty.
Variables ¶
var ( // AppArguments is the merged list for the cmdline arguments // and INI values for the application. AppArguments tAguments )
Functions ¶
func AddUser ¶
func AddUser(aUser, aFilename string)
AddUser reads a password for `aUser` from the commandline and adds it to `aFilename`.
NOTE: This function does not return but terminates the program with error code `0` (zero) if successful, or `1` (one) otherwise.
`aUser` the username to add to the password file.
`aFilename` name of the password file to use.
func CalibreCachePath ¶
func CalibreCachePath() string
CalibreCachePath returns the directory of the copied `Calibre` databse.
func CalibreDatabaseName ¶
func CalibreDatabaseName() string
CalibreDatabaseName returns the name of the `Calibre` database.
func CalibreDatabasePath ¶
func CalibreDatabasePath() string
CalibreDatabasePath returns rhe complete path-/filename of the `Calibre` library.
func CalibreLibraryPath ¶
func CalibreLibraryPath() string
CalibreLibraryPath returns the base directory of the `Calibre` library.
func CalibrePreferencesPath ¶ added in v0.7.0
func CalibrePreferencesPath() string
CalibrePreferencesPath returns rhe complete path-/filename of the `Calibre` library's preferences file.
func CheckUser ¶
func CheckUser(aUser, aFilename string)
CheckUser reads a password for `aUser` from the commandline and compares it with the one stored in `aFilename`.
NOTE: This function does not return but terminates the program with error code `0` (zero) if successful, or `1` (one) otherwise.
`aUser` the username to check in the password file.
`aFilename` name of the password file to use.
func DBopen ¶
DBopen establishes a new database connection.
`aFilename` is the path-/filename of the SQLite database to use.
func DeleteUser ¶
func DeleteUser(aUser, aFilename string)
DeleteUser removes the entry for `aUser` from the password list `aFilename`.
NOTE: This function does not return but terminates the program with error code `0` (zero) if successful, or `1` (one) otherwise.
`aUser` the username to remove from the password file.
`aFilename` name of the password file to use.
func GetVirtLibOptions ¶ added in v0.7.0
GetVirtLibOptions returns the SELECT/OPTIONs of virtual libraries.
func ListUser ¶
func ListUser(aFilename string)
ListUser reads `aFilename` and lists all users stored in there.
NOTE: This function does not return but terminates the program with error code `0` (zero) if successful, or `1` (one) otherwise.
`aFilename` name of the password file to use.
func RemoveWhiteSpace ¶
RemoveWhiteSpace removes HTML comments and unnecessary whitespace.
This function removes all unneeded/redundant whitespace and HTML comments from the given <tt>aPage</tt>. This can reduce significantly the amount of data to send to the remote user agent thus saving bandwidth.
func SQLtraceFile ¶ added in v0.4.7
func SQLtraceFile() string
SQLtraceFile returns the optional file used for logging all SQL queries.
func SetCalibreCachePath ¶
SetCalibreCachePath sets the directory of the `Calibre` database copy.
func SetCalibreLibraryPath ¶
SetCalibreLibraryPath sets the base directory of the `Calibre` library.
func SetSQLtraceFile ¶ added in v0.4.7
func SetSQLtraceFile(aFilename string)
SetSQLtraceFile sets the filename to use for logging SQL queries.
If the provided `aFilename` is empty the SQL logging gets disabled.
`aFilename` the tracefile to use; if empty tracing is disabled.
func SetThumbWidth ¶ added in v0.2.0
SetThumbWidth set the new width for generated thumbnails.
If `aWidth` is smaller than `64` it's increased.
func ThumbWidth ¶ added in v0.2.0
func ThumbWidth() uint
ThumbWidth returns the configured width of generated thumbnails.
func ThumbnailName ¶ added in v0.2.0
ThumbnailName returns the name of thumbnail file of `aDoc`.
func ThumbnailRemove ¶ added in v0.2.0
ThumbnailRemove deletes the thumbnail of `aDoc`.
func ThumbnailUpdate ¶ added in v0.2.0
func ThumbnailUpdate()
ThumbnailUpdate creates thumbnails for all existing documents
func URLparts ¶
URLparts returns two parts: `rDir` holds the base-directory of `aURL`, `rPath` holds the remaining part of `aURL`.
Depending on the actual value of `aURL` both return values may be empty or both may be filled; none of both will hold a leading slash.
func UpdateUser ¶
func UpdateUser(aUser, aFilename string)
UpdateUser reads a password for `aUser` from the commandline and updates the entry in the password list `aFilename`.
NOTE: This function does not return but terminates the program with error code `0` (zero) if successful, or `1` (one) otherwise.
`aUser` the username to remove from the password file.
`aFilename` name of the password file to use.
Types ¶
type TDocList ¶
type TDocList []TDocument
TDocList is a list of `TDocument` instances.
func QueryBy ¶
func QueryBy(aOption *TQueryOptions) (rCount int, rList *TDocList, rErr error)
QueryBy returns all documents according to `aOption`.
func QueryIDs ¶ added in v0.2.0
QueryIDs returns a list of documents with only the `ID` and `path` fields set. This function is used `thumbnails`.
func QuerySearch ¶
func QuerySearch(aOption *TQueryOptions) (rCount int, rList *TDocList, rErr error)
QuerySearch returns a list of documents
type TDocument ¶
type TDocument tDocument
TDocument represents a single document (e.g. book)
func QueryDocMini ¶
QueryDocMini returns the document identified by `aID`.
This function fills only the document fields `ID`, `formats`, `path`, and `Title`.
func QueryDocument ¶
QueryDocument returns the `TDocument` identified by `aID`.
func (*TDocument) Authors ¶
func (doc *TDocument) Authors() *TEntityList
Authors returns a list of ID/Name author fields.
func (*TDocument) Cover ¶
Cover returns the absolute URL path-filename of the document's cover image.
func (*TDocument) Files ¶
func (doc *TDocument) Files() *TEntityList
Files returns a list of ID/Name/URL fields for doc format files.
func (*TDocument) Formats ¶
func (doc *TDocument) Formats() *TEntityList
Formats returns a list of ID/Name/URL fields for doc formats.
func (*TDocument) Identifiers ¶
func (doc *TDocument) Identifiers() *TEntityList
Identifiers returns a list of ID/Name/URL identifier fields.
func (*TDocument) SeriesIndex ¶
SeriesIndex returns the document's series index as formatted string.
func (*TDocument) Tags ¶
func (doc *TDocument) Tags() *TEntityList
Tags returns a list of ID/Name/URL tag fields.
type TPageHandler ¶
type TPageHandler struct {
// contains filtered or unexported fields
}
TPageHandler provides the handling of HTTP request/response.
func NewPageHandler ¶
func NewPageHandler() (*TPageHandler, error)
NewPageHandler returns a new `TPageHandler` instance.
func (*TPageHandler) Address ¶
func (ph *TPageHandler) Address() string
Address returns the configured `IP:Port` address to use for listening.
func (*TPageHandler) GetErrorPage ¶
func (ph *TPageHandler) GetErrorPage(aData []byte, aStatus int) []byte
GetErrorPage returns an error page for `aStatus`, implementing the `TErrorPager` interface.
func (*TPageHandler) NeedAuthentication ¶
func (ph *TPageHandler) NeedAuthentication(aRequest *http.Request) bool
NeedAuthentication returns `true` if authentication is needed, or `false` otherwise.
`aRequest` is the request to check.
func (TPageHandler) ServeHTTP ¶
func (ph TPageHandler) ServeHTTP(aWriter http.ResponseWriter, aRequest *http.Request)
ServeHTTP handles the incoming HTTP requests.
type TPathList ¶
type TPathList TStringMap
TPathList is a map of document formats holding the respective library file.
type TQueryOptions ¶
type TQueryOptions struct { ID TID // an entity ID to lookup Descending bool // sort direction Entity string // limiting query to a certain entity (author, publisher, series, tags) GuiLang uint8 // GUI language Layout uint8 // either `qoLayoutList` or `qoLayoutGrid` LimitLength uint // number of documents per page LimitStart uint // starting number Matching string // text to lookup in all documents QueryCount uint // number of DB records matching the query options SortBy uint8 // display order of documents (`qoSortByXXX`) Theme uint8 // CSS presentation theme VirtLib string // virtual libraries }
TQueryOptions hold properties configuring a query.
This type is used by the HTTP pagehandler when receiving a page's data.
func NewQueryOptions ¶
func NewQueryOptions() *TQueryOptions
NewQueryOptions returns a new `TQueryOptions` instance.
func (*TQueryOptions) DecLimit ¶
func (qo *TQueryOptions) DecLimit() *TQueryOptions
DecLimit decrements the LIMIT values.
func (*TQueryOptions) IncLimit ¶
func (qo *TQueryOptions) IncLimit() *TQueryOptions
IncLimit increments the LIMIT values.
func (*TQueryOptions) Scan ¶
func (qo *TQueryOptions) Scan(aString string) *TQueryOptions
Scan returns the options read from `aString`.
func (*TQueryOptions) SelectLanguageOptions ¶ added in v0.5.1
func (qo *TQueryOptions) SelectLanguageOptions() *TStringMap
SelectLanguageOptions returns a list of two SELECT/OPTIONs.
func (*TQueryOptions) SelectLayoutOptions ¶ added in v0.3.0
func (qo *TQueryOptions) SelectLayoutOptions() *TStringMap
SelectLayoutOptions returns a list of SELECT/OPTIONs.
func (*TQueryOptions) SelectLimitOptions ¶
func (qo *TQueryOptions) SelectLimitOptions() *TStringMap
SelectLimitOptions returns a list of SELECT/OPTIONs.
func (*TQueryOptions) SelectOrderOptions ¶
func (qo *TQueryOptions) SelectOrderOptions() *TStringMap
SelectOrderOptions returns a list of SELECT/OPTIONs.
func (*TQueryOptions) SelectSortByOptions ¶
func (qo *TQueryOptions) SelectSortByOptions() *TStringMap
SelectSortByOptions returns a list of SELECT/OPTIONs.
func (*TQueryOptions) SelectThemeOptions ¶ added in v0.5.0
func (qo *TQueryOptions) SelectThemeOptions() *TStringMap
SelectThemeOptions returns a list of two SELECT/OPTIONs.
func (*TQueryOptions) SelectVirtLibOptions ¶ added in v0.7.0
func (qo *TQueryOptions) SelectVirtLibOptions() string
SelectVirtLibOptions returns the SELECT/OPTIONs of virtual libraries.
func (*TQueryOptions) String ¶
func (qo *TQueryOptions) String() string
String returns the options as a `|` delimited string.
func (*TQueryOptions) Update ¶
func (qo *TQueryOptions) Update(aRequest *http.Request) *TQueryOptions
Update returns a `TQueryOptions` instance with updated values read from the `aRequest` data.
type TSearch ¶
type TSearch struct {
// contains filtered or unexported fields
}
TSearch provides text search capabilities.
type TStringMap ¶
TStringMap is a map of strings indexed by string.
type TView ¶
type TView struct {
// contains filtered or unexported fields
}
TView combines a template and its logical name.
func NewView ¶
NewView returns a new `TView` with `aName`.
`aBaseDir` is the path to the directory storing the template files.
`aName` is the name of the template file providing the page's main body without the filename extension (i.e. w/o ".gohtml"). `aName` serves as both the main template's name as well as the view's name.
func (*TView) Render ¶
func (v *TView) Render(aWriter http.ResponseWriter, aData *TemplateData) error
Render executes the template using the TView's properties.
`aWriter` is a http.ResponseWriter, or e.g. `os.Stdout` in console apps.
`aData` is a list of data to be injected into the template.
If an error occurs executing the template or writing its output, execution stops, and the method returns without writing anything to the output `aWriter`.
func (*TView) RenderedPage ¶
func (v *TView) RenderedPage(aData *TemplateData) (rBytes []byte, rErr error)
RenderedPage returns the rendered template/page and a possible Error executing the template.
`aData` is a list of data to be injected into the template.
type TViewList ¶
type TViewList tViewList
TViewList is a list of `TView` instances (to be used as a template pool).
func NewViewList ¶
func NewViewList() *TViewList
NewViewList returns a new (empty) `TViewList` instance.
func (*TViewList) Add ¶
Add appends `aView` to the list.
`aView` is the view to add to this list.
The view's name (as specified in the `NewView()` function call) is used as the view's key in this list.
func (*TViewList) Get ¶
Get returns the view with `aName`.
`aName` is the name (key) of the `TView` object to retrieve.
If `aName` doesn't exist, the return value is `nil`. The second value (ok) is a `bool` that is `true` if `aName` exists in the list, and `false` if not.
func (*TViewList) Render ¶
func (vl *TViewList) Render(aName string, aWriter http.ResponseWriter, aData *TemplateData) error
Render executes the template with the key `aName`.
`aName` is the name of the template/view to use.
`aWriter` is a `http.ResponseWriter` to handle the executed template.
`aData` is a list of data to be injected into the template.
If an error occurs executing the template or writing its output, execution stops, and the method returns without writing anything to the output `aWriter`.
func (*TViewList) RenderedPage ¶
func (vl *TViewList) RenderedPage(aName string, aData *TemplateData) (rBytes []byte, rErr error)
RenderedPage returns the rendered template/page with the key `aName`.
`aName` is the name of the template/view to use.
`aData` is a list of data to be injected into the template.
type TVirtLibStruct ¶ added in v0.7.0
TVirtLibStruct is a structure to hold a virtual library definition.
type TemplateData ¶
type TemplateData map[string]interface{}
TemplateData is a list of values to be injected into a template.
func NewTemplateData ¶
func NewTemplateData() *TemplateData
NewTemplateData returns a new (empty) `TDataList` instance.
func (*TemplateData) Set ¶
func (dl *TemplateData) Set(aKey string, aValue interface{}) *TemplateData
Set inserts `aValue` identified by `aKey` to the list.
If there's already a list entry with `aKey` its current value gets replaced by `aValue`.
`aKey` is the values's identifier (as used as placeholder in the template).
`aValue` contains the data entry's value.
type TvirtLibMap ¶ added in v0.7.0
type TvirtLibMap map[string]TVirtLibStruct
TvirtLibMap is a list of virt.lib. definitions
func GetVirtLibList ¶ added in v0.7.0
func GetVirtLibList() (*TvirtLibMap, error)
GetVirtLibList returns a list of virtual library definitions and SQL code to access them.