Laat parseNovel niet crashen als live bronnen 502/403 geven
liveParseNovel las fetched.posts.length terwijl Arctic Shift bij een 502 geen posts-array teruggeeft. Die TypeError sloeg de statische fallback over, waardoor LNReader overal "unable to load novel" toonde — ook bij verhalen in de index. v0.3.3 vangt dat af en houdt SourceNovel.path gelijk aan het aangevraagde pad.
@@ -113,7 +113,7 @@ class HFYNovelsPlugin {
113
113
constructor() {
114
114
this.id = "hfyNovels";
115
115
this.name = "HFY Novels";
116
this.version = "0.3.2";
116
this.version = "0.3.3";
117
117
this.site = "https://www.reddit.com/r/HFY/";
118
118
this.icon = "icon.png";
119
119
// Geen webStorageUtilized: Reddit-login zit in cookies. LNReader's
@@ -340,7 +340,15 @@ class HFYNovelsPlugin {
340
340
341
341
async parseNovel(novelPath) {
342
342
const mode = this.chapterMode();
343
const live = await this.liveParseNovel(novelPath, mode);
343
let live;
344
try {
345
live = await this.liveParseNovel(novelPath, mode);
346
} catch (err) {
347
// Een throw (bijv. ontbrekende posts-array bij een 502) mag de
348
// statische fallback niet blokkeren en niet als "unable to load novel"
349
// eindigen als de index het verhaal wel kent.
350
live = { ok: false, reason: err && err.message ? err.message : String(err) };
351
}
344
352
if (mode === "reddit" && (!live || !live.ok)) {
345
353
throw new Error(
346
354
"HFY Novels: Reddit gaf de hoofdstuklijst niet (" +
@@ -349,11 +357,19 @@ class HFYNovelsPlugin {
349
357
);
350
358
}
351
359
let novel = live && live.ok ? live.novel : null;
360
const finish = (item) => {
361
if (!item) {
362
return item;
363
}
364
// LNReader verwacht dat SourceNovel.path gelijk is aan het aangevraagde pad.
365
item.path = novelPath;
366
return item;
367
};
352
368
if (!wikiSlugFromPath(novelPath)) {
353
369
try {
354
370
const fallback = await this.staticParseNovel(novelPath);
355
371
if (!novel) {
356
return fallback;
372
return finish(fallback);
357
373
}
358
374
// De statische index kan een langere inhoudsopgave hebben dan een
359
375
// enkele live-post zonder werkende next-link; neem dan die lijst.
@@ -368,16 +384,16 @@ class HFYNovelsPlugin {
368
384
if (fallback.cover) {
369
385
novel.cover = fallback.cover;
370
386
}
371
return novel;
387
return finish(novel);
372
388
} catch (err) {
373
389
if (novel) {
374
return novel;
390
return finish(novel);
375
391
}
376
392
throw err;
377
393
}
378
394
}
379
395
if (novel) {
380
return novel;
396
return finish(novel);
381
397
}
382
398
throw new Error(
383
399
"HFY Novels: kon de reeks " +
@@ -507,7 +523,7 @@ class HFYNovelsPlugin {
507
523
if (!fetched.ok) {
508
524
return fetched;
509
525
}
510
const grouped = groupPostsIntoNovels(fetched.posts, fetched.wikiEntries || []);
526
const grouped = groupPostsIntoNovels(fetched.posts || [], fetched.wikiEntries || []);
511
527
const items = grouped
512
528
.filter((entry) => this.matchesFilters(entry, filters))
513
529
.map((entry) => toNovelItem(Object.assign({}, entry, { source: fetched.source }), this));
@@ -565,11 +581,12 @@ class HFYNovelsPlugin {
565
581
const seedId = (entry && (entry.firstId || (entry.chapterIds && entry.chapterIds[0]))) || startId;
566
582
const wanted = uniqueIds([].concat((entry && entry.chapterIds) || [], seedId ? [seedId] : []));
567
583
const fetched = await this.loadPostsByIds(wanted, mode);
568
if (!fetched.ok && !fetched.posts.length) {
569
return { ok: false, reason: reason || fetched.reason || "geen posts" };
584
const posts = fetched && Array.isArray(fetched.posts) ? fetched.posts : [];
585
if (!posts.length) {
586
return { ok: false, reason: reason || (fetched && fetched.reason) || "geen posts" };
570
587
}
571
588
const byId = {};
572
fetched.posts.forEach((post) => {
589
posts.forEach((post) => {
573
590
const id = postId(post);
574
591
if (id) {
575
592
byId[id] = post;
@@ -690,7 +707,7 @@ class HFYNovelsPlugin {
690
707
if (reddit.ok) {
691
708
return {
692
709
ok: true,
693
posts: reddit.posts.filter(isStoryPost),
710
posts: (reddit.posts || []).filter(isStoryPost),
694
711
wikiEntries: wiki.ok ? wiki.entries : [],
695
712
source: "reddit",
696
713
};
@@ -113,7 +113,7 @@ class HFYNovelsPlugin {113
constructor() {113
constructor() {114
this.id = "hfyNovels";114
this.id = "hfyNovels";115
this.name = "HFY Novels";115
this.name = "HFY Novels";116
this.version = "0.3.2";116
this.version = "0.3.3";117
this.site = "https://www.reddit.com/r/HFY/";117
this.site = "https://www.reddit.com/r/HFY/";118
this.icon = "icon.png";118
this.icon = "icon.png";119
// Geen webStorageUtilized: Reddit-login zit in cookies. LNReader's119
// Geen webStorageUtilized: Reddit-login zit in cookies. LNReader's@@ -340,7 +340,15 @@ class HFYNovelsPlugin {340
340
341
async parseNovel(novelPath) {341
async parseNovel(novelPath) {342
const mode = this.chapterMode();342
const mode = this.chapterMode();343
const live = await this.liveParseNovel(novelPath, mode);343
let live;344
try {345
live = await this.liveParseNovel(novelPath, mode);346
} catch (err) {347
// Een throw (bijv. ontbrekende posts-array bij een 502) mag de348
// statische fallback niet blokkeren en niet als "unable to load novel"349
// eindigen als de index het verhaal wel kent.350
live = { ok: false, reason: err && err.message ? err.message : String(err) };351
}344
if (mode === "reddit" && (!live || !live.ok)) {352
if (mode === "reddit" && (!live || !live.ok)) {345
throw new Error(353
throw new Error(346
"HFY Novels: Reddit gaf de hoofdstuklijst niet (" +354
"HFY Novels: Reddit gaf de hoofdstuklijst niet (" +@@ -349,11 +357,19 @@ class HFYNovelsPlugin {349
);357
);350
}358
}351
let novel = live && live.ok ? live.novel : null;359
let novel = live && live.ok ? live.novel : null;360
const finish = (item) => {361
if (!item) {362
return item;363
}364
// LNReader verwacht dat SourceNovel.path gelijk is aan het aangevraagde pad.365
item.path = novelPath;366
return item;367
};352
if (!wikiSlugFromPath(novelPath)) {368
if (!wikiSlugFromPath(novelPath)) {353
try {369
try {354
const fallback = await this.staticParseNovel(novelPath);370
const fallback = await this.staticParseNovel(novelPath);355
if (!novel) {371
if (!novel) {356
return fallback;372
return finish(fallback);357
}373
}358
// De statische index kan een langere inhoudsopgave hebben dan een374
// De statische index kan een langere inhoudsopgave hebben dan een359
// enkele live-post zonder werkende next-link; neem dan die lijst.375
// enkele live-post zonder werkende next-link; neem dan die lijst.@@ -368,16 +384,16 @@ class HFYNovelsPlugin {368
if (fallback.cover) {384
if (fallback.cover) {369
novel.cover = fallback.cover;385
novel.cover = fallback.cover;370
}386
}371
return novel;387
return finish(novel);372
} catch (err) {388
} catch (err) {373
if (novel) {389
if (novel) {374
return novel;390
return finish(novel);375
}391
}376
throw err;392
throw err;377
}393
}378
}394
}379
if (novel) {395
if (novel) {380
return novel;396
return finish(novel);381
}397
}382
throw new Error(398
throw new Error(383
"HFY Novels: kon de reeks " +399
"HFY Novels: kon de reeks " +@@ -507,7 +523,7 @@ class HFYNovelsPlugin {507
if (!fetched.ok) {523
if (!fetched.ok) {508
return fetched;524
return fetched;509
}525
}510
const grouped = groupPostsIntoNovels(fetched.posts, fetched.wikiEntries || []);526
const grouped = groupPostsIntoNovels(fetched.posts || [], fetched.wikiEntries || []);511
const items = grouped527
const items = grouped512
.filter((entry) => this.matchesFilters(entry, filters))528
.filter((entry) => this.matchesFilters(entry, filters))513
.map((entry) => toNovelItem(Object.assign({}, entry, { source: fetched.source }), this));529
.map((entry) => toNovelItem(Object.assign({}, entry, { source: fetched.source }), this));@@ -565,11 +581,12 @@ class HFYNovelsPlugin {565
const seedId = (entry && (entry.firstId || (entry.chapterIds && entry.chapterIds[0]))) || startId;581
const seedId = (entry && (entry.firstId || (entry.chapterIds && entry.chapterIds[0]))) || startId;566
const wanted = uniqueIds([].concat((entry && entry.chapterIds) || [], seedId ? [seedId] : []));582
const wanted = uniqueIds([].concat((entry && entry.chapterIds) || [], seedId ? [seedId] : []));567
const fetched = await this.loadPostsByIds(wanted, mode);583
const fetched = await this.loadPostsByIds(wanted, mode);568
if (!fetched.ok && !fetched.posts.length) {584
const posts = fetched && Array.isArray(fetched.posts) ? fetched.posts : [];569
return { ok: false, reason: reason || fetched.reason || "geen posts" };585
if (!posts.length) {586
return { ok: false, reason: reason || (fetched && fetched.reason) || "geen posts" };570
}587
}571
const byId = {};588
const byId = {};572
fetched.posts.forEach((post) => {589
posts.forEach((post) => {573
const id = postId(post);590
const id = postId(post);574
if (id) {591
if (id) {575
byId[id] = post;592
byId[id] = post;@@ -690,7 +707,7 @@ class HFYNovelsPlugin {690
if (reddit.ok) {707
if (reddit.ok) {691
return {708
return {692
ok: true,709
ok: true,693
posts: reddit.posts.filter(isStoryPost),710
posts: (reddit.posts || []).filter(isStoryPost),694
wikiEntries: wiki.ok ? wiki.entries : [],711
wikiEntries: wiki.ok ? wiki.entries : [],695
source: "reddit",712
source: "reddit",696
};713
};@@ -4,7 +4,7 @@
4
4
"name": "HFY Novels",
5
5
"site": "https://www.reddit.com/r/HFY/",
6
6
"lang": "English",
7
"version": "0.3.2",
7
"version": "0.3.3",
8
8
"url": "https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/hfy-novels.js?rev=master",
9
9
"iconUrl": "https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/icon.png?rev=master",
10
10
"hasSettings": true
@@ -4,7 +4,7 @@4
"name": "HFY Novels",4
"name": "HFY Novels",5
"site": "https://www.reddit.com/r/HFY/",5
"site": "https://www.reddit.com/r/HFY/",6
"lang": "English",6
"lang": "English",7
"version": "0.3.2",7
"version": "0.3.3",8
"url": "https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/hfy-novels.js?rev=master",8
"url": "https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/hfy-novels.js?rev=master",9
"iconUrl": "https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/icon.png?rev=master",9
"iconUrl": "https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/icon.png?rev=master",10
"hasSettings": true10
"hasSettings": true@@ -1 +1 @@
1
[{"id":"hfyNovels","name":"HFY Novels","site":"https://www.reddit.com/r/HFY/","lang":"English","version":"0.3.2","url":"https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/hfy-novels.js?rev=master","iconUrl":"https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/icon.png?rev=master","hasSettings":true}]
1
[{"id":"hfyNovels","name":"HFY Novels","site":"https://www.reddit.com/r/HFY/","lang":"English","version":"0.3.3","url":"https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/hfy-novels.js?rev=master","iconUrl":"https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/icon.png?rev=master","hasSettings":true}]
@@ -1 +1 @@1
[{"id":"hfyNovels","name":"HFY Novels","site":"https://www.reddit.com/r/HFY/","lang":"English","version":"0.3.2","url":"https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/hfy-novels.js?rev=master","iconUrl":"https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/icon.png?rev=master","hasSettings":true}]1
[{"id":"hfyNovels","name":"HFY Novels","site":"https://www.reddit.com/r/HFY/","lang":"English","version":"0.3.3","url":"https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/hfy-novels.js?rev=master","iconUrl":"https://git.timfalken.com/timfa/hfy-novels/-/raw/.dist/icon.png?rev=master","hasSettings":true}]@@ -39,14 +39,14 @@ Live gevonden verhalen (via Reddit of Arctic Shift, zonder bestand in de index)
39
39
- Reddit: het r/HFY-community-icoon (`/.dist/covers/reddit.png`)
40
40
- Arctic Shift (fallback): het logo van Arctic Shift (`/.dist/covers/arctic-shift.png`)
41
41
42
De plugin genereert geen covers meer op het toestel (geen `data:`-URI's). Die data-URI's uit 0.3.1 konden LNReader vastzetten in de bronlijst en de bibliotheek. Bij een bibliotheek-refresh geeft `parseNovel` opnieuw een gewone URL: de indexcover als het verhaal daarin staat, anders de broncover. LNReader overschrijft de opgeslagen cover dan als je de metadata mee ververst.
42
De plugin genereert geen covers meer op het toestel (geen `data:`-URI's). Die data-URI's uit 0.3.1 konden LNReader vastzetten in de bronlijst en de bibliotheek. Bij een bibliotheek-refresh geeft `parseNovel` opnieuw een gewone URL: de indexcover als het verhaal daarin staat, anders de broncover. LNReader overschrijft de opgeslagen cover dan als je de metadata mee ververst. Vanaf **0.3.3** laat een fout of 502 van Reddit/Arctic Shift `parseNovel` niet meer crashen: verhalen in de statische index openen dan gewoon via die fallback (in 0.3.2 gaf dat overal "unable to load novel").
43
43
44
44
45
45
### Inloggen via de WebView (aanbevolen)
46
46
47
47
Anonieme Reddit-JSON is sinds 2026 vaak geblokkeerd. Als je in LNReader op reddit.com inlogt, stuurt de plugin die cookies automatisch mee (dezelfde cookie-jar als de WebView; `fetchApi` gebruikt dezelfde User-Agent).
48
48
49
1. Werk de plugin bij als LNReader een update naar **0.3.2** toont (bronnen verversen, daarna bijwerken).
49
1. Werk de plugin bij als LNReader een update naar **0.3.3** toont (bronnen verversen, daarna bijwerken).
50
50
2. Open de plugin **HFY Novels** → **Website** (of in een reeks/hoofdstuk **Open in WebView**). Je komt op r/HFY.
51
51
3. Log in op Reddit met *jouw* account en sluit de WebView daarna af. Iemand anders (bijvoorbeeld op een andere telefoon) logt met een eigen account in; de sessies blijven gescheiden.
52
52
4. Ga terug naar de plugin: **Popular** toont de wiki-series, **Latest** (of filter **Nieuw**) recente OC-posts. Zoek op een titel. Open een reeks en controleer of de hoofdstuklijst klopt, en open daarna een hoofdstuk. Live gevonden reeksen die niet in de statische index zitten, tonen het r/HFY-logo (of het Arctic Shift-logo als die fallback is gebruikt). Verhalen uit de statische index houden hun eigen titelcover. Als een verhaal tijdens 0.3.1 in je bibliotheek is gezet en de app traag blijft, open het verhaal, ververs het (inclusief metadata) of verwijder het en voeg het opnieuw toe.
@@ -39,14 +39,14 @@ Live gevonden verhalen (via Reddit of Arctic Shift, zonder bestand in de index)39
- Reddit: het r/HFY-community-icoon (`/.dist/covers/reddit.png`)39
- Reddit: het r/HFY-community-icoon (`/.dist/covers/reddit.png`)40
- Arctic Shift (fallback): het logo van Arctic Shift (`/.dist/covers/arctic-shift.png`)40
- Arctic Shift (fallback): het logo van Arctic Shift (`/.dist/covers/arctic-shift.png`)41
41
42
De plugin genereert geen covers meer op het toestel (geen `data:`-URI's). Die data-URI's uit 0.3.1 konden LNReader vastzetten in de bronlijst en de bibliotheek. Bij een bibliotheek-refresh geeft `parseNovel` opnieuw een gewone URL: de indexcover als het verhaal daarin staat, anders de broncover. LNReader overschrijft de opgeslagen cover dan als je de metadata mee ververst.42
De plugin genereert geen covers meer op het toestel (geen `data:`-URI's). Die data-URI's uit 0.3.1 konden LNReader vastzetten in de bronlijst en de bibliotheek. Bij een bibliotheek-refresh geeft `parseNovel` opnieuw een gewone URL: de indexcover als het verhaal daarin staat, anders de broncover. LNReader overschrijft de opgeslagen cover dan als je de metadata mee ververst. Vanaf **0.3.3** laat een fout of 502 van Reddit/Arctic Shift `parseNovel` niet meer crashen: verhalen in de statische index openen dan gewoon via die fallback (in 0.3.2 gaf dat overal "unable to load novel").43
43
44
44
45
### Inloggen via de WebView (aanbevolen)45
### Inloggen via de WebView (aanbevolen)46
46
47
Anonieme Reddit-JSON is sinds 2026 vaak geblokkeerd. Als je in LNReader op reddit.com inlogt, stuurt de plugin die cookies automatisch mee (dezelfde cookie-jar als de WebView; `fetchApi` gebruikt dezelfde User-Agent).47
Anonieme Reddit-JSON is sinds 2026 vaak geblokkeerd. Als je in LNReader op reddit.com inlogt, stuurt de plugin die cookies automatisch mee (dezelfde cookie-jar als de WebView; `fetchApi` gebruikt dezelfde User-Agent).48
48
49
1. Werk de plugin bij als LNReader een update naar **0.3.2** toont (bronnen verversen, daarna bijwerken).49
1. Werk de plugin bij als LNReader een update naar **0.3.3** toont (bronnen verversen, daarna bijwerken).50
2. Open de plugin **HFY Novels** → **Website** (of in een reeks/hoofdstuk **Open in WebView**). Je komt op r/HFY.50
2. Open de plugin **HFY Novels** → **Website** (of in een reeks/hoofdstuk **Open in WebView**). Je komt op r/HFY.51
3. Log in op Reddit met *jouw* account en sluit de WebView daarna af. Iemand anders (bijvoorbeeld op een andere telefoon) logt met een eigen account in; de sessies blijven gescheiden.51
3. Log in op Reddit met *jouw* account en sluit de WebView daarna af. Iemand anders (bijvoorbeeld op een andere telefoon) logt met een eigen account in; de sessies blijven gescheiden.52
4. Ga terug naar de plugin: **Popular** toont de wiki-series, **Latest** (of filter **Nieuw**) recente OC-posts. Zoek op een titel. Open een reeks en controleer of de hoofdstuklijst klopt, en open daarna een hoofdstuk. Live gevonden reeksen die niet in de statische index zitten, tonen het r/HFY-logo (of het Arctic Shift-logo als die fallback is gebruikt). Verhalen uit de statische index houden hun eigen titelcover. Als een verhaal tijdens 0.3.1 in je bibliotheek is gezet en de app traag blijft, open het verhaal, ververs het (inclusief metadata) of verwijder het en voeg het opnieuw toe.52
4. Ga terug naar de plugin: **Popular** toont de wiki-series, **Latest** (of filter **Nieuw**) recente OC-posts. Zoek op een titel. Open een reeks en controleer of de hoofdstuklijst klopt, en open daarna een hoofdstuk. Live gevonden reeksen die niet in de statische index zitten, tonen het r/HFY-logo (of het Arctic Shift-logo als die fallback is gebruikt). Verhalen uit de statische index houden hun eigen titelcover. Als een verhaal tijdens 0.3.1 in je bibliotheek is gezet en de app traag blijft, open het verhaal, ververs het (inclusief metadata) of verwijder het en voeg het opnieuw toe.@@ -77,6 +77,8 @@ LNReader toont covers met `expo-image` (`NovelCoverImage`, `cachePolicy: 'memory
77
77
78
78
BlueGit kan geen dynamische afbeeldingen serveren. Live gevonden reeksen (zonder bestand in `public/covers/`) krijgen vanaf 0.3.2 geen gegenereerde cover meer op het toestel. 0.3.1 zette per titel een `data:image/png;base64` in de catalogus; LNReader probeerde die bij toevoegen aan de bibliotheek te downloaden via OkHttp (`downloadFile`), wat voor `data:`-URI's faalt, waarna de (grote) URI in de database bleef staan. Veel van die URI's tegelijk tekenden de bronlijst en de bibliotheek vast. Vanaf 0.3.2 is de live-cover een gewone, kleine https-URL naar één vast bestand per bron: `.dist/covers/reddit.png` (officiële r/HFY-community-icoon) of `.dist/covers/arctic-shift.png` (favicon van arctic-shift.photon-reddit.com), beide 240×360. De wiki-cache bewaart de bron (`reddit` of `arctic`), zodat een gecachte lijst de juiste cover houdt. Items zonder cover én zonder live-bron (bijvoorbeeld de zoekindex, die geen cover-veld heeft) vallen terug op LNReader's `defaultCover`, niet op een bronlogo.
79
79
80
In 0.3.2 gooide `liveParseNovel` een TypeError (`Cannot read properties of undefined (reading 'length')`) als Reddit 403 gaf en Arctic Shift `/api/posts/ids` (of de wiki) met HTTP 502 antwoordde zonder `posts`-array. `parseNovel` ving die throw niet op, dus de statische index werd nooit als fallback gebruikt en LNReader toonde overal "unable to load novel" — ook bij verhalen die wel in de index staan, en terwijl de catalogus nog Arctic Shift-covers kon tonen (wiki-index of cache). Vanaf 0.3.3 wordt een ontbrekende `posts`-array als lege lijst behandeld, vangt `parseNovel` throws van de live-poging af, en blijft de statische fallback werken. Het teruggegeven `SourceNovel.path` is altijd het aangevraagde pad. Een mislukte cover-download in LNReader zelf hoort `parseNovel` niet te raken; de plugin haalt covers niet op tijdens `parseNovel`, ze zijn alleen URL's in het resultaat.
81
80
82
`parseNovel` geeft dezelfde gewone URL's terug. Staat de reeks in de statische index, dan wint die indexcover, ook als de live-bron al een logo had meegegeven. In LNReader (`LibraryUpdateQueries.ts`, `updateNovelMetadata`) wordt de cover alleen overschreven als de update-optie *refresh novel metadata* aan staat (of je het verhaal opnieuw toevoegt). Dan downloadt `downloadFile` de nieuwe http(s)-URL naar `cover.png` en zet de database op `file://…`. Lukt de download niet, dan wordt `cover` op `null` gezet. Zonder metadata-refresh blijft een oude data-URI in de bibliotheek staan; verwijderen en opnieuw toevoegen lost dat ook op.
81
83
82
84
De index-PNG's gebruiken DejaVu Sans Bold (Bitstream Vera-licentie, `indexer/fonts/`). Zonder Pillow valt de indexer terug op alleen SVG. Twee verhalen met dezelfde weergavetitel delen dezelfde indexcover; dat is bewust, de hash is alleen de titel.
@@ -77,6 +77,8 @@ LNReader toont covers met `expo-image` (`NovelCoverImage`, `cachePolicy: 'memory77
77
78
BlueGit kan geen dynamische afbeeldingen serveren. Live gevonden reeksen (zonder bestand in `public/covers/`) krijgen vanaf 0.3.2 geen gegenereerde cover meer op het toestel. 0.3.1 zette per titel een `data:image/png;base64` in de catalogus; LNReader probeerde die bij toevoegen aan de bibliotheek te downloaden via OkHttp (`downloadFile`), wat voor `data:`-URI's faalt, waarna de (grote) URI in de database bleef staan. Veel van die URI's tegelijk tekenden de bronlijst en de bibliotheek vast. Vanaf 0.3.2 is de live-cover een gewone, kleine https-URL naar één vast bestand per bron: `.dist/covers/reddit.png` (officiële r/HFY-community-icoon) of `.dist/covers/arctic-shift.png` (favicon van arctic-shift.photon-reddit.com), beide 240×360. De wiki-cache bewaart de bron (`reddit` of `arctic`), zodat een gecachte lijst de juiste cover houdt. Items zonder cover én zonder live-bron (bijvoorbeeld de zoekindex, die geen cover-veld heeft) vallen terug op LNReader's `defaultCover`, niet op een bronlogo.78
BlueGit kan geen dynamische afbeeldingen serveren. Live gevonden reeksen (zonder bestand in `public/covers/`) krijgen vanaf 0.3.2 geen gegenereerde cover meer op het toestel. 0.3.1 zette per titel een `data:image/png;base64` in de catalogus; LNReader probeerde die bij toevoegen aan de bibliotheek te downloaden via OkHttp (`downloadFile`), wat voor `data:`-URI's faalt, waarna de (grote) URI in de database bleef staan. Veel van die URI's tegelijk tekenden de bronlijst en de bibliotheek vast. Vanaf 0.3.2 is de live-cover een gewone, kleine https-URL naar één vast bestand per bron: `.dist/covers/reddit.png` (officiële r/HFY-community-icoon) of `.dist/covers/arctic-shift.png` (favicon van arctic-shift.photon-reddit.com), beide 240×360. De wiki-cache bewaart de bron (`reddit` of `arctic`), zodat een gecachte lijst de juiste cover houdt. Items zonder cover én zonder live-bron (bijvoorbeeld de zoekindex, die geen cover-veld heeft) vallen terug op LNReader's `defaultCover`, niet op een bronlogo.79
79
80
In 0.3.2 gooide `liveParseNovel` een TypeError (`Cannot read properties of undefined (reading 'length')`) als Reddit 403 gaf en Arctic Shift `/api/posts/ids` (of de wiki) met HTTP 502 antwoordde zonder `posts`-array. `parseNovel` ving die throw niet op, dus de statische index werd nooit als fallback gebruikt en LNReader toonde overal "unable to load novel" — ook bij verhalen die wel in de index staan, en terwijl de catalogus nog Arctic Shift-covers kon tonen (wiki-index of cache). Vanaf 0.3.3 wordt een ontbrekende `posts`-array als lege lijst behandeld, vangt `parseNovel` throws van de live-poging af, en blijft de statische fallback werken. Het teruggegeven `SourceNovel.path` is altijd het aangevraagde pad. Een mislukte cover-download in LNReader zelf hoort `parseNovel` niet te raken; de plugin haalt covers niet op tijdens `parseNovel`, ze zijn alleen URL's in het resultaat.81
80
`parseNovel` geeft dezelfde gewone URL's terug. Staat de reeks in de statische index, dan wint die indexcover, ook als de live-bron al een logo had meegegeven. In LNReader (`LibraryUpdateQueries.ts`, `updateNovelMetadata`) wordt de cover alleen overschreven als de update-optie *refresh novel metadata* aan staat (of je het verhaal opnieuw toevoegt). Dan downloadt `downloadFile` de nieuwe http(s)-URL naar `cover.png` en zet de database op `file://…`. Lukt de download niet, dan wordt `cover` op `null` gezet. Zonder metadata-refresh blijft een oude data-URI in de bibliotheek staan; verwijderen en opnieuw toevoegen lost dat ook op.82
`parseNovel` geeft dezelfde gewone URL's terug. Staat de reeks in de statische index, dan wint die indexcover, ook als de live-bron al een logo had meegegeven. In LNReader (`LibraryUpdateQueries.ts`, `updateNovelMetadata`) wordt de cover alleen overschreven als de update-optie *refresh novel metadata* aan staat (of je het verhaal opnieuw toevoegt). Dan downloadt `downloadFile` de nieuwe http(s)-URL naar `cover.png` en zet de database op `file://…`. Lukt de download niet, dan wordt `cover` op `null` gezet. Zonder metadata-refresh blijft een oude data-URI in de bibliotheek staan; verwijderen en opnieuw toevoegen lost dat ook op.81
83
82
De index-PNG's gebruiken DejaVu Sans Bold (Bitstream Vera-licentie, `indexer/fonts/`). Zonder Pillow valt de indexer terug op alleen SVG. Twee verhalen met dezelfde weergavetitel delen dezelfde indexcover; dat is bewust, de hash is alleen de titel.84
De index-PNG's gebruiken DejaVu Sans Bold (Bitstream Vera-licentie, `indexer/fonts/`). Zonder Pillow valt de indexer terug op alleen SVG. Twee verhalen met dezelfde weergavetitel delen dezelfde indexcover; dat is bewust, de hash is alleen de titel.@@ -113,7 +113,7 @@ class HFYNovelsPlugin {
113
113
constructor() {
114
114
this.id = "hfyNovels";
115
115
this.name = "HFY Novels";
116
this.version = "0.3.2";
116
this.version = "0.3.3";
117
117
this.site = "https://www.reddit.com/r/HFY/";
118
118
this.icon = "icon.png";
119
119
// Geen webStorageUtilized: Reddit-login zit in cookies. LNReader's
@@ -340,7 +340,15 @@ class HFYNovelsPlugin {
340
340
341
341
async parseNovel(novelPath) {
342
342
const mode = this.chapterMode();
343
const live = await this.liveParseNovel(novelPath, mode);
343
let live;
344
try {
345
live = await this.liveParseNovel(novelPath, mode);
346
} catch (err) {
347
// Een throw (bijv. ontbrekende posts-array bij een 502) mag de
348
// statische fallback niet blokkeren en niet als "unable to load novel"
349
// eindigen als de index het verhaal wel kent.
350
live = { ok: false, reason: err && err.message ? err.message : String(err) };
351
}
344
352
if (mode === "reddit" && (!live || !live.ok)) {
345
353
throw new Error(
346
354
"HFY Novels: Reddit gaf de hoofdstuklijst niet (" +
@@ -349,11 +357,19 @@ class HFYNovelsPlugin {
349
357
);
350
358
}
351
359
let novel = live && live.ok ? live.novel : null;
360
const finish = (item) => {
361
if (!item) {
362
return item;
363
}
364
// LNReader verwacht dat SourceNovel.path gelijk is aan het aangevraagde pad.
365
item.path = novelPath;
366
return item;
367
};
352
368
if (!wikiSlugFromPath(novelPath)) {
353
369
try {
354
370
const fallback = await this.staticParseNovel(novelPath);
355
371
if (!novel) {
356
return fallback;
372
return finish(fallback);
357
373
}
358
374
// De statische index kan een langere inhoudsopgave hebben dan een
359
375
// enkele live-post zonder werkende next-link; neem dan die lijst.
@@ -368,16 +384,16 @@ class HFYNovelsPlugin {
368
384
if (fallback.cover) {
369
385
novel.cover = fallback.cover;
370
386
}
371
return novel;
387
return finish(novel);
372
388
} catch (err) {
373
389
if (novel) {
374
return novel;
390
return finish(novel);
375
391
}
376
392
throw err;
377
393
}
378
394
}
379
395
if (novel) {
380
return novel;
396
return finish(novel);
381
397
}
382
398
throw new Error(
383
399
"HFY Novels: kon de reeks " +
@@ -507,7 +523,7 @@ class HFYNovelsPlugin {
507
523
if (!fetched.ok) {
508
524
return fetched;
509
525
}
510
const grouped = groupPostsIntoNovels(fetched.posts, fetched.wikiEntries || []);
526
const grouped = groupPostsIntoNovels(fetched.posts || [], fetched.wikiEntries || []);
511
527
const items = grouped
512
528
.filter((entry) => this.matchesFilters(entry, filters))
513
529
.map((entry) => toNovelItem(Object.assign({}, entry, { source: fetched.source }), this));
@@ -565,11 +581,12 @@ class HFYNovelsPlugin {
565
581
const seedId = (entry && (entry.firstId || (entry.chapterIds && entry.chapterIds[0]))) || startId;
566
582
const wanted = uniqueIds([].concat((entry && entry.chapterIds) || [], seedId ? [seedId] : []));
567
583
const fetched = await this.loadPostsByIds(wanted, mode);
568
if (!fetched.ok && !fetched.posts.length) {
569
return { ok: false, reason: reason || fetched.reason || "geen posts" };
584
const posts = fetched && Array.isArray(fetched.posts) ? fetched.posts : [];
585
if (!posts.length) {
586
return { ok: false, reason: reason || (fetched && fetched.reason) || "geen posts" };
570
587
}
571
588
const byId = {};
572
fetched.posts.forEach((post) => {
589
posts.forEach((post) => {
573
590
const id = postId(post);
574
591
if (id) {
575
592
byId[id] = post;
@@ -690,7 +707,7 @@ class HFYNovelsPlugin {
690
707
if (reddit.ok) {
691
708
return {
692
709
ok: true,
693
posts: reddit.posts.filter(isStoryPost),
710
posts: (reddit.posts || []).filter(isStoryPost),
694
711
wikiEntries: wiki.ok ? wiki.entries : [],
695
712
source: "reddit",
696
713
};
@@ -113,7 +113,7 @@ class HFYNovelsPlugin {113
constructor() {113
constructor() {114
this.id = "hfyNovels";114
this.id = "hfyNovels";115
this.name = "HFY Novels";115
this.name = "HFY Novels";116
this.version = "0.3.2";116
this.version = "0.3.3";117
this.site = "https://www.reddit.com/r/HFY/";117
this.site = "https://www.reddit.com/r/HFY/";118
this.icon = "icon.png";118
this.icon = "icon.png";119
// Geen webStorageUtilized: Reddit-login zit in cookies. LNReader's119
// Geen webStorageUtilized: Reddit-login zit in cookies. LNReader's@@ -340,7 +340,15 @@ class HFYNovelsPlugin {340
340
341
async parseNovel(novelPath) {341
async parseNovel(novelPath) {342
const mode = this.chapterMode();342
const mode = this.chapterMode();343
const live = await this.liveParseNovel(novelPath, mode);343
let live;344
try {345
live = await this.liveParseNovel(novelPath, mode);346
} catch (err) {347
// Een throw (bijv. ontbrekende posts-array bij een 502) mag de348
// statische fallback niet blokkeren en niet als "unable to load novel"349
// eindigen als de index het verhaal wel kent.350
live = { ok: false, reason: err && err.message ? err.message : String(err) };351
}344
if (mode === "reddit" && (!live || !live.ok)) {352
if (mode === "reddit" && (!live || !live.ok)) {345
throw new Error(353
throw new Error(346
"HFY Novels: Reddit gaf de hoofdstuklijst niet (" +354
"HFY Novels: Reddit gaf de hoofdstuklijst niet (" +@@ -349,11 +357,19 @@ class HFYNovelsPlugin {349
);357
);350
}358
}351
let novel = live && live.ok ? live.novel : null;359
let novel = live && live.ok ? live.novel : null;360
const finish = (item) => {361
if (!item) {362
return item;363
}364
// LNReader verwacht dat SourceNovel.path gelijk is aan het aangevraagde pad.365
item.path = novelPath;366
return item;367
};352
if (!wikiSlugFromPath(novelPath)) {368
if (!wikiSlugFromPath(novelPath)) {353
try {369
try {354
const fallback = await this.staticParseNovel(novelPath);370
const fallback = await this.staticParseNovel(novelPath);355
if (!novel) {371
if (!novel) {356
return fallback;372
return finish(fallback);357
}373
}358
// De statische index kan een langere inhoudsopgave hebben dan een374
// De statische index kan een langere inhoudsopgave hebben dan een359
// enkele live-post zonder werkende next-link; neem dan die lijst.375
// enkele live-post zonder werkende next-link; neem dan die lijst.@@ -368,16 +384,16 @@ class HFYNovelsPlugin {368
if (fallback.cover) {384
if (fallback.cover) {369
novel.cover = fallback.cover;385
novel.cover = fallback.cover;370
}386
}371
return novel;387
return finish(novel);372
} catch (err) {388
} catch (err) {373
if (novel) {389
if (novel) {374
return novel;390
return finish(novel);375
}391
}376
throw err;392
throw err;377
}393
}378
}394
}379
if (novel) {395
if (novel) {380
return novel;396
return finish(novel);381
}397
}382
throw new Error(398
throw new Error(383
"HFY Novels: kon de reeks " +399
"HFY Novels: kon de reeks " +@@ -507,7 +523,7 @@ class HFYNovelsPlugin {507
if (!fetched.ok) {523
if (!fetched.ok) {508
return fetched;524
return fetched;509
}525
}510
const grouped = groupPostsIntoNovels(fetched.posts, fetched.wikiEntries || []);526
const grouped = groupPostsIntoNovels(fetched.posts || [], fetched.wikiEntries || []);511
const items = grouped527
const items = grouped512
.filter((entry) => this.matchesFilters(entry, filters))528
.filter((entry) => this.matchesFilters(entry, filters))513
.map((entry) => toNovelItem(Object.assign({}, entry, { source: fetched.source }), this));529
.map((entry) => toNovelItem(Object.assign({}, entry, { source: fetched.source }), this));@@ -565,11 +581,12 @@ class HFYNovelsPlugin {565
const seedId = (entry && (entry.firstId || (entry.chapterIds && entry.chapterIds[0]))) || startId;581
const seedId = (entry && (entry.firstId || (entry.chapterIds && entry.chapterIds[0]))) || startId;566
const wanted = uniqueIds([].concat((entry && entry.chapterIds) || [], seedId ? [seedId] : []));582
const wanted = uniqueIds([].concat((entry && entry.chapterIds) || [], seedId ? [seedId] : []));567
const fetched = await this.loadPostsByIds(wanted, mode);583
const fetched = await this.loadPostsByIds(wanted, mode);568
if (!fetched.ok && !fetched.posts.length) {584
const posts = fetched && Array.isArray(fetched.posts) ? fetched.posts : [];569
return { ok: false, reason: reason || fetched.reason || "geen posts" };585
if (!posts.length) {586
return { ok: false, reason: reason || (fetched && fetched.reason) || "geen posts" };570
}587
}571
const byId = {};588
const byId = {};572
fetched.posts.forEach((post) => {589
posts.forEach((post) => {573
const id = postId(post);590
const id = postId(post);574
if (id) {591
if (id) {575
byId[id] = post;592
byId[id] = post;@@ -690,7 +707,7 @@ class HFYNovelsPlugin {690
if (reddit.ok) {707
if (reddit.ok) {691
return {708
return {692
ok: true,709
ok: true,693
posts: reddit.posts.filter(isStoryPost),710
posts: (reddit.posts || []).filter(isStoryPost),694
wikiEntries: wiki.ok ? wiki.entries : [],711
wikiEntries: wiki.ok ? wiki.entries : [],695
source: "reddit",712
source: "reddit",696
};713
};@@ -554,6 +554,55 @@ function testLiveCoverFiles() {
554
554
}
555
555
556
556
557
558
async function testParseNovelWhenLiveFails(origin, fixtureRoot, assert) {
559
// Reddit 403 + Arctic Shift 502 zonder posts-array: dit is de fout uit 0.3.2
560
// ("unable to load novel" overal, ook voor verhalen in de statische index).
561
const redditHandler = (url, res) => {
562
res.writeHead(403, { "Content-Type": "text/html; charset=utf-8" });
563
res.end("<html><body>blocked</body></html>");
564
};
565
const arcticHandler = (url, res) => {
566
res.writeHead(502, { "Content-Type": "text/html; charset=utf-8" });
567
res.end("<html><body>Bad Gateway</body></html>");
568
};
569
const started = await startServer(fixtureRoot, arcticHandler, redditHandler);
570
const fetchApi = makeFetchApi(started.url);
571
try {
572
const storageMap = {
573
indexBaseUrl: origin,
574
indexRev: "",
575
chapterSourceUrl: started.url,
576
chapterSource: "auto",
577
};
578
const plugin = loadPlugin(storageMap, fetchApi);
579
580
const live = await plugin.liveParseNovel("series/aaa111", "auto");
581
assert(live && live.ok === false, "liveParseNovel geeft ok:false bij 403+502, geen throw");
582
assert(!live.novel, "geen half novel-object bij live-fout");
583
584
const novel = await plugin.parseNovel("series/aaa111");
585
assert(novel.path === "series/aaa111", "parseNovel houdt het aangevraagde pad");
586
assert(novel.name === "The Last Terran", "parseNovel valt terug op de statische index");
587
assert(novel.chapters && novel.chapters.length === 3, "statische hoofdstuklijst blijft beschikbaar");
588
assert(novel.cover && novel.cover.indexOf("/covers/") !== -1, "indexcover bij live-fout");
589
assert(String(novel.cover).indexOf("data:") === -1, "geen data-URI bij fallback");
590
591
let wikiError = "";
592
try {
593
await plugin.parseNovel("wiki/the_last_terran");
594
} catch (err) {
595
wikiError = String(err && err.message || err);
596
}
597
assert(/niet live bepalen/i.test(wikiError), "wiki zonder index krijgt een duidelijke fout");
598
assert(!/Cannot read/i.test(wikiError) && !/undefined/i.test(wikiError), "geen TypeError op .posts.length");
599
600
console.log("✔️ parseNovel: 403+502 TypeError-vrij, statische fallback werkt");
601
} finally {
602
started.server.close();
603
}
604
}
605
557
606
async function main() {
558
607
const fixtureRoot = path.join(ROOT, "testdata", "index-fixture");
559
608
const redditState = { mode: "ok", redditHits: 0, arcticHits: 0 };
@@ -579,7 +628,7 @@ async function main() {
579
628
580
629
assert(plugin.id === "hfyNovels", "id");
581
630
assert(plugin.name === "HFY Novels", "name");
582
assert(plugin.version === "0.3.2", "version");
631
assert(plugin.version === "0.3.3", "version");
583
632
assert(plugin.site === "https://www.reddit.com/r/HFY/", "site");
584
633
assert(plugin.pluginSettings && plugin.pluginSettings.indexBaseUrl, "pluginSettings");
585
634
assert(plugin.filters && plugin.filters.catalog, "filter Nieuw/wiki");
@@ -701,6 +750,8 @@ async function main() {
701
750
702
751
// --- Live catalogus: wiki, zoeken, parseNovel, met fallbacks ---
703
752
await testLiveCatalog(url, fixtureRoot, fetchApi, assert);
753
await testParseNovelWhenLiveFails(url, fixtureRoot, assert);
754
704
755
705
756
// Manifest-vorm controleren.
706
757
const manifest = JSON.parse(fs.readFileSync(path.join(ROOT, ".dist", "plugins.json"), "utf8"));
@@ -554,6 +554,55 @@ function testLiveCoverFiles() {554
}554
}555
555
556
556
557
558
async function testParseNovelWhenLiveFails(origin, fixtureRoot, assert) {559
// Reddit 403 + Arctic Shift 502 zonder posts-array: dit is de fout uit 0.3.2560
// ("unable to load novel" overal, ook voor verhalen in de statische index).561
const redditHandler = (url, res) => {562
res.writeHead(403, { "Content-Type": "text/html; charset=utf-8" });563
res.end("<html><body>blocked</body></html>");564
};565
const arcticHandler = (url, res) => {566
res.writeHead(502, { "Content-Type": "text/html; charset=utf-8" });567
res.end("<html><body>Bad Gateway</body></html>");568
};569
const started = await startServer(fixtureRoot, arcticHandler, redditHandler);570
const fetchApi = makeFetchApi(started.url);571
try {572
const storageMap = {573
indexBaseUrl: origin,574
indexRev: "",575
chapterSourceUrl: started.url,576
chapterSource: "auto",577
};578
const plugin = loadPlugin(storageMap, fetchApi);579
580
const live = await plugin.liveParseNovel("series/aaa111", "auto");581
assert(live && live.ok === false, "liveParseNovel geeft ok:false bij 403+502, geen throw");582
assert(!live.novel, "geen half novel-object bij live-fout");583
584
const novel = await plugin.parseNovel("series/aaa111");585
assert(novel.path === "series/aaa111", "parseNovel houdt het aangevraagde pad");586
assert(novel.name === "The Last Terran", "parseNovel valt terug op de statische index");587
assert(novel.chapters && novel.chapters.length === 3, "statische hoofdstuklijst blijft beschikbaar");588
assert(novel.cover && novel.cover.indexOf("/covers/") !== -1, "indexcover bij live-fout");589
assert(String(novel.cover).indexOf("data:") === -1, "geen data-URI bij fallback");590
591
let wikiError = "";592
try {593
await plugin.parseNovel("wiki/the_last_terran");594
} catch (err) {595
wikiError = String(err && err.message || err);596
}597
assert(/niet live bepalen/i.test(wikiError), "wiki zonder index krijgt een duidelijke fout");598
assert(!/Cannot read/i.test(wikiError) && !/undefined/i.test(wikiError), "geen TypeError op .posts.length");599
600
console.log("✔️ parseNovel: 403+502 TypeError-vrij, statische fallback werkt");601
} finally {602
started.server.close();603
}604
}605
557
async function main() {606
async function main() {558
const fixtureRoot = path.join(ROOT, "testdata", "index-fixture");607
const fixtureRoot = path.join(ROOT, "testdata", "index-fixture");559
const redditState = { mode: "ok", redditHits: 0, arcticHits: 0 };608
const redditState = { mode: "ok", redditHits: 0, arcticHits: 0 };@@ -579,7 +628,7 @@ async function main() {579
628
580
assert(plugin.id === "hfyNovels", "id");629
assert(plugin.id === "hfyNovels", "id");581
assert(plugin.name === "HFY Novels", "name");630
assert(plugin.name === "HFY Novels", "name");582
assert(plugin.version === "0.3.2", "version");631
assert(plugin.version === "0.3.3", "version");583
assert(plugin.site === "https://www.reddit.com/r/HFY/", "site");632
assert(plugin.site === "https://www.reddit.com/r/HFY/", "site");584
assert(plugin.pluginSettings && plugin.pluginSettings.indexBaseUrl, "pluginSettings");633
assert(plugin.pluginSettings && plugin.pluginSettings.indexBaseUrl, "pluginSettings");585
assert(plugin.filters && plugin.filters.catalog, "filter Nieuw/wiki");634
assert(plugin.filters && plugin.filters.catalog, "filter Nieuw/wiki");@@ -701,6 +750,8 @@ async function main() {701
750
702
// --- Live catalogus: wiki, zoeken, parseNovel, met fallbacks ---751
// --- Live catalogus: wiki, zoeken, parseNovel, met fallbacks ---703
await testLiveCatalog(url, fixtureRoot, fetchApi, assert);752
await testLiveCatalog(url, fixtureRoot, fetchApi, assert);753
await testParseNovelWhenLiveFails(url, fixtureRoot, assert);754
704
755
705
// Manifest-vorm controleren.756
// Manifest-vorm controleren.706
const manifest = JSON.parse(fs.readFileSync(path.join(ROOT, ".dist", "plugins.json"), "utf8"));757
const manifest = JSON.parse(fs.readFileSync(path.join(ROOT, ".dist", "plugins.json"), "utf8"));