From: Niki Roo Date: Wed, 13 May 2020 14:18:28 +0000 (+0200) Subject: chapter url handling fixes X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=4c3426fbd8a0208c285fc10d8d51e92670996438;p=fanfix.git chapter url handling fixes --- diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServer.java b/src/be/nikiroo/fanfix/library/WebLibraryServer.java index b76d8dc..8a87401 100644 --- a/src/be/nikiroo/fanfix/library/WebLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/WebLibraryServer.java @@ -626,7 +626,7 @@ public class WebLibraryServer implements Runnable { builder.append("
"); builder.append(""); @@ -784,7 +784,7 @@ public class WebLibraryServer implements Runnable { String paragraphStr = cover.length < off + 4 ? null : cover[off + 3]; // 1-based (0 = desc) - int chapter = -1; + int chapter = 0; if (chapterStr != null) { try { chapter = Integer.parseInt(chapterStr); @@ -864,9 +864,9 @@ public class WebLibraryServer implements Runnable { desc.append(story.getMeta().getTitle()); desc.append("\n"); desc.append("
\n"); - desc.append("\t\n"); + desc.append("\t\n"); desc.append("\t\n"); Map details = BasicLibrary .getMetaDesc(story.getMeta()); @@ -970,15 +970,12 @@ public class WebLibraryServer implements Runnable { // List of chap/para links - String blink = "/view/story/" + luid + "/"; - appendItemA(builder, 3, blink + "0", "Description", + appendItemA(builder, 3, getViewUrl(luid, 0, null), "Description", paragraph == 0 && chapter == 0); - if (paragraph > 0) { - blink = blink + chapter + "/"; for (int i = 1; i <= chap.getParagraphs().size(); i++) { - appendItemA(builder, 3, blink + i, "Image " + i, - paragraph == i); + appendItemA(builder, 3, getViewUrl(luid, chapter, i), + "Image " + i, paragraph == i); } } else { int i = 1; @@ -988,7 +985,8 @@ public class WebLibraryServer implements Runnable { chapName += ": " + c.getName(); } - appendItemA(builder, 3, blink + i, chapName, chapter == i); + appendItemA(builder, 3, getViewUrl(luid, i, null), chapName, + chapter == i); i++; } @@ -1064,12 +1062,12 @@ public class WebLibraryServer implements Runnable { return ""; } - private String getViewUrl(String luid, int chap, Integer para) { + private String getViewUrl(String luid, Integer chap, Integer para) { return VIEWER_URL // .replace("{luid}", luid) // - .replace("{chap}", Integer.toString(chap)) // + .replace("/{chap}", chap == null ? "" : "/" + chap) // .replace("/{para}", - para == null ? "" : "/" + Integer.toString(para)); + (chap == null || para == null) ? "" : "/" + para); } private String getStoryUrl(String luid, int chap, Integer para) {