Documentation
¶
Index ¶
- func StarString(rating float64) string
- func TagsForCategory(cachedTags string, category string) []string
- func ValidateRating(r float64) error
- type Book
- type DayActivity
- type Goal
- type JournalEntry
- type LabelCount
- type PageUpdate
- type ReadingSession
- type ReadingStats
- type SearchMode
- type SearchResult
- type Status
- type TimerState
- type UserBook
- type UserBookRead
- type WeeklyStats
- type YearSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StarString ¶ added in v0.4.1
StarString renders a 5-slot rating string.
func TagsForCategory ¶ added in v0.6.0
TagsForCategory extracts tag names for one category (e.g. "Genre", "Mood") from a Hardcover cached_tags JSON blob. Returns nil when the blob is empty or malformed.
func ValidateRating ¶ added in v0.4.1
ValidateRating validates a user rating value. Allowed values are 0 (unrated) or 0.5 increments from 0.5 to 5.0.
Types ¶
type Book ¶
type Book struct {
ID int
Title string
Authors []string
Pages int
Slug string
ImageURL string
Rating float64
RatingsCount int
ReviewsCount int
UsersCount int
UsersReadCount int
ReleaseDate string
CachedTags string // raw Hardcover cached_tags JSON (genres/moods/tags)
FeaturedSeries string
FeaturedSeriesPosition int
}
Book represents a book from Hardcover.
func (Book) AuthorString ¶
AuthorString returns authors joined by ", ".
type DayActivity ¶
type DayActivity struct {
Date time.Time
Minutes int
HasActivity bool // progress update or finished book that day (no timer minutes required)
}
DayActivity represents total reading minutes for a single day.
type Goal ¶ added in v0.6.0
type Goal struct {
ID int
Metric string // "books", "pages", ...
Target int
Progress float64 // current progress toward Target, maintained server-side
State string // "active", "completed", "failed"
StartDate time.Time
EndDate time.Time
}
Goal represents a Hardcover reading goal.
type JournalEntry ¶ added in v0.6.0
JournalEntry represents a Hardcover reading journal entry (the activity timeline that powers the heatmap).
type LabelCount ¶ added in v0.6.0
LabelCount is a generic label→count pair used by bar charts (books per year, genre breakdown, ...).
type PageUpdate ¶
type PageUpdate struct {
Absolute int // target page (if not relative)
Delta int // delta (if relative)
Relative bool // true if +N or -N
}
PageUpdate represents a parsed page update instruction.
func ParsePage ¶
func ParsePage(s string) (PageUpdate, error)
ParsePage parses a page string: "123", "+10", "-5".
func (PageUpdate) Resolve ¶
func (p PageUpdate) Resolve(currentPage, totalPages int) int
Resolve computes the final page number given the current page and total.
type ReadingSession ¶
type ReadingSession struct {
ID int
BookID int // 0 = no book associated
StartedAt time.Time
EndedAt *time.Time // nil = still running (should not be stored without end)
Notes string
BookTitle string // denormalized for display
}
ReadingSession represents a timed reading session stored locally.
func (ReadingSession) Duration ¶
func (s ReadingSession) Duration() time.Duration
Duration returns the session duration. Returns zero if EndedAt is nil.
type ReadingStats ¶ added in v0.6.0
type ReadingStats struct {
Year YearSummary
Goal *Goal // active "books" goal, nil when none
Months [12]int // books finished per month of Year (Jan=0)
Years []LabelCount // books finished per year, ascending
Ratings [10]int // count per half-star bucket: index i = (i+1)*0.5 stars
Genres []LabelCount // top genres across finished books, descending
Heatmap []DayActivity
Weekly WeeklyStats // timer minutes for the current week
}
ReadingStats bundles everything the stats view and `oku stats` display.
type SearchMode ¶
type SearchMode string
SearchMode represents a discovery intent in search.
const ( SearchModeBook SearchMode = "book" SearchModeAuthor SearchMode = "author" SearchModeGenre SearchMode = "genre" )
func ParseSearchMode ¶
func ParseSearchMode(raw string) (SearchMode, error)
ParseSearchMode parses a user-facing search mode value.
func (SearchMode) Description ¶
func (m SearchMode) Description() string
Description returns the applied discovery strategy.
func (SearchMode) Label ¶
func (m SearchMode) Label() string
Label returns a compact uppercase label suitable for badges.
func (SearchMode) Next ¶
func (m SearchMode) Next() SearchMode
Next cycles through modes in a deterministic order.
type SearchResult ¶
type SearchResult struct {
ID int
Title string
Authors []string
Pages int
Slug string
ImageURL string
Rating float64
Ratings int
}
SearchResult represents a book from the search API.
type Status ¶
type Status int
Status represents a user-book status on Hardcover.
func StatusFromString ¶
StatusFromString maps CLI aliases to status IDs.
type TimerState ¶
TimerState represents the currently running timer, stored as JSON in the state KV table.
type UserBook ¶
type UserBook struct {
ID int
BookID int
StatusID Status
Rating float64
Review string
ReviewedAt *time.Time
CurrentPage int
Book Book
UserBookReads []UserBookRead
UpdatedAt time.Time
}
UserBook represents the user's relationship with a book.
type UserBookRead ¶
type UserBookRead struct {
ID int
UserBookID int
ProgressPages int
StartedAt *time.Time
FinishedAt *time.Time
}
UserBookRead represents a reading session/progress entry.