package eu.svjatoslav.meviz.htmlindexer.layouts;
import eu.svjatoslav.commons.file.FilePathParser;
-import eu.svjatoslav.meviz.htmlindexer.*;
+import eu.svjatoslav.meviz.htmlindexer.AbstractIndexer;
+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;
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.AbstractIndexer.getVideoType;
+import static eu.svjatoslav.meviz.htmlindexer.Utils.urlEncode;
+
public class MixedLayout implements Layout {
public static final String encoding = "UTF-8";
filesHtml.append("<div style=\"clear: both;\"><a href=\""
+ indexingContext.getGlobalUrl()
- + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
+ + urlEncode(indexingContext.getLocalUrl() + "/"
+ fullFileName) + "\">" + fullFileName + "</a>\n");
filesHtml.append(" ("
+ FilePathParser.getFileSizeDescription(file.getFileLength())
// clickable image thumbnail
filesHtml.append("<a href=\""
+ indexingContext.getGlobalUrl()
- + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
+ + urlEncode(indexingContext.getLocalUrl() + "/"
+ picture.fileName) + "\">\n");
filesHtml.append("<img border=\"0\" src=\""
// file name
filesHtml.append("<b>"
- + FilePathParser.getFileNameWithoutExtension(picture.fileName)
+ + getFileNameWithoutExtension(picture.fileName)
+ "</b><br/>");
// links to thumbnails of various sizes
filesHtml.append("</div>");
}
- /**
- * {@inheritDoc}
- */
- @Override
- public void enlistOgv(final AbstractFile abstractFile,
- final DirectoryMetadata parentDirectoryMetadata) {
-
- final GeneralFile file = (GeneralFile) abstractFile;
-
- filesHtml.append("<div style=\"margin: 30px; clear: both;\">");
-
- // watchable video
- filesHtml
- .append("<video preload=\"metadata\" controls=\"controls\" tabindex=\"0\">\n");
- filesHtml
- .append("<source type=\"video/ogg\" codecs=\"theora, vorbis\" src=\""
- + indexingContext.getGlobalUrl()
- + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
- + file.fileName) + "\">\n");
- filesHtml.append("</source>\n");
- filesHtml.append("</video>\n");
- filesHtml.append("<br/>\n");
-
- // video title
- filesHtml
- .append("Video: <b>"
- + FilePathParser
- .getFileNameWithoutExtension(file.fileName)
- + "<b/> ");
-
- // video download link
- filesHtml.append("<a href=\""
- + indexingContext.getGlobalUrl()
- + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
- + file.fileName) + "\">download as OGV file</a>");
-
- filesHtml.append("</div>\n");
-
- filesHtml.append("\n");
-
- }
-
/**
* {@inheritDoc}
*/
}
@Override
- public void enlistWebm(AbstractFile abstractFile,
- DirectoryMetadata directory) {
- final GeneralFile file = (GeneralFile) abstractFile;
+ public void enlistVideo(AbstractFile file) {
- filesHtml.append("<div style=\"margin: 30px; clear: both;\">");
+ filesHtml.append("<div style=\"margin: 30px; clear: both;\">\n");
// watchable video
+ filesHtml.append(" <video width=\"640\" controls>\n");
+ filesHtml.append(" <source src=\"" + getFileUrl(file) + "\" type=\""
+ + getVideoType(file.getFileExtension()) + "\"/>\n");
+ filesHtml.append(" </video>\n");
- String fileUrl = indexingContext.getGlobalUrl()
- + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
- + file.fileName);
-
- filesHtml.append("<video controls>\n");
- filesHtml.append(" <source src=\"" + fileUrl
- + "\" type='video/webm;codecs=\"vp8, opus\"'/>\n");
- filesHtml.append("</video>\n");
- filesHtml.append("<br/>\n");
+ filesHtml.append(" <br/>\n");
// video title
- filesHtml
- .append("Video: <b>"
- + FilePathParser
- .getFileNameWithoutExtension(file.fileName)
+ filesHtml.append(" Video: <b>"
+ + getFileNameWithoutExtension(file.fileName)
+ "<b/> ");
// video download link
- filesHtml.append("<a href=\""
- + indexingContext.getGlobalUrl()
- + Utils.urlEncode(indexingContext.getLocalUrl() + "/"
- + file.fileName) + "\">download as WebM file</a>");
+ filesHtml.append(" <a href=\"" + getFileUrl(file) + "\">download</a>\n");
filesHtml.append("</div>\n");
filesHtml.append("\n");
}
+
+
+ private String getFileUrl(AbstractFile file) {
+ return indexingContext.getGlobalUrl()
+ + urlEncode(indexingContext.getLocalUrl() + "/"
+ + file.fileName);
+ }
}