From: Svjatoslav Agejenko Date: Fri, 2 Jan 2015 22:14:25 +0000 (+0200) Subject: preparations to add HTML snippets into generated HTML X-Git-Tag: meviz-1.0~35 X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=commitdiff_plain;h=fc6fdf1d4343a5b19c1a6213af272e9df40e3442;p=meviz.git preparations to add HTML snippets into generated HTML --- diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/AbstractIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/AbstractIndexer.java index 84a5868..fff1b68 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/AbstractIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/AbstractIndexer.java @@ -36,21 +36,21 @@ public abstract class AbstractIndexer { public void compileHtml(final Layout layout, final DirectoryMetadata directory) - throws UnsupportedEncodingException { + throws UnsupportedEncodingException { for (final AbstractFile file : directory.getFiles()) if (file instanceof GeneralFile) { final String fileExtension = file.getFileExtension(); if ("ogv".equals(fileExtension)) - layout.enlistOgv(file); + layout.enlistOgv(file, directory); else - layout.enlistFile(file); + layout.enlistFile(file, directory); } else if (file instanceof Picture) - layout.enlistImage((Picture) file); + layout.enlistImage((Picture) file, directory); else if (file instanceof DirectoryFile) - layout.enlistDirectory(file); + layout.enlistDirectory(file, directory); } diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java index 61b9027..6c672b1 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java @@ -12,7 +12,6 @@ package eu.svjatoslav.meviz.htmlindexer; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -25,8 +24,6 @@ import eu.svjatoslav.meviz.htmlindexer.metadata.Dimension; import eu.svjatoslav.meviz.htmlindexer.metadata.DirectoryMetadata; import eu.svjatoslav.meviz.htmlindexer.metadata.MetadadaHelper; import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.AbstractFile; -import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.DirectoryFile; -import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.GeneralFile; import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.Picture; /** @@ -102,7 +99,7 @@ public class FilesystemIndexer extends AbstractIndexer { if (canWriteIndexFile(indexFile)) { - indexForLayout(layout); + compileHtml(layout, metadata); IOHelper.overwriteFileIfContentDiffers(indexFile, layout .getHtml(true, true).getBytes()); @@ -147,7 +144,7 @@ public class FilesystemIndexer extends AbstractIndexer { validMetadataFiles.add(thumbnailFileName); final File thumbnailFile = new File( Utils.getThumbnailsDirectoryPath(directoryToIndex) - + thumbnailFileName); + + thumbnailFileName); if (!thumbnailFile.exists()) { @@ -159,25 +156,7 @@ public class FilesystemIndexer extends AbstractIndexer { desiredDimension.getAwtDimension()); } return Constants.THUMBNAILS_DIRECTORY_NAME + "/" - + UrlParamEncoder.encode(thumbnailFileName); - } - - public void indexForLayout(final Layout layout) - throws UnsupportedEncodingException { - - for (final AbstractFile abstractFile : metadata.getFiles()) - if (abstractFile instanceof GeneralFile) { - - if (isOgv(abstractFile.getFileExtension())) - layout.enlistOgv(abstractFile); - else - layout.enlistFile(abstractFile); - - } else if (abstractFile instanceof Picture) - layout.enlistImage((Picture) abstractFile); - else if (abstractFile instanceof DirectoryFile) - layout.enlistDirectory(abstractFile); - + + UrlParamEncoder.encode(thumbnailFileName); } public void initializeLayouts() { @@ -203,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 8df469e..e29cb11 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java @@ -12,6 +12,7 @@ package eu.svjatoslav.meviz.htmlindexer; import java.io.UnsupportedEncodingException; import java.util.List; +import eu.svjatoslav.meviz.htmlindexer.metadata.DirectoryMetadata; import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.AbstractFile; import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.Picture; @@ -27,24 +28,28 @@ public interface Layout { /** * Enlist directory. */ - public void enlistDirectory(AbstractFile directory); + public void enlistDirectory(AbstractFile directory, + DirectoryMetadata parentDirectoryMetadata); /** * Enlist simple file. */ - public void enlistFile(AbstractFile file); + public void enlistFile(AbstractFile file, + DirectoryMetadata parentDirectoryMetadata); /** * Enlist image file. */ - public void enlistImage(Picture picture); + public void enlistImage(Picture picture, + DirectoryMetadata parentDirectoryMetadata); /** * Enlist video in OGV format. * * @throws UnsupportedEncodingException */ - public void enlistOgv(AbstractFile file) + public void enlistOgv(AbstractFile file, + DirectoryMetadata parentDirectoryMetadata) throws UnsupportedEncodingException; /** 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 f7eee2c..08a308b 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java @@ -21,6 +21,7 @@ import eu.svjatoslav.meviz.htmlindexer.Constants; import eu.svjatoslav.meviz.htmlindexer.IndexingContext; import eu.svjatoslav.meviz.htmlindexer.Layout; import eu.svjatoslav.meviz.htmlindexer.metadata.Dimension; +import eu.svjatoslav.meviz.htmlindexer.metadata.DirectoryMetadata; import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.AbstractFile; import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.GeneralFile; import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.Picture; @@ -44,7 +45,8 @@ public class MixedLayout implements Layout { private IndexingContext indexingContext; @Override - public void enlistDirectory(final AbstractFile directory) { + public void enlistDirectory(final AbstractFile directory, + final DirectoryMetadata parentDirectoryMetadata) { dirHtml.append(""); dirHtml.append("