worldhopper/lib/database/tables/publications_table.dart
Felipe M. 1074e3808d
feat: basic navigation
feat: navigation store

feat: implement OPDS entry caching system

Add comprehensive caching for OPDS publications with local image storage and Dublin Core Terms metadata extraction. This enables offline viewing, fixes Library screen to show book titles and covers, and improves overall UX.

- Add publications table with full metadata (title, authors, series, publisher, ISBN, language)
- Implement local image cache service for covers and thumbnails
- Extract DCTerms metadata (series, publisher, language, ISBN) from OPDS feeds
- Link reading progress to cached publications
- Update Library screen to display cached publication data and covers
- Cache publications automatically when starting to read
- Fix navigation stack issues by using context.push() instead of context.go()
- Add explicit back button to EPUB reader with proper PopScope handling
- Implement UNIQUE constraint on reading_progress to prevent duplicates
- Save reading progress on screen dispose for both EPUB and image readers

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-28 18:24:07 +01:00

59 lines
1.7 KiB
Dart

/// SQL schema for the publications table
class PublicationsTable {
PublicationsTable._();
static const String tableName = 'publications';
/// SQL statement to create the publications table
static const String createTable = '''
CREATE TABLE $tableName (
id TEXT PRIMARY KEY,
server_id TEXT NOT NULL,
opds_id TEXT NOT NULL,
title TEXT NOT NULL,
authors TEXT,
summary TEXT,
content TEXT,
cover_path TEXT,
thumbnail_path TEXT,
cover_url TEXT,
thumbnail_url TEXT,
series TEXT,
series_position REAL,
publisher TEXT,
language TEXT,
isbn TEXT,
categories TEXT,
links TEXT,
stream_link TEXT,
published INTEGER,
updated INTEGER,
first_cached_at INTEGER NOT NULL,
last_cached_at INTEGER NOT NULL,
last_accessed_at INTEGER NOT NULL,
FOREIGN KEY (server_id) REFERENCES servers(id) ON DELETE CASCADE,
UNIQUE(server_id, opds_id)
)
''';
/// SQL statement to drop the publications table
static const String dropTable = 'DROP TABLE IF EXISTS $tableName';
/// Create index on server_id for faster lookups
static const String createServerIndex = '''
CREATE INDEX idx_publications_server_id
ON $tableName(server_id)
''';
/// Create composite index on server_id and opds_id for unique lookups
static const String createServerOpdsIndex = '''
CREATE INDEX idx_publications_server_opds
ON $tableName(server_id, opds_id)
''';
/// Create index on last_accessed_at for cache cleanup
static const String createAccessedIndex = '''
CREATE INDEX idx_publications_last_accessed
ON $tableName(last_accessed_at)
''';
}