From 5e584219e79d72ef09c461dca4b2ab9ebffaede6 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sun, 3 Feb 2013 12:51:53 +0200 Subject: [PATCH] Possibility to disable HTML header and footer and title. --- .../meviz/htmlindexer/FilesystemIndexer.java | 2 +- .../svjatoslav/meviz/htmlindexer/Layout.java | 3 +- .../meviz/htmlindexer/WebIndexer.java | 2 +- .../htmlindexer/layouts/MixedLayout.java | 39 +++++++++++-------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java index 3a48b67..4e1b2f2 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java @@ -144,7 +144,7 @@ public class FilesystemIndexer extends AbstractIndexer { indexForLayout(layout); IOHelper.overwriteFileIfContentDiffers(indexFile, layout - .getHtml().getBytes()); + .getHtml(true, true).getBytes()); } } catch (final Exception e) { logger.error("Error writing index file to:" + indexFilePath, e); diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java index 88de6ce..5110b3e 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java @@ -57,7 +57,8 @@ public interface Layout { * After necessary files have been enlisted for particular directory, use * this method to retrieve generated HTML result. */ - public String getHtml(); + public String getHtml(final boolean showTitle, + final boolean doHtmlHeaderAndFooter); /** * Initialize layout for particular directory. diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java index 29ceac1..d4fd7e3 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java @@ -44,7 +44,7 @@ public class WebIndexer extends AbstractIndexer { compileHtml(layout, metadata); - return layout.getHtml(); + return layout.getHtml(false, false); } public DirectoryMetadata getMetadataForPath(final String requestPath) diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java index 4c00985..c51d7fa 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java @@ -219,25 +219,31 @@ public class MixedLayout implements Layout { /** {@inheritDoc} */ @Override - public String getHtml() { + public String getHtml(final boolean showTitle, + final boolean doHtmlHeaderAndFooter) { // assemble final page HTML final StringBuffer finalHtml = new StringBuffer(); - // page header - finalHtml.append("\n"); - finalHtml.append("\n"); - finalHtml - .append(" \n"); - finalHtml.append("\n"); - finalHtml - .append("\n"); - finalHtml.append("\n"); - finalHtml.append("\n"); - finalHtml.append("\n"); - finalHtml.append("

" + galleryTitle + "

\n"); - - finalHtml.append("

"); + if (doHtmlHeaderAndFooter) { + // page header + finalHtml.append("\n"); + finalHtml.append("\n"); + finalHtml + .append(" \n"); + finalHtml.append("\n"); + finalHtml + .append("\n"); + finalHtml.append("\n"); + finalHtml.append("\n"); + finalHtml.append("\n"); + } + + if (showTitle) + finalHtml + .append("

" + galleryTitle + "

\n"); + + finalHtml.append("

"); for (final String p : path) finalHtml.append(" / " + p); finalHtml.append("

\n"); @@ -264,7 +270,8 @@ public class MixedLayout implements Layout { finalHtml.append(filesHtml.toString()); finalHtml.append("\n\n"); - finalHtml.append("
\n"); + if (doHtmlHeaderAndFooter) + finalHtml.append("
\n"); return finalHtml.toString(); } -- 2.20.1