From 1f1318b8c0ba0bc472c263e54079cbaa6e303fe0 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Wed, 20 May 2020 16:28:19 +0200 Subject: [PATCH] weblib: use templates for all html --- src/be/nikiroo/fanfix/library/Template.java | 9 +- .../fanfix/library/WebLibraryServerHtml.java | 254 +++++++----------- .../library/web/WebLibraryServerIndex.java | 5 + .../fanfix/library/web/package-info.java | 3 + .../templates/WebLibraryServerTemplates.java | 36 ++- .../library/web/templates/package-info.java | 3 + .../fanfix/library/web/templates/viewer.html | 1 - 7 files changed, 139 insertions(+), 172 deletions(-) delete mode 100644 src/be/nikiroo/fanfix/library/web/templates/viewer.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