possilibity to generate HTML while embedded on the web site
[meviz.git] / src / main / java / eu / svjatoslav / meviz / htmlindexer / layouts / MixedLayout.java
index f54b72f..40286e9 100755 (executable)
@@ -44,6 +44,8 @@ public class MixedLayout implements Layout {
 
        private AbstractIndexer indexer;
 
+       private String pathPrefix;
+
        public void columnAdded() {
                currentColumn++;
                if (currentColumn > horizontalColumnsLimit) {
@@ -57,9 +59,8 @@ public class MixedLayout implements Layout {
        @Override
        public void enlistDirectory(final AbstractFile directory) {
                dirHtml.append("<TR>");
-               dirHtml.append("<TD><b><a href=\"" + directory.fileName
-                               + "/index.html\"> ==&gt; " + directory.fileName
-                               + "</a></b></TD>");
+               dirHtml.append("<TD><b><a href=\"" + indexer.getDirectoryUrl(directory) + "\"> ==&gt; "
+                               + directory.fileName + "</a></b></TD>");
                dirHtml.append("</TR>\n");
 
        }
@@ -73,8 +74,8 @@ public class MixedLayout implements Layout {
                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("&nbsp;&nbsp;("
                                + FilePathParser.getFileSizeDescription(file.getFileLength())
                                + ")</TD>\n");
@@ -105,7 +106,8 @@ public class MixedLayout implements Layout {
                        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)
@@ -158,14 +160,17 @@ public class MixedLayout implements Layout {
                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");
@@ -179,7 +184,8 @@ public class MixedLayout implements Layout {
                                                + FilePathParser
                                                                .getFileNameWithoutExtension(file.fileName)
                                                + "<b/>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
-               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");
@@ -258,10 +264,14 @@ public class MixedLayout implements Layout {
 
        @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() {