From: Niki Roo Date: Tue, 26 May 2020 19:03:01 +0000 (+0200) Subject: update to master X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=commitdiff_plain;h=379a497e6fd2b959c57b2ff4023413e2daf36232 update to master --- diff --git a/data/MetaData.java b/data/MetaData.java index 1c6ad42..5989604 100644 --- a/data/MetaData.java +++ b/data/MetaData.java @@ -320,7 +320,7 @@ public class MetaData implements Cloneable, Comparable, Serializable { * output type this {@link Story} is in (see {@link SupportType}). *

* It allows you to know where the {@link Story} comes from, and is not - * supposed to change. + * supposed to change, even when re-imported. *

* It's the user representation of the enum * ({@link SupportType#getSourceName()}, not @@ -337,7 +337,7 @@ public class MetaData implements Cloneable, Comparable, Serializable { * output type this {@link Story} is in (see {@link SupportType}). *

* It allows you to know where the {@link Story} comes from, and is not - * supposed to change. + * supposed to change, even when re-imported. *

* It's the user representation of the enum * ({@link SupportType#getSourceName()}, not @@ -353,8 +353,8 @@ public class MetaData implements Cloneable, Comparable, Serializable { /** * The output type this {@link Story} is in (see {@link SupportType}). *

- * It allows you to know where the {@link Story} comes from, and is not - * supposed to change. + * It allows you to know where the {@link Story} comes from, and is supposed + * to only change when it is imported anew. *

* It's the direct representation of the enum * ({@link SupportType#toString()}, not @@ -369,8 +369,8 @@ public class MetaData implements Cloneable, Comparable, Serializable { /** * The output type this {@link Story} is in (see {@link SupportType}). *

- * It allows you to know where the {@link Story} comes from, and is not - * supposed to change. + * It allows you to know where the {@link Story} comes from, and is supposed + * to only change when it is imported anew. *

* It's the direct representation of the enum * ({@link SupportType#toString()}, not diff --git a/library/WebLibrary.java b/library/WebLibrary.java index 9af38e2..7381ae3 100644 --- a/library/WebLibrary.java +++ b/library/WebLibrary.java @@ -173,12 +173,12 @@ public class WebLibrary extends BasicLibrary { InputStream in = post(WebLibraryUrls.getStoryUrlCover(luid)); try { Image img = new Image(in); - if (img.getSize() > 0) { + if (img.getSize() == 0) { img.close(); - return img; + img = null; } - return null; + return img; } finally { in.close(); } @@ -189,12 +189,12 @@ public class WebLibrary extends BasicLibrary { InputStream in = post(WebLibraryUrls.getCoverUrlSource(source)); try { Image img = new Image(in); - if (img.getSize() > 0) { + if (img.getSize() == 0) { img.close(); - return img; + img = null; } - return null; + return img; } finally { in.close(); } @@ -205,12 +205,12 @@ public class WebLibrary extends BasicLibrary { InputStream in = post(WebLibraryUrls.getCoverUrlAuthor(author)); try { Image img = new Image(in); - if (img.getSize() > 0) { + if (img.getSize() == 0) { img.close(); - return img; + img = null; } - return null; + return img; } finally { in.close(); } diff --git a/library/WebLibraryServer.java b/library/WebLibraryServer.java index 22f36e9..56d78ed 100644 --- a/library/WebLibraryServer.java +++ b/library/WebLibraryServer.java @@ -217,9 +217,8 @@ public class WebLibraryServer extends WebLibraryServerHtml { jsons.add(JsonIO.toJson(meta)); } - return newInputStreamResponse("application/json", - new ByteArrayInputStream( - new JSONArray(jsons).toString().getBytes())); + return NanoHTTPD.newFixedLengthResponse(Status.OK, + "application/json", new JSONArray(jsons).toString()); } return NanoHTTPD.newFixedLengthResponse(Status.BAD_REQUEST, diff --git a/library/WebLibraryServerHtml.java b/library/WebLibraryServerHtml.java index d5ba533..63c50c5 100644 --- a/library/WebLibraryServerHtml.java +++ b/library/WebLibraryServerHtml.java @@ -247,6 +247,12 @@ abstract class WebLibraryServerHtml implements Runnable { mimeType = "text/html"; } else if (uri.endsWith(".js")) { mimeType = "text/javascript"; + } else if (uri.endsWith(".png")) { + mimeType = "image/png"; + } else if (uri.endsWith(".ico")) { + mimeType = "image/x-icon"; + } else if (uri.endsWith(".java")) { + mimeType = "text/plain"; } rep = newChunkedResponse(Status.OK, mimeType, in); @@ -326,7 +332,8 @@ abstract class WebLibraryServerHtml implements Runnable { content.add(templates.login(uri)); return NanoHTTPD.newChunkedResponse(Status.FORBIDDEN, - NanoHTTPD.MIME_HTML, templates.index(true, content).read()); + NanoHTTPD.MIME_HTML, + templates.index(true, false, content).read()); } private Response root(IHTTPSession session, Map cookies, @@ -469,7 +476,7 @@ abstract class WebLibraryServerHtml implements Runnable { booklines.add(0, templates.browser(browser, filter, selects)); return newInputStreamResponse(NanoHTTPD.MIME_HTML, - templates.index(true, booklines).read()); + templates.index(true, false, booklines).read()); } private Response getViewer(Map cookies, String uri, @@ -546,6 +553,7 @@ abstract class WebLibraryServerHtml implements Runnable { boolean disabledRight = false; boolean disabledZoomReal = false; boolean disabledZoomWidth = false; + boolean disabledZoomWidthLimited = false; boolean disabledZoomHeight = false; Template viewerItem = null; @@ -623,27 +631,36 @@ abstract class WebLibraryServerHtml implements Runnable { } if (para.getType() == ParagraphType.IMAGE) { - String zoomStyle = "max-width: 100%;"; - disabledZoomWidth = true; + // default values: + String zoomStyle = "max-width: 800px;"; + disabledZoomWidthLimited = true; + String zoomOption = cookies.get("zoom"); if (zoomOption != null && !zoomOption.isEmpty()) { if (zoomOption.equals("real")) { zoomStyle = ""; - disabledZoomWidth = false; + disabledZoomWidthLimited = false; disabledZoomReal = true; + } else if (zoomOption.equals("widthlimited")) { + // default } else if (zoomOption.equals("width")) { zoomStyle = "max-width: 100%;"; + disabledZoomWidthLimited = false; + disabledZoomWidth = true; } else if (zoomOption.equals("height")) { // see height of navbar + optionbar zoomStyle = "max-height: calc(100% - 128px);"; - disabledZoomWidth = false; + disabledZoomWidthLimited = false; disabledZoomHeight = true; } } - viewerItem = templates.viewerImage(WebLibraryUrls - .getStoryUrl(luid, chapter, paragraph), next, - zoomStyle); + viewerItem = templates.viewerImage( + WebLibraryUrls.getStoryUrl(luid, chapter, + paragraph), // + disabledRight ? null : next, // + zoomStyle // + ); } else { viewerItem = templates.viewerText(null, new TextOutput(false).convert(para)); @@ -708,25 +725,29 @@ abstract class WebLibraryServerHtml implements Runnable { buttons.add(templates.viewerOptionbarButton( // "1:1", uri + "?optionName=zoom&optionValue=real", "zoomreal", disabledZoomReal)); + buttons.add(templates.viewerOptionbarButton( // + "]width[", + uri + "?optionName=zoom&optionValue=widthlimited", + "zoomwidthlimited", disabledZoomWidthLimited)); buttons.add(templates.viewerOptionbarButton( // "Width", uri + "?optionName=zoom&optionValue=width", "zoomwidth", disabledZoomWidth)); buttons.add(templates.viewerOptionbarButton( // "Height", uri + "?optionName=zoom&optionValue=height", - "zoomHeight", disabledZoomHeight)); + "zoomheight", disabledZoomHeight)); } // Optionbar Template optionbar = templates.viewerOptionbar( // - (paragraph > 0) ? 4 : 1, // + (paragraph > 0) ? 5 : 1, // buttons // ); // Full content return newInputStreamResponse(NanoHTTPD.MIME_HTML, // - templates.index(false, Arrays.asList( // + templates.index(false, (paragraph > 0), Arrays.asList( // navbar, // viewerItem, // optionbar // @@ -738,7 +759,7 @@ abstract class WebLibraryServerHtml implements Runnable { NanoHTTPD.MIME_PLAINTEXT, "Error when processing request"); } } - + protected Response newInputStreamResponse(String mimeType, InputStream in) { if (in == null) { return NanoHTTPD.newFixedLengthResponse(Status.NO_CONTENT, "", diff --git a/library/web/fit_to_width_limited-32x32.png b/library/web/fit_to_width_limited-32x32.png new file mode 100644 index 0000000..4971046 Binary files /dev/null and b/library/web/fit_to_width_limited-32x32.png differ diff --git a/library/web/fit_to_width_limited-64x64.png b/library/web/fit_to_width_limited-64x64.png new file mode 100644 index 0000000..bd97942 Binary files /dev/null and b/library/web/fit_to_width_limited-64x64.png differ diff --git a/library/web/index.pre.html b/library/web/index.pre.html deleted file mode 100644 index 1e626ab..0000000 --- a/library/web/index.pre.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - ${title} - - - - -

diff --git a/library/web/style.css b/library/web/style.css index bb91002..5a4c51f 100644 --- a/library/web/style.css +++ b/library/web/style.css @@ -227,6 +227,7 @@ h3 { .bar.optionbar.s1 { padding-left: calc(50% - (1 * (64px + 5px) / 2)); } .bar.optionbar.s4 { padding-left: calc(50% - (4 * (64px + 5px) / 2)); } +.bar.optionbar.s5 { padding-left: calc(50% - (5 * (64px + 5px) / 2)); } .bar.optionbar { bottom: 0; @@ -258,10 +259,11 @@ h3 { .bar .button.next { color: transparent; background-image: url('/arrow_right-32x32.png'); } .bar .button.last { color: transparent; background-image: url('/arrow_double_right-32x32.png'); } -.bar .button.back { color: transparent; background-image: url('/back-32x32.png'); } -.bar .button.zoomreal { color: transparent; background-image: url('/actual_size-32x32.png'); } -.bar .button.zoomwidth { color: transparent; background-image: url('/fit_to_width-32x32.png'); } -.bar .button.zoomheight { color: transparent; background-image: url('/fit_to_height-32x32.png'); } +.bar .button.back { color: transparent; background-image: url('/back-32x32.png'); } +.bar .button.zoomreal { color: transparent; background-image: url('/actual_size-32x32.png'); } +.bar .button.zoomwidth { color: transparent; background-image: url('/fit_to_width-32x32.png'); } +.bar .button.zoomwidthlimited { color: transparent; background-image: url('/fit_to_width_limited-32x32.png'); } +.bar .button.zoomheight { color: transparent; background-image: url('/fit_to_height-32x32.png'); } .viewer { padding-top: 64px; @@ -316,18 +318,19 @@ a.viewer.link:hover { color: #AAA391; } -@media(min-width: 800px) { - .main { +@media(min-width: 800px) { + .main:not(.fullscreen) { max-width: 800px; } - .bar.navbar { padding-left: calc(400px - (5 * (64px + 5px) / 2)); } + .main:not(.fullscreen) .bar.navbar { padding-left: calc(400px - (5 * (64px + 5px) / 2)); } - .bar.optionbar.s1 { padding-left: calc(400px - (1 * (64px + 5px) / 2)); } - .bar.optionbar.s4 { padding-left: calc(400px - (4 * (64px + 5px) / 2)); } + .main:not(.fullscreen) .bar.optionbar.s1 { padding-left: calc(400px - (1 * (64px + 5px) / 2)); } + .main:not(.fullscreen) .bar.optionbar.s4 { padding-left: calc(400px - (4 * (64px + 5px) / 2)); } + .main:not(.fullscreen) .bar.optionbar.s5 { padding-left: calc(400px - (5 * (64px + 5px) / 2)); } - .desc { flex-direction: row; } - .desc .cover img { + .main:not(.fullscreen) .desc { flex-direction: row; } + .main:not(.fullscreen) .desc .cover img { width: 200px; padding-right: 10px; } diff --git a/library/web/templates/WebLibraryServerTemplates.java b/library/web/templates/WebLibraryServerTemplates.java index 59e7020..2564444 100644 --- a/library/web/templates/WebLibraryServerTemplates.java +++ b/library/web/templates/WebLibraryServerTemplates.java @@ -44,7 +44,8 @@ public class WebLibraryServerTemplates { ; } - public Template index(boolean banner, List