From: Niki Roo Date: Fri, 15 May 2020 18:05:50 +0000 (+0200) Subject: weblib: use some templates X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=c43615157b52a51f9d4a8a9f8a0a32490dbbb30d;p=nikiroo-utils.git weblib: use some templates --- diff --git a/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java b/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java index 1ec3b1f..e530d3f 100644 --- a/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java +++ b/src/be/nikiroo/fanfix/library/WebLibraryServerHtml.java @@ -371,45 +371,53 @@ abstract class WebLibraryServerHtml implements Runnable { // TODO: javascript in realtime, using visible=false + hide [submit] - builder.append("\t\t
\n"); - builder.append("\t\t\t\n"); + selects.append(selectTemplate // + .replace("${name}", "browser3") // + .replace("${value}", browser3) // + .replace("${options}", options.toString()) // + ); + } - // TODO: javascript in realtime, using visible=false + hide [submit] - builder.append("\t\t\t
\n"); - builder.append("\t\t\t\tFilter: \n"); - builder.append( - "\t\t\t\t\n"); - builder.append("\t\t\t\t\n"); - builder.append( - "\t\t\t\t\n"); - builder.append( - "\t\t\t\t\n"); - builder.append("\t\t\t
\n"); - builder.append("\t\t
\n"); + String sel = "selected='selected'"; + builder.append(getTemplate("browser") // + .replace("${sourcesSelected}", sourcesSel ? sel : "") // + .replace("${authorsSelected}", authorsSel ? sel : "") // + .replace("${tagsSelected}", tagsSel ? sel : "") // + .replace("${filter}", filter) // + .replace("${selects}", selects.toString()) // + ); builder.append("\t\t
\n"); for (MetaData meta : result.getMetas()) { @@ -481,34 +481,28 @@ abstract class WebLibraryServerHtml implements Runnable { continue; } - builder.append("\t\t\t\n"); + + builder.append(getTemplate("bookline") // + .replace("${href}", + WebLibraryUrls.getViewUrl(meta.getLuid(), null, + null)) // + .replace("${luid}", meta.getLuid()) // + .replace("${title}", meta.getTitle()) // + .replace("${author}", author) // + .replace("${cachedClass}", cachedClass) // + .replace("${cached}", cached) // + ); } builder.append("\t\t
\n"); @@ -900,4 +894,14 @@ abstract class WebLibraryServerHtml implements Runnable { builder.append(name); builder.append("\n"); } + + private String getTemplate(String template) throws IOException { + InputStream in = IOUtils.openResource(WebLibraryServerIndex.class, + template + ".html"); + try { + return IOUtils.readSmallStream(in); + } finally { + in.close(); + } + } } diff --git a/src/be/nikiroo/fanfix/library/web/bookline.html b/src/be/nikiroo/fanfix/library/web/bookline.html new file mode 100644 index 0000000..9b1a6b7 --- /dev/null +++ b/src/be/nikiroo/fanfix/library/web/bookline.html @@ -0,0 +1 @@ +
${cached}${luid}${title}${author}
diff --git a/src/be/nikiroo/fanfix/library/web/browser.html b/src/be/nikiroo/fanfix/library/web/browser.html new file mode 100644 index 0000000..f3f3047 --- /dev/null +++ b/src/be/nikiroo/fanfix/library/web/browser.html @@ -0,0 +1,18 @@ +
+ +
+ Filter: + + + + +
+
diff --git a/src/be/nikiroo/fanfix/library/web/browser.select.html b/src/be/nikiroo/fanfix/library/web/browser.select.html new file mode 100644 index 0000000..447d845 --- /dev/null +++ b/src/be/nikiroo/fanfix/library/web/browser.select.html @@ -0,0 +1,3 @@ +