From bc50d9d413e133d50fbab07a234d476b680d4185 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sat, 3 Jan 2015 16:09:03 +0200 Subject: [PATCH] possibility to include header HTML --- .../meviz/htmlindexer/FilesystemIndexer.java | 8 +- .../svjatoslav/meviz/htmlindexer/Layout.java | 7 +- .../meviz/htmlindexer/WebIndexer.java | 14 +-- .../htmlindexer/layouts/MixedLayout.java | 98 ++++++++++--------- .../metadata/DirectoryMetadata.java | 11 ++- 5 files changed, 80 insertions(+), 58 deletions(-) diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java index 6c672b1..f7cb130 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java @@ -102,7 +102,7 @@ public class FilesystemIndexer extends AbstractIndexer { compileHtml(layout, metadata); IOHelper.overwriteFileIfContentDiffers(indexFile, layout - .getHtml(true, true).getBytes()); + .getHtml(true, true, metadata).getBytes()); } } catch (final Exception e) { logger.error("Error writing index file. ", e); @@ -144,7 +144,7 @@ public class FilesystemIndexer extends AbstractIndexer { validMetadataFiles.add(thumbnailFileName); final File thumbnailFile = new File( Utils.getThumbnailsDirectoryPath(directoryToIndex) - + thumbnailFileName); + + thumbnailFileName); if (!thumbnailFile.exists()) { @@ -156,7 +156,7 @@ public class FilesystemIndexer extends AbstractIndexer { desiredDimension.getAwtDimension()); } return Constants.THUMBNAILS_DIRECTORY_NAME + "/" - + UrlParamEncoder.encode(thumbnailFileName); + + UrlParamEncoder.encode(thumbnailFileName); } public void initializeLayouts() { @@ -182,7 +182,7 @@ public class FilesystemIndexer extends AbstractIndexer { metadataFile = new File( Utils.getThumbnailsDirectoryPath(directoryToIndex) - + Constants.METADATA_FILE_NAME); + + Constants.METADATA_FILE_NAME); metadata = MetadadaHelper.initDirectoryMetadata(metadataFile); } diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java index e29cb11..b41d83a 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java @@ -9,6 +9,7 @@ package eu.svjatoslav.meviz.htmlindexer; +import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.List; @@ -62,9 +63,13 @@ public interface Layout { /** * After necessary files have been enlisted for particular directory, use * this method to retrieve generated HTML result. + * + * @param metadata + * @throws IOException */ public String getHtml(final boolean showTitle, - final boolean doHtmlHeaderAndFooter); + final boolean doHtmlHeaderAndFooter, DirectoryMetadata metadata) + throws IOException; /** * 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 6530e70..acc1a28 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java @@ -33,7 +33,7 @@ public class WebIndexer extends AbstractIndexer { } public String getHtml(String requestPath) throws MalformedURLException, - IOException, ClassNotFoundException { + IOException, ClassNotFoundException { if (requestPath == null) requestPath = ""; @@ -46,11 +46,11 @@ public class WebIndexer extends AbstractIndexer { requestPath); layout.init("Photos", context.getLocalPathComponents(), this, context); - final DirectoryMetadata metadata = getMetadataForPath(requestPath); + final DirectoryMetadata directory = getMetadataForPath(requestPath); - compileHtml(layout, metadata); + compileHtml(layout, directory); - return layout.getHtml(false, false); + return layout.getHtml(false, false, directory); } public DirectoryMetadata getMetadataForPath(final String requestPath) @@ -110,14 +110,14 @@ public class WebIndexer extends AbstractIndexer { // file path if (picture.getDimensions().equals(desiredDimension)) return context.getGlobalUrl() + context.getLocalUrl() + "/" - + picture.fileName; + + picture.fileName; final String thumbnailFileName = picture .getRelativeThumbnailFileName(desiredDimension); return context.getGlobalUrl() + context.getLocalUrl() + "/" - + Constants.THUMBNAILS_DIRECTORY_NAME + "/" - + UrlParamEncoder.encode(thumbnailFileName); + + Constants.THUMBNAILS_DIRECTORY_NAME + "/" + + UrlParamEncoder.encode(thumbnailFileName); } } 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 4e6b5bf..ddacb56 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java @@ -9,6 +9,7 @@ package eu.svjatoslav.meviz.htmlindexer.layouts; +import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.List; @@ -81,7 +82,7 @@ public class MixedLayout implements Layout { "Error generating thumbnails for image file: " + e.toString() + ", thumbnail generation skipped, enlisting as ordinary file instead.", - e); + e); enlistFile(picture, parentDirectoryMetadata); } } @@ -134,7 +135,7 @@ public class MixedLayout implements Layout { @Override public void enlistOgv(final AbstractFile abstractFile, final DirectoryMetadata parentDirectoryMetadata) - throws UnsupportedEncodingException { + throws UnsupportedEncodingException { final GeneralFile file = (GeneralFile) abstractFile; @@ -142,22 +143,22 @@ public class MixedLayout implements Layout { // watchable video filesHtml - .append("