final String fileExtension = file.getFileExtension();
if ("ogv".equals(fileExtension))
- layout.enlistOgv((GeneralFile) file);
+ layout.enlistOgv(file);
else
layout.enlistFile(file);
}
+ public abstract String getDirectoryUrl(final AbstractFile directory);
+
public abstract String getThumbnailPath(Picture picture,
final Dimension desiredDimension);
}
}
+ @Override
+ public String getDirectoryUrl(final AbstractFile directory) {
+ return directory.fileName + "/index.html";
+ }
+
public String[] getSubPath(final File file) {
final String[] subPath = new String[pathElements.length + 1];
layouts.add(new MixedLayout());
for (final Layout layout : layouts)
- layout.init(indexingOptions.galleryTitle, pathElements, this);
+ layout.init(indexingOptions.galleryTitle, pathElements, this, "");
}
public void initializeThumbnailsDirectory() {
* Initialize layout for particular directory.
*/
public void init(String galleryTitle, String[] path,
- final AbstractIndexer indexer);
+ final AbstractIndexer indexer, final String pathPrefix);
}
--- /dev/null
+package eu.svjatoslav.meviz.htmlindexer;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import eu.svjatoslav.meviz.htmlindexer.layouts.MixedLayout;
+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.Picture;
+
+public class WebIndexer extends AbstractIndexer {
+
+ private final MixedLayout layout = new MixedLayout();
+ private final String localPrefix;
+ private final String globalPrefix;
+
+ public WebIndexer(final String globalPrefix, final String localPrefix) {
+ this.globalPrefix = globalPrefix;
+ this.localPrefix = localPrefix;
+ }
+
+ @Override
+ public String getDirectoryUrl(final AbstractFile directory) {
+ return "photos.jsp?path=/" + directory.fileName;
+ }
+
+ public String getHtml(final String path) throws MalformedURLException,
+ IOException, ClassNotFoundException {
+
+ layout.init("Photos", new String[] {}, this, localPrefix);
+
+ final DirectoryMetadata metadata = getMetadataForPath();
+
+ compileHtml(layout, metadata);
+
+ return layout.getHtml();
+ }
+
+ public DirectoryMetadata getMetadataForPath() throws IOException,
+ MalformedURLException, ClassNotFoundException {
+
+ final BufferedInputStream in = new BufferedInputStream(
+ new URL(globalPrefix + localPrefix
+ + ".thumbnails/metadata_6.dat").openStream());
+
+ final ObjectInputStream oin = new ObjectInputStream(in);
+ final DirectoryMetadata directory = (DirectoryMetadata) oin
+ .readObject();
+ in.close();
+
+ return directory;
+ }
+
+ @Override
+ public String getThumbnailPath(final Picture picture,
+ final Dimension desiredDimension) {
+
+ // in case thumbnail size was equal to original, then return original
+ // file path
+ if (picture.getDimensions().equals(desiredDimension))
+ return localPrefix + picture.fileName;
+
+ final String thumbnailFileName = picture
+ .getRelativeThumbnailFileName(desiredDimension);
+
+ return localPrefix + Constants.THUMBNAILS_DIRECTORY_NAME + "/"
+ + thumbnailFileName;
+ }
+
+}
private AbstractIndexer indexer;
+ private String pathPrefix;
+
public void columnAdded() {
currentColumn++;
if (currentColumn > horizontalColumnsLimit) {
@Override
public void enlistDirectory(final AbstractFile directory) {
dirHtml.append("<TR>");
- dirHtml.append("<TD><b><a href=\"" + directory.fileName
- + "/index.html\"> ==> " + directory.fileName
- + "</a></b></TD>");
+ dirHtml.append("<TD><b><a href=\"" + indexer.getDirectoryUrl(directory) + "\"> ==> "
+ + directory.fileName + "</a></b></TD>");
dirHtml.append("</TR>\n");
}
filesHtml.append("<TR>\n");
filesHtml.append(" <TD colspan=\""
+ String.valueOf(horizontalColumnsLimit) + "\"><a href=\""
- + UrlParamEncoder.encode(fullFileName) + "\">" + fullFileName
- + "</a>\n");
+ + UrlParamEncoder.encode(pathPrefix + fullFileName) + "\">"
+ + fullFileName + "</a>\n");
filesHtml.append(" ("
+ FilePathParser.getFileSizeDescription(file.getFileLength())
+ ")</TD>\n");
startcolumn();
filesHtml.append("<TD><center><a href=\""
- + UrlParamEncoder.encode(picture.fileName) + "\">\n");
+ + UrlParamEncoder.encode(pathPrefix + picture.fileName)
+ + "\">\n");
filesHtml.append("<img border=\"0\" src=\""
+ UrlParamEncoder.encode(listingThumbnailPath)
filesHtml.append("<video controls=\"controls\" tabindex=\"0\">\n");
filesHtml
.append("<source type=\"video/ogg\" codecs=\"theora, vorbis\" src=\""
- + UrlParamEncoder.encode(file.fileName) + "\">\n");
+ + UrlParamEncoder.encode(pathPrefix + file.fileName)
+ + "\">\n");
filesHtml.append("</source>\n");
// if browser cannot play video directry, fall back to java Applet
filesHtml
.append("<applet code=\"com.fluendo.player.Cortado.class\" archive=\"http://theora.org/cortado.jar\" width=\"800\" height=\"600\">\n");
- filesHtml.append(" <param name=\"url\" value=\""
- + UrlParamEncoder.encode(file.fileName) + "\"/>\n");
+ filesHtml
+ .append(" <param name=\"url\" value=\""
+ + UrlParamEncoder.encode(pathPrefix + file.fileName)
+ + "\"/>\n");
filesHtml.append(" <param name=\"keepAspect\" value=\"true\"/>\n");
filesHtml.append(" <param name=\"autoPlay\" value=\"false\"/>\n");
filesHtml.append("</applet>\n");
+ FilePathParser
.getFileNameWithoutExtension(file.fileName)
+ "<b/> ");
- filesHtml.append("<a href=\"" + UrlParamEncoder.encode(file.fileName)
+ filesHtml.append("<a href=\""
+ + UrlParamEncoder.encode(pathPrefix + file.fileName)
+ "\">download as OGV</a>\n");
filesHtml.append("</TD></TR>\n");
@Override
public void init(final String galleryTitle, final String[] path,
- final AbstractIndexer indexer) {
+ final AbstractIndexer indexer, final String pathPrefix) {
this.indexer = indexer;
this.galleryTitle = galleryTitle;
this.path = path;
+ this.pathPrefix = pathPrefix;
+
+ dirHtml = new StringBuffer();
+ filesHtml = new StringBuffer();
}
public void startcolumn() {