X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Flibrary%2FWebLibraryServer.java;h=8a874010257072cc93018f92583c1d82620fedfd;hb=4c3426fbd8a0208c285fc10d8d51e92670996438;hp=fe79f96ad455c0814e0c759196ff580c37609733;hpb=599b05c7917edbe2fe4d6449628f2b261eae2f5e;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServer.java b/src/be/nikiroo/fanfix/library/WebLibraryServer.java index fe79f96..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(""); @@ -713,6 +713,8 @@ public class WebLibraryServer implements Runnable { if (img != null) { in = img.newInputStream(); } + // TODO: get correct image type + mimeType = "image/png"; } else if ("metadata".equals(chapterStr)) { MetaData meta = meta(luid, whitelist); JSONObject json = JsonIO.toJson(meta); @@ -782,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); @@ -858,10 +860,13 @@ public class WebLibraryServer implements Runnable { StringBuilder desc = new StringBuilder(); if (chapter <= 0) { + desc.append("

"); + 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()); @@ -877,9 +882,9 @@ public class WebLibraryServer implements Runnable { content.append(desc); String description = new TextOutput(false).convert(chap, chapter > 0); - content.append( - description.isEmpty() ? "No description provided." - : description); + content.append(chap.getParagraphs().size() <= 0 + ? "No content provided." + : description); content.append("\n"); if (chapter <= 0) @@ -935,10 +940,12 @@ public class WebLibraryServer implements Runnable { } } + String javascript = "document.getElementById(\"previous\").click(); return false;"; content.append(String.format("" // - + "" + + "" + "" + "", // + javascript, // next, // zoomStyle, // getStoryUrl(luid, chapter, paragraph))); @@ -952,12 +959,45 @@ public class WebLibraryServer implements Runnable { builder.append(String.format("" // + "\n", // + + "\t<\n" // + + "\t
\n" // + + "\t\t
%d
\n" // + + "\t\t
\n", // disabledLeft, first, // disabledLeft, previous, // + paragraph > 0 ? paragraph : chapter // + )); + + // List of chap/para links + + appendItemA(builder, 3, getViewUrl(luid, 0, null), "Description", + paragraph == 0 && chapter == 0); + if (paragraph > 0) { + for (int i = 1; i <= chap.getParagraphs().size(); i++) { + appendItemA(builder, 3, getViewUrl(luid, chapter, i), + "Image " + i, paragraph == i); + } + } else { + int i = 1; + for (Chapter c : story.getChapters()) { + String chapName = "Chapter " + c.getNumber(); + if (c.getName() != null && !c.getName().isEmpty()) { + chapName += ": " + c.getName(); + } + + appendItemA(builder, 3, getViewUrl(luid, i, null), chapName, + chapter == i); + + i++; + } + } + + builder.append(String.format("" // + + "\t\t
\n" // + + "\t
\n" // + + "\t>\n" // + + "\t>>\n"// + + "\n", // disabledRight, next, // disabledRight, last // )); @@ -1022,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) { @@ -1178,6 +1218,23 @@ public class WebLibraryServer implements Runnable { builder.append("\n"); } + private void appendItemA(StringBuilder builder, int depth, String link, + String name, boolean selected) { + for (int i = 0; i < depth; i++) { + builder.append("\t"); + } + + builder.append(""); + builder.append(name); + builder.append("\n"); + } + public static void main(String[] args) throws IOException { Instance.init(); WebLibraryServer web = new WebLibraryServer(false);