From: Niki Roo Date: Tue, 12 May 2020 16:53:29 +0000 (+0200) Subject: fix cover image, prepare desc X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=db9146bc53fcfd0912910f5bd21a6cc917018b36;p=nikiroo-utils.git fix cover image, prepare desc --- diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServer.java b/src/be/nikiroo/fanfix/library/WebLibraryServer.java index 35b8ab5..4abd438 100644 --- a/src/be/nikiroo/fanfix/library/WebLibraryServer.java +++ b/src/be/nikiroo/fanfix/library/WebLibraryServer.java @@ -813,145 +813,162 @@ public class WebLibraryServer implements Runnable { StringBuilder builder = new StringBuilder(); appendPreHtml(builder, false); - if (chapter < 0) { - builder.append(story); - } else { - if (chapter == 0) { - // TODO: description + // TODO: no desc page for images? + if (story.getMeta().isImageDocument()) { + if (chapter <= 0) chapter = 1; - } + if (paragraph <= 0) + paragraph = 1; + } - Chapter chap = null; + Chapter chap = null; + if (chapter <= 0) { + chap = story.getMeta().getResume(); + } else { try { chap = story.getChapters().get(chapter - 1); } catch (IndexOutOfBoundsException e) { return NanoHTTPD.newFixedLengthResponse(Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT, "Chapter not found"); } + } - if (story.getMeta().isImageDocument() && paragraph <= 0) { - paragraph = 1; + String first, previous, next, last; + + StringBuilder content = new StringBuilder(); + + String disabledLeft = ""; + String disabledRight = ""; + String disabledZoomReal = ""; + String disabledZoomWidth = ""; + String disabledZoomHeight = ""; + + if (paragraph <= 0) { + first = getViewUrl(luid, 1, null); + previous = getViewUrl(luid, (Math.max(chapter - 1, 1)), null); + next = getViewUrl(luid, + (Math.min(chapter + 1, story.getChapters().size())), + null); + last = getViewUrl(luid, story.getChapters().size(), null); + + // TODO + StringBuilder desc = new StringBuilder(); + + if (chapter <= 0) { + desc.append("
\n"); + desc.append("\t
\n"); + desc.append("\t\t\n"); + desc.append("\t
\n"); + desc.append("\t\n"); + desc.append( + "\t\t\n"); + desc.append("\t\t\n"); + desc.append("\t\t\n"); + desc.append("\t
HEAD 1HEAD 2
KEY 1VAL 1
KEY 2VAL 2
\n"); + desc.append("
\n"); + desc.append("

Description

\n"); } - String first, previous, next, last; - String content; - - String disabledLeft = ""; - String disabledRight = ""; - String disabledZoomReal = ""; - String disabledZoomWidth = ""; - String disabledZoomHeight = ""; + content.append("
\n"); + content.append(desc); + content.append( + new TextOutput(false).convert(chap, chapter > 0)); + content.append("
\n"); - if (paragraph <= 0) { - first = getViewUrl(luid, 1, null); - previous = getViewUrl(luid, (Math.max(chapter - 1, 1)), - null); - next = getViewUrl(luid, - (Math.min(chapter + 1, story.getChapters().size())), - null); - last = getViewUrl(luid, story.getChapters().size(), null); - - content = "
\n" - + new TextOutput(false).convert(chap, true) - + "
\n"; - - if (chapter <= 1) - disabledLeft = " disabled='disbaled'"; - if (chapter >= story.getChapters().size()) - disabledRight = " disabled='disbaled'"; - } else { - first = getViewUrl(luid, chapter, 1); - previous = getViewUrl(luid, chapter, - (Math.max(paragraph - 1, 1))); - next = getViewUrl(luid, chapter, (Math.min(paragraph + 1, - chap.getParagraphs().size()))); - last = getViewUrl(luid, chapter, - chap.getParagraphs().size()); - - if (paragraph <= 1) - disabledLeft = " disabled='disbaled'"; - if (paragraph >= chap.getParagraphs().size()) - disabledRight = " disabled='disbaled'"; - - Paragraph para = null; - try { - para = chap.getParagraphs().get(paragraph - 1); - } catch (IndexOutOfBoundsException e) { - return NanoHTTPD.newFixedLengthResponse( - Status.NOT_FOUND, NanoHTTPD.MIME_PLAINTEXT, - "Paragraph not found"); - } + if (chapter <= 1) + disabledLeft = " disabled='disbaled'"; + if (chapter >= story.getChapters().size()) + disabledRight = " disabled='disbaled'"; + } else { + first = getViewUrl(luid, chapter, 1); + previous = getViewUrl(luid, chapter, + (Math.max(paragraph - 1, 1))); + next = getViewUrl(luid, chapter, + (Math.min(paragraph + 1, chap.getParagraphs().size()))); + last = getViewUrl(luid, chapter, chap.getParagraphs().size()); + + if (paragraph <= 1) + disabledLeft = " disabled='disbaled'"; + if (paragraph >= chap.getParagraphs().size()) + disabledRight = " disabled='disbaled'"; + + Paragraph para = null; + try { + para = chap.getParagraphs().get(paragraph - 1); + } catch (IndexOutOfBoundsException e) { + return NanoHTTPD.newFixedLengthResponse(Status.NOT_FOUND, + NanoHTTPD.MIME_PLAINTEXT, + "Paragraph " + paragraph + " not found"); + } - if (para.getType() == ParagraphType.IMAGE) { - String zoomStyle = "max-width: 100%;"; - disabledZoomWidth = " disabled='disabled'"; - String zoomOption = cookies.get("zoom"); - if (zoomOption != null && !zoomOption.isEmpty()) { - if (zoomOption.equals("real")) { - zoomStyle = ""; - disabledZoomWidth = ""; - disabledZoomReal = " disabled='disabled'"; - } else if (zoomOption.equals("width")) { - zoomStyle = "max-width: 100%;"; - } else if (zoomOption.equals("height")) { - // see height of navbar + optionbar - zoomStyle = "max-height: calc(100% - 128px);"; - disabledZoomWidth = ""; - disabledZoomHeight = " disabled='disabled'"; - } + if (para.getType() == ParagraphType.IMAGE) { + String zoomStyle = "max-width: 100%;"; + disabledZoomWidth = " disabled='disabled'"; + String zoomOption = cookies.get("zoom"); + if (zoomOption != null && !zoomOption.isEmpty()) { + if (zoomOption.equals("real")) { + zoomStyle = ""; + disabledZoomWidth = ""; + disabledZoomReal = " disabled='disabled'"; + } else if (zoomOption.equals("width")) { + zoomStyle = "max-width: 100%;"; + } else if (zoomOption.equals("height")) { + // see height of navbar + optionbar + zoomStyle = "max-height: calc(100% - 128px);"; + disabledZoomWidth = ""; + disabledZoomHeight = " disabled='disabled'"; } - content = String.format("" // - + "" // - + "" - + "", // - next, // - zoomStyle, // - getStoryUrl(luid, chapter, paragraph)); - } else { - content = para.getContent(); } + content.append(String.format("" // + + "" + + "" + + "", // + next, // + zoomStyle, // + getStoryUrl(luid, chapter, paragraph))); + } else { + content.append(para.getContent()); } + } + builder.append(String.format("" // + + "\n", // + disabledLeft, first, // + disabledLeft, previous, // + disabledRight, next, // + disabledRight, last // + )); + + builder.append(content); + + builder.append("
\n"); + builder.append(" BACK\n"); + + if (paragraph > 0) { builder.append(String.format("" // - + "\n" // - + "%s", // - disabledLeft, first, // - disabledLeft, previous, // - disabledRight, next, // - disabledRight, last, // - content // + + "\tREAL\n"// + + "\tWIDTH\n"// + + "\tHEIGHT\n"// + + "
\n", // + disabledZoomReal, + uri + "?optionName=zoom&optionValue=real", // + disabledZoomWidth, + uri + "?optionName=zoom&optionValue=width", // + disabledZoomHeight, + uri + "?optionName=zoom&optionValue=height" // )); - - builder.append("
\n"); - builder.append( - " BACK\n"); - - if (paragraph > 0) { - builder.append(String.format("" // - + "\tREAL\n"// - + "\tWIDTH\n"// - + "\tHEIGHT\n"// - + "
\n", // - disabledZoomReal, - uri + "?optionName=zoom&optionValue=real", // - disabledZoomWidth, - uri + "?optionName=zoom&optionValue=width", // - disabledZoomHeight, - uri + "?optionName=zoom&optionValue=height" // - )); - } } appendPostHtml(builder); @@ -1023,7 +1040,8 @@ public class WebLibraryServer implements Runnable { throws IOException { MetaData meta = meta(luid, whitelist); if (meta != null) { - return meta.getCover(); + BasicLibrary lib = Instance.getInstance().getLibrary(); + return lib.getCover(meta.getLuid()); } return null; diff --git a/src/be/nikiroo/fanfix/library/web/style.css b/src/be/nikiroo/fanfix/library/web/style.css index 5c4d1bb..fb01190 100644 --- a/src/be/nikiroo/fanfix/library/web/style.css +++ b/src/be/nikiroo/fanfix/library/web/style.css @@ -6,10 +6,6 @@ html, body, .main { height: 100%; } -table { - width: 100%; -} - .banner { } @@ -136,25 +132,6 @@ h3 { margin: auto; } -.viewer { - padding-top: 64px; - padding-bottom: 64px; -} - -.viewer.img { - margin: auto; - display: block; -} - -a.viewer.link:hover { - background-color: transparent; -} - -.viewer.text { - padding-left: 10px; - padding-right: 10px; -} - .bar.navbar { padding-left: calc(50% - (4 * 64px / 2)); } .bar.optionbar.s1 { padding-left: calc(50% - (1 * 64px / 2)); } @@ -200,6 +177,29 @@ a.viewer.link:hover { .bar .button.zoomwidth { background-image: url('/fit_to_width-32x32.png'); } .bar .button.zoomheight { background-image: url('/fit_to_height-32x32.png'); } +.viewer { + padding-top: 64px; + padding-bottom: 64px; +} + +.viewer.img { + margin: auto; + display: block; +} + +a.viewer.link:hover { + background-color: transparent; +} + +.viewer.text { + padding-left: 10px; + padding-right: 10px; +} + +.desc { + display: flex; +} + @media(min-width: 800px) { .main { max-width: 800px;