Major rewrite of the web reader to properly interface with
@bookhoard/foliate-js, replacing the abandoned panel-detection
architecture with direct pan and zoom support built into the
foliate-js FixedLayout renderer.
Template (reader.templ):
- Fix critical bug: x-init config was using literal strings
'{ readerData.X }' inside a quoted attribute, which templ
treated as raw text and never interpolated. Values were never
actually passed to JavaScript. Now uses fmt.Sprintf() with
templ's expression attribute syntax ={ }.
- Pass fileUrl from server so foliate-js can open books directly.
- Redesign bottom bar with foliate-js parity: left/right navigation
buttons, progress slider with tick marks, and zoom controls
(zoom out, percentage display, zoom in, magnifier, pan/select
mode toggle for PDFs).
- Remove panel editor button and enablePanelDetection config.
- Add SVG icon styles for consistent reader controls.
Go types (templates/types.go):
- Expand ReaderMetadata with FormatGroup, MangaType,
ReadingDirection, FileURL, and LibraryID fields needed by
the reader frontend.
Router (internal/router/reader.go):
- Populate new ReaderMetadata fields from database values.
- Construct FileURL from library ID and file path for the
/uploads/library-{id}/* file serving route.
Reader JS (reader.ts):
- Full rewrite modeled on foliate-js Reader class, adapted for
Alpine.js. Opens books via view.open(fileUrl), accesses
view.renderer for zoom/pan/navigation, and wires up keyboard
shortcuts (+/-/0 for zoom, arrows for nav, Escape for magnifier).
- Uses view.isFixedLayout instead of importing FixedLayout class,
avoiding a TypeScript module resolution issue with the Vite alias.
Settings manager (settings-manager.ts):
- Remove dependency on deleted ReaderContext event bus.
- Export loadSettings/saveSettings/syncSettings directly as
standalone async functions.
Cleanup:
- Delete reader-context.ts and reader-events.ts (over-engineered
event system replaced by direct function calls).
- Remove panel_zoom_enabled from ReaderSettings type.
209 lines
4.0 KiB
Go
209 lines
4.0 KiB
Go
package templates
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/a-h/templ"
|
|
)
|
|
|
|
type User struct {
|
|
ID string
|
|
Username string
|
|
Email string
|
|
Role string
|
|
Theme string
|
|
FirstName string
|
|
LastName string
|
|
CreatedAt time.Time
|
|
Token string
|
|
}
|
|
|
|
type PageData struct {
|
|
User User
|
|
CurrentPage string
|
|
}
|
|
|
|
type CollectionData struct {
|
|
ID string
|
|
Name string
|
|
Description string
|
|
Color string
|
|
Icon string
|
|
}
|
|
|
|
type LibraryData struct {
|
|
ID string
|
|
Name string
|
|
Description string
|
|
TypeName string
|
|
}
|
|
|
|
type PendingRegistrationData struct {
|
|
RegistrationID string
|
|
DeviceName string
|
|
DeviceType string
|
|
ExpiresAt string
|
|
}
|
|
|
|
type ConflictData struct {
|
|
ID string
|
|
MediaItemID string
|
|
MediaItemTitle string
|
|
ConflictType string
|
|
ResolutionStatus string
|
|
CreatedAt string
|
|
ResolutionData map[string]interface{}
|
|
ResolvedBy string
|
|
ResolvedAt string
|
|
}
|
|
|
|
type QueueItemData struct {
|
|
ID string
|
|
DeviceID string
|
|
DeviceName string
|
|
DeviceType string
|
|
SyncType string
|
|
Status string
|
|
Priority int32
|
|
Attempts int32
|
|
CreatedAt string
|
|
}
|
|
|
|
type DeviceShelfMappingData struct {
|
|
ID string
|
|
CollectionID string
|
|
CollectionName string
|
|
DeviceShelfName string
|
|
SyncDirection string
|
|
CreatedAt string
|
|
}
|
|
|
|
type UnlinkedBookData struct {
|
|
ProgressID string
|
|
DeviceID string
|
|
DeviceType string
|
|
DeviceName string
|
|
FilePath string
|
|
SHA256 string
|
|
TitleFromDevice string
|
|
LastSyncTime string
|
|
ConfidenceScore float64
|
|
PotentialMatches []PotentialMatchData
|
|
}
|
|
|
|
type PotentialMatchData struct {
|
|
MediaItemID string
|
|
Title string
|
|
Author string
|
|
CoverImagePath string
|
|
MatchMethod string
|
|
Confidence float64
|
|
}
|
|
|
|
// Documentation types
|
|
type Navigation struct {
|
|
Sections []NavSection
|
|
}
|
|
|
|
type NavSection struct {
|
|
Title string
|
|
Items []NavItem
|
|
Collapsed bool
|
|
}
|
|
|
|
type NavItem struct {
|
|
Title string
|
|
URL string
|
|
Icon string
|
|
}
|
|
|
|
type Document struct {
|
|
Title string
|
|
Content string
|
|
TOC []TOCItem
|
|
Breadcrumb []BreadcrumbItem
|
|
Category string
|
|
SourceFile string
|
|
}
|
|
|
|
type TOCItem struct {
|
|
Level int
|
|
Title string
|
|
Anchor string
|
|
}
|
|
|
|
type BreadcrumbItem struct {
|
|
Title string
|
|
URL string
|
|
}
|
|
|
|
// UnsafeHTML is used for rendering raw HTML (like rendered markdown)
|
|
type UnsafeHTML string
|
|
|
|
// ToComponent converts UnsafeHTML to a templ Component
|
|
func (u UnsafeHTML) ToComponent() templ.Component {
|
|
return templ.Raw(string(u))
|
|
}
|
|
|
|
// Reader types
|
|
type ReaderMetadata struct {
|
|
MediaItemID string `json:"media_item_id"`
|
|
Title string `json:"title"`
|
|
Author string `json:"author"`
|
|
CoverImagePath string `json:"cover_image_path"`
|
|
LibraryType string `json:"library_type"`
|
|
MimeType string `json:"mime_type"`
|
|
FilePath string `json:"file_path"`
|
|
TotalPages int `json:"total_pages"`
|
|
ChapterCount int `json:"chapter_count"`
|
|
FormatGroup string `json:"format_group"`
|
|
MangaType string `json:"manga_type"`
|
|
ReadingDirection string `json:"reading_direction"`
|
|
FileURL string `json:"file_url"`
|
|
LibraryID string `json:"library_id"`
|
|
}
|
|
|
|
type ReadingProgress struct {
|
|
ID string
|
|
MediaItemID string
|
|
UserID string
|
|
CurrentPage int
|
|
TotalPages int
|
|
Percentage float64
|
|
EpubCfi string
|
|
LastReadAt time.Time
|
|
}
|
|
|
|
type Bookmark struct {
|
|
ID string
|
|
MediaItemID string
|
|
UserID string
|
|
PageNumber *int
|
|
ChapterNumber *int
|
|
CfiPosition string
|
|
Title string
|
|
Position string
|
|
Notes string
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
// ProcessingIssueData - Processing issue types
|
|
type ProcessingIssueData struct {
|
|
ID string
|
|
MediaItemID string
|
|
Title string
|
|
FilePath string
|
|
FormatGroup string
|
|
LibraryTypeName string
|
|
IssueType string
|
|
IssueDescription string
|
|
Severity string
|
|
CreatedAt time.Time
|
|
}
|
|
|
|
type IssueStats struct {
|
|
ErrorCount int64
|
|
WarningCount int64
|
|
InfoCount int64
|
|
}
|