Commit graph svitak/app/Types.hs
Author SHA1 Message Date
4e990f19cd
add book-wide text search 2026-07-06 01:16:57 +01:00
da70b3ccf2
add LRU cache 2026-07-05 01:45:47 +01:00
81c2caaf67
add worker thread tracking
add stGen which gets bumped for every worker thread spawned by
loadBook

every thread captures stGen when it spawns and before actually loading
the book in the main thread, and in the worker thread it checks if
myGen == stGen

this throws away stale requests, meaning if you try and load another
book while one is still loading, it will ignore the one still loading
and start loading the latest request
2026-07-02 02:50:31 +01:00
2011d638b0
refactor: streaming loader, hierarchical TOC, parser robustness
Rework the reader around a clean BookInfo interface and lazy chapter loading.

Types/parser:
- BookInfo now splits into loadStructure (cheap: spine refs + TOC tree) and renderChapter (one chapter on demand). EpubEnv carries the parsed archive.
- resolveZipPath collapses ./.. and strips #fragments (normalise does not), so relative hrefs like ../Images/x.jpg resolve; used for chapters and images.
- decodeEntry tolerates encodings: UTF-8/UTF-16 BOMs, Latin-1 fallback instead of throwing on invalid bytes.
- Skip spine items with no manifest entry instead of throwing an error.
- Scan the zip for a .opf if container.xml is missing.
- Image inlining rewrites the src URL string, not the whole <img> tag (scalpel
  re-serialises tags, so a whole-tag replace silently missed self-closing imgs).

Navigation:
- Hierarchical TOC: ncxToc (EPUB 2), navToc (EPUB 3), guideToc (<guide> fallback). Nested scrapers use atDepth 1 to take only direct children.

UI:
- Streaming: render the opened chapter on demand, cache it, preload neighbours so arrow paging is instant with a placeholder that covers uncached jumps.
- Sidebar shows the TOC tree with CSS styling. Clicks scroll to #fragments.
- wrapHtml wraps each body in a full HTML document for reliable WebKit render.

Test: 'svitak-test <book> <idx>' dumps one rendered chapter. cabal test stanza fixed to list all needed modules/deps.
2026-06-26 03:45:29 +01:00
9784b7c7de
improve error handling 2026-03-22 03:24:56 +00:00
acd221be28
epub version detection 2026-02-23 01:30:54 +00:00
80be08965e implement generic bookinfo and move logic to parser 2026-02-12 12:47:01 +00:00
55b04ecf44 explicit types 2026-02-12 11:17:36 +00:00
7cd9e79c94 add navigation module 2026-02-11 06:22:09 +00:00
4ddb090b2f table of contents integration 2026-02-08 03:02:54 +00:00
eb479d0ae3 break up UI into different functions 2026-02-07 03:07:14 +00:00
de7a64cade replace tagsoup with scalpel 2026-02-04 06:15:20 +00:00
b24288eb70 add seperate types module 2026-02-05 03:25:31 +00:00