X-Git-Url: http://www2.svjatoslav.eu/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Feu%2Fsvjatoslav%2Fmeviz%2Fhtmlindexer%2Flayouts%2FMixedLayout.java;h=49ffa7e4b734b39d8a595eabfc26c812750616fe;hb=35252da406b80b367bf8ff130991165c7e865687;hp=e20f875ed934fbb9a1e00de92a701dc248dd68bb;hpb=934d5b7cc3d7d4bbafda7fbb4fab47d54f1a8a91;p=meviz.git 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 e20f875..49ffa7e 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java @@ -1,26 +1,31 @@ /* * Meviz - Various tools collection to work with multimedia. - * Copyright (C) 2012 -- 2017, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu + * Copyright (C) 2012 -- 2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu * * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public License - * as published by the Free Software Foundation. - */ + * modify it under the terms of version 3 of the GNU Lesser General Public License + * or later as published by the Free Software Foundation. +*/ package eu.svjatoslav.meviz.htmlindexer.layouts; import eu.svjatoslav.commons.file.FilePathParser; -import eu.svjatoslav.meviz.htmlindexer.*; +import eu.svjatoslav.meviz.htmlindexer.indexer.AbstractIndexer; +import eu.svjatoslav.meviz.htmlindexer.Constants; +import eu.svjatoslav.meviz.htmlindexer.IndexingContext; 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; +import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.Video; import org.apache.log4j.Logger; import java.io.IOException; import java.util.List; +import static eu.svjatoslav.commons.file.FilePathParser.getFileNameWithoutExtension; +import static eu.svjatoslav.meviz.htmlindexer.Utils.urlEncode; + public class MixedLayout implements Layout { public static final String encoding = "UTF-8"; @@ -58,7 +63,7 @@ public class MixedLayout implements Layout { filesHtml.append("
" + fullFileName + "\n"); filesHtml.append("  (" + FilePathParser.getFileSizeDescription(file.getFileLength()) @@ -109,7 +114,7 @@ public class MixedLayout implements Layout { // clickable image thumbnail filesHtml.append("\n"); filesHtml.append("" - + FilePathParser.getFileNameWithoutExtension(picture.fileName) + + getFileNameWithoutExtension(picture.fileName) + "
"); // links to thumbnails of various sizes @@ -126,48 +131,6 @@ public class MixedLayout implements Layout { filesHtml.append("
"); } - /** - * {@inheritDoc} - */ - @Override - public void enlistOgv(final AbstractFile abstractFile, - final DirectoryMetadata parentDirectoryMetadata) { - - final GeneralFile file = (GeneralFile) abstractFile; - - filesHtml.append("
"); - - // watchable video - filesHtml - .append("\n"); - filesHtml.append("
\n"); - - // video title - filesHtml - .append("Video: " - + FilePathParser - .getFileNameWithoutExtension(file.fileName) - + "            "); - - // video download link - filesHtml.append("
download as OGV file"); - - filesHtml.append("
\n"); - - filesHtml.append("\n"); - - } - /** * {@inheritDoc} */ @@ -189,17 +152,8 @@ public class MixedLayout implements Layout { // assemble final page HTML final StringBuilder html = new StringBuilder(); - if (doHtmlHeaderAndFooter) { - // page header - html.append("\n"); - html.append("\n"); - html.append(" \n"); - html.append("\n"); - html.append("\n"); - html.append("\n"); - html.append("\n"); - html.append("\n"); - } + if (doHtmlHeaderAndFooter) + appendHtmlHeader(html); if (showTitle) html.append("

" + galleryTitle + "

\n"); @@ -210,11 +164,27 @@ public class MixedLayout implements Layout { html.append(filesHtml.toString()); if (doHtmlHeaderAndFooter) - html.append("
\n"); + appendHtmlFooter(html); return html.toString(); } + private void appendHtmlFooter(StringBuilder html) { + html.append("\n"); + } + + private void appendHtmlHeader(StringBuilder html) { + // page header + html.append("\n"); + html.append("\n"); + html.append(" \n"); + html.append("\n"); + html.append("\n"); + html.append("\n"); + html.append("\n"); + html.append("\n"); + } + private String getImageThumbnailUrl(final Picture picture) { final Dimension imageSize = picture.getDimensions(); @@ -271,39 +241,34 @@ public class MixedLayout implements Layout { } @Override - public void enlistWebm(AbstractFile abstractFile, - DirectoryMetadata directory) { - final GeneralFile file = (GeneralFile) abstractFile; + public void enlistVideo(Video video) { - filesHtml.append("
"); + filesHtml.append("
\n"); // watchable video + filesHtml.append(" \n"); - String fileUrl = indexingContext.getGlobalUrl() - + Utils.urlEncode(indexingContext.getLocalUrl() + "/" - + file.fileName); - - filesHtml.append("\n"); - filesHtml.append("
\n"); + filesHtml.append("
\n"); // video title - filesHtml - .append("Video: " - + FilePathParser - .getFileNameWithoutExtension(file.fileName) + filesHtml.append(" Video: " + + getFileNameWithoutExtension(video.fileName) + "            "); // video download link - filesHtml.append("download as WebM file"); + filesHtml.append(" download\n"); filesHtml.append("
\n"); filesHtml.append("\n"); } + + + private String getFileUrl(AbstractFile file) { + return indexingContext.getGlobalUrl() + + urlEncode(indexingContext.getLocalUrl() + "/" + + file.fileName); + } }