Documentation
¶
Index ¶
- Constants
- func HumanizeDuration(duration time.Duration) string
- func HumanizeDurationShort(duration time.Duration) string
- func HumanizeInt(num int) string
- func NewChart(stats Stats, year int, filename string) error
- func SecondsToHoursString(seconds int) string
- func Sync(db KoboDatabase, storage Storage) error
- type JSONStorage
- func (s *JSONStorage) AddBookmark(bID, vID, cID, typeStr, path string, index, startOffset, endOffset int, ...)
- func (s *JSONStorage) AddContent(fn, title, author, url string, words int, book, finished bool, percent int)
- func (s *JSONStorage) AddDevice(device, model string)
- func (s *JSONStorage) AddEvent(fn, device, name string, t time.Time, duration int)
- func (s *JSONStorage) AddShelf(ID, name, internalName, shelfType string, isDeleted bool)
- func (s *JSONStorage) AddShelfContent(shelfName, fn string, isDeleted bool)
- func (s *JSONStorage) Bookmarks(cID string) []StorageBookmark
- func (s *JSONStorage) Contents() []StorageContent
- func (s *JSONStorage) Events(cID string) []StorageEvents
- func (s *JSONStorage) Save() error
- func (s *JSONStorage) ShelfContents(shelfName string) []StorageShelfContent
- func (s *JSONStorage) Shelfs() []StorageShelf
- type KoboBook
- type KoboBookPart
- type KoboBookmark
- type KoboDatabase
- type KoboEvent
- type KoboEventReadingSession
- type KoboEventType
- type KoboShelf
- type KoboShelfContent
- type MonthStats
- type Stats
- func (s Stats) ArticleSecondsReadWeek(year, week int) int
- func (s Stats) ArticlesFinishedMonth(year, month int) []*StatsBook
- func (s Stats) ArticlesFinishedYear(year int) []*StatsBook
- func (s Stats) ArticlesSecondsReadMonth(year, month int) int
- func (s Stats) ArticlesSecondsReadYear(year int) int
- func (s Stats) BooksFinishedMonth(year, month int) []*StatsBook
- func (s Stats) BooksFinishedYear(year int) []*StatsBook
- func (s Stats) BooksSecondsReadMonth(year, month int) int
- func (s Stats) BooksSecondsReadWeek(year, week int) int
- func (s Stats) BooksSecondsReadYear(year int) int
- type StatsBook
- func (b StatsBook) FirstReadTime() string
- func (b StatsBook) NumSessions() int
- func (b StatsBook) NumSessionsInMonth(year, month int) int
- func (b StatsBook) NumSessionsInYear(year int) int
- func (b StatsBook) ReadSeconds() int
- func (b StatsBook) ReadSecondsInMonth(year, month int) int
- func (b StatsBook) ReadSecondsInWeek(year int, week int) int
- func (b StatsBook) ReadSecondsInYear(year int) int
- type StatsBookmark
- type StatsRead
- type Statter
- type Storage
- type StorageBookmark
- type StorageContent
- type StorageDevice
- type StorageEvents
- type StorageShelf
- type StorageShelfContent
- type YearStats
Constants ¶
View Source
const (
StorageTimeFmt = "2006-01-02T15:04:05.000"
)
Variables ¶
This section is empty.
Functions ¶
func HumanizeDuration ¶
HumanizeDuration humanizes time.Duration output to a meaningful value, golang's default “time.Duration“ output is badly formatted and unreadable. From: https://gist.github.com/harshavardhana/327e0577c4fed9211f65
func HumanizeDurationShort ¶
func HumanizeInt ¶
HumanizeInt Based on https://github.com/dustin/go-humanize/blob/v1.0.1/comma.go#L15
func SecondsToHoursString ¶ added in v0.0.3
func Sync ¶
func Sync(db KoboDatabase, storage Storage) error
Types ¶
type JSONStorage ¶
type JSONStorage struct { DeviceMap map[string]StorageDevice `json:"devices"` ContentMap map[string]StorageContent `json:"contents"` EventMap map[string][]StorageEvents `json:"events"` // Extra data that may be interesting. TODO need to think about relating content across devices e.g. books with different CIDs, fine for stats but not for shelve content Shelf map[string]StorageShelf `json:"shelf"` ShelfContent map[string][]StorageShelfContent `json:"shelf_content"` Bookmark map[string][]StorageBookmark `json:"bookmark"` // contains filtered or unexported fields }
func (*JSONStorage) AddBookmark ¶
func (*JSONStorage) AddContent ¶
func (s *JSONStorage) AddContent(fn, title, author, url string, words int, book, finished bool, percent int)
func (*JSONStorage) AddDevice ¶
func (s *JSONStorage) AddDevice(device, model string)
func (*JSONStorage) AddEvent ¶
func (s *JSONStorage) AddEvent(fn, device, name string, t time.Time, duration int)
func (*JSONStorage) AddShelf ¶
func (s *JSONStorage) AddShelf(ID, name, internalName, shelfType string, isDeleted bool)
func (*JSONStorage) AddShelfContent ¶
func (s *JSONStorage) AddShelfContent(shelfName, fn string, isDeleted bool)
func (*JSONStorage) Bookmarks ¶
func (s *JSONStorage) Bookmarks(cID string) []StorageBookmark
func (*JSONStorage) Contents ¶
func (s *JSONStorage) Contents() []StorageContent
func (*JSONStorage) Events ¶
func (s *JSONStorage) Events(cID string) []StorageEvents
func (*JSONStorage) Save ¶
func (s *JSONStorage) Save() error
func (*JSONStorage) ShelfContents ¶
func (s *JSONStorage) ShelfContents(shelfName string) []StorageShelfContent
func (*JSONStorage) Shelfs ¶
func (s *JSONStorage) Shelfs() []StorageShelf
type KoboBook ¶
type KoboBook struct { ID string Title string Author string URL string Finished bool ProgressPercent int Parts map[string]KoboBookPart // IsBook true for book, false for Pocket IsBook bool }
func (KoboBook) TotalWords ¶
type KoboBookPart ¶
type KoboBookPart struct {
WordCount int
}
type KoboBookmark ¶
type KoboDatabase ¶
type KoboDatabase interface { Device() (string, string) Contents() ([]KoboBook, error) Events() ([]KoboEvent, error) Shelves() ([]KoboShelf, error) ShelfContents() ([]KoboShelfContent, error) Bookmarks() ([]KoboBookmark, error) Close() error }
func NewKoboDatabase ¶
func NewKoboDatabase(fn string) (KoboDatabase, error)
type KoboEvent ¶
type KoboEvent struct { // BookID is the filename or Pocket ID BookID string EventType KoboEventType Time time.Time ReadingSessions []KoboEventReadingSession }
KoboEvent minimal event for reading start/stop/session
type KoboEventReadingSession ¶
type KoboEventType ¶
type KoboEventType string
const ( KoboFilenamePrefix = "/mnt/onboard/" KoboTimeFmt = "2006-01-02T15:04:05.000" GuessReadEvent KoboEventType = "GuessRead" ReadEvent KoboEventType = "Read" Progress25Event KoboEventType = "25%" Progress50Event KoboEventType = "50%" Progress75Event KoboEventType = "75%" FinishEvent KoboEventType = "Finish" )
func (KoboEventType) String ¶
func (t KoboEventType) String() string
type KoboShelfContent ¶
type MonthStats ¶
type Stats ¶
type Stats struct { Years map[int]YearStats `json:"years"` Content map[string]StatsBook `json:"content"` }
func (Stats) ArticleSecondsReadWeek ¶ added in v0.0.3
func (Stats) ArticlesFinishedMonth ¶
func (Stats) ArticlesFinishedYear ¶
func (Stats) ArticlesSecondsReadMonth ¶
func (Stats) ArticlesSecondsReadYear ¶
func (Stats) BooksFinishedMonth ¶
func (Stats) BooksFinishedYear ¶
func (Stats) BooksSecondsReadMonth ¶
func (Stats) BooksSecondsReadWeek ¶ added in v0.0.3
func (Stats) BooksSecondsReadYear ¶
type StatsBook ¶
type StatsBook struct { BookID string `json:"id"` Title string `json:"title"` Author string `json:"author"` URL string `json:"url"` Words int `json:"words"` IsBook bool `json:"is_book"` IsFinished bool `json:"is_finished"` FinishedTime string `json:"finished_time"` Reads []StatsRead `json:"reads"` Bookmarks []StatsBookmark `json:"bookmarks"` }
func (StatsBook) FirstReadTime ¶
func (StatsBook) NumSessions ¶
func (StatsBook) NumSessionsInMonth ¶ added in v0.0.4
func (StatsBook) NumSessionsInYear ¶
func (StatsBook) ReadSeconds ¶
func (StatsBook) ReadSecondsInMonth ¶ added in v0.0.3
func (StatsBook) ReadSecondsInWeek ¶ added in v0.0.3
func (StatsBook) ReadSecondsInYear ¶
type StatsBookmark ¶
type StatsBookmark struct { ID string `json:"id,omitempty"` Index int `json:"idx,omitempty"` StartOffset int `json:"start_offset,omitempty"` EndOffset int `json:"end_offset,omitempty"` Text string `json:"text,omitempty"` Annotation string `json:"annotation,omitempty"` Created string `json:"created,omitempty"` Modified string `json:"modified,omitempty"` Type string `json:"type,omitempty"` }
type Statter ¶
type Statter interface { BooksFinishedYear(year int) []*StatsBook BooksFinishedMonth(year, month int) []*StatsBook ArticlesFinishedYear(year int) []*StatsBook ArticlesFinishedMonth(year, month int) []*StatsBook BooksSecondsReadYear(year int) int BooksSecondsReadMonth(year, month int) int ArticlesSecondsReadYear(year int) int ArticlesSecondsReadMonth(year, month int) int }
type Storage ¶
type Storage interface { Save() error AddContent(fn, title, author, url string, words int, book, finished bool, percent int) AddDevice(device, model string) AddEvent(fn, device, name string, t time.Time, duration int) AddShelf(ID, name, internalName, shelfType string, isDeleted bool) AddShelfContent(shelfName, fn string, isDeleted bool) Contents() []StorageContent Events(cID string) []StorageEvents Bookmarks(cID string) []StorageBookmark Shelfs() []StorageShelf ShelfContents(shelfName string) []StorageShelfContent AddBookmark(bID, vID, cID, typeStr, path string, index, startOffset, endOffset int, text, annotation string, created, modified time.Time) }
func OpenStorageOrCreate ¶
type StorageBookmark ¶
type StorageBookmark struct { ID string `json:"id,omitempty"` VolumeID string `json:"volume_id,omitempty"` ContentID string `json:"content_id,omitempty"` BookPath string `json:"book_path,omitempty"` Index int `json:"idx,omitempty"` StartOffset int `json:"start_offset,omitempty"` EndOffset int `json:"end_offset,omitempty"` Text string `json:"text,omitempty"` Annotation string `json:"annotation,omitempty"` Created string `json:"created,omitempty"` Modified string `json:"modified,omitempty"` Type string `json:"type,omitempty"` }
type StorageContent ¶
type StorageDevice ¶
type StorageEvents ¶
type StorageShelf ¶
type StorageShelfContent ¶
type YearStats ¶
type YearStats struct { Months map[int]MonthStats `json:"months"` Weeks map[int]MonthStats `json:"weeks"` }
Click to show internal directories.
Click to hide internal directories.