From: Niki Roo Date: Wed, 20 May 2020 14:28:19 +0000 (+0200) Subject: weblib: use templates for all html X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=1f1318b8c0ba0bc472c263e54079cbaa6e303fe0;p=fanfix.git weblib: use templates for all html --- diff --git a/src/be/nikiroo/fanfix/library/Template.java b/src/be/nikiroo/fanfix/library/Template.java index 3536d5f..3ec9873 100644 --- a/src/be/nikiroo/fanfix/library/Template.java +++ b/src/be/nikiroo/fanfix/library/Template.java @@ -64,22 +64,27 @@ public class Template { i++; } - + InputStream in = IOUtils.openResource(location, name); return new ReplaceInputStream(in, from, to); } public synchronized Template set(String key, String value) { - values.put(key, value); + values.put(key, value == null ? "" : key); valuesTemplate.remove(key); valuesTemplateList.remove(key); return this; } public synchronized Template set(String key, Template value) { + if (value == null) { + return set(key, ""); + } + values.remove(key); valuesTemplate.put(key, value); valuesTemplateList.remove(key); + return this; } diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java b/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java index 42ebead..d5ba533 100644 --- a/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java +++ b/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java @@ -16,7 +16,6 @@ import javax.net.ssl.SSLServerSocketFactory; import be.nikiroo.fanfix.Instance; import be.nikiroo.fanfix.bundles.Config; -import be.nikiroo.fanfix.bundles.UiConfig; import be.nikiroo.fanfix.data.Chapter; import be.nikiroo.fanfix.data.MetaData; import be.nikiroo.fanfix.data.Paragraph; @@ -543,14 +542,13 @@ abstract class WebLibraryServerHtml implements Runnable { String first, previous, next, last; - String viewer = ""; - - String disabledLeft = ""; - String disabledRight = ""; - String disabledZoomReal = ""; - String disabledZoomWidth = ""; - String disabledZoomHeight = ""; + boolean disabledLeft = false; + boolean disabledRight = false; + boolean disabledZoomReal = false; + boolean disabledZoomWidth = false; + boolean disabledZoomHeight = false; + Template viewerItem = null; if (paragraph <= 0) { first = WebLibraryUrls.getViewUrl(luid, 0, null); previous = WebLibraryUrls.getViewUrl(luid, @@ -561,42 +559,37 @@ abstract class WebLibraryServerHtml implements Runnable { last = WebLibraryUrls.getViewUrl(luid, story.getChapters().size(), null); - String desc = ""; + Template desc = null; if (chapter <= 0) { - StringBuilder desclines = new StringBuilder(); + List