Possibility to disable HTML header and footer and title.
authorSvjatoslav Agejenko <n0@n0-Aspire-8920.(none)>
Sun, 3 Feb 2013 10:51:53 +0000 (12:51 +0200)
committerSvjatoslav Agejenko <n0@n0-Aspire-8920.(none)>
Sun, 3 Feb 2013 10:51:53 +0000 (12:51 +0200)
src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java
src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java
src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java
src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java

index 3a48b67..4e1b2f2 100755 (executable)
@@ -144,7 +144,7 @@ public class FilesystemIndexer extends AbstractIndexer {
                                        indexForLayout(layout);
 
                                        IOHelper.overwriteFileIfContentDiffers(indexFile, layout
-                                                       .getHtml().getBytes());
+                                                       .getHtml(true, true).getBytes());
                                }
                        } catch (final Exception e) {
                                logger.error("Error writing index file to:" + indexFilePath, e);
index 88de6ce..5110b3e 100755 (executable)
@@ -57,7 +57,8 @@ public interface Layout {
         * After necessary files have been enlisted for particular directory, use
         * this method to retrieve generated HTML result.
         */
-       public String getHtml();
+       public String getHtml(final boolean showTitle,
+                       final boolean doHtmlHeaderAndFooter);
 
        /**
         * Initialize layout for particular directory.
index 29ceac1..d4fd7e3 100644 (file)
@@ -44,7 +44,7 @@ public class WebIndexer extends AbstractIndexer {
 
                compileHtml(layout, metadata);
 
-               return layout.getHtml();
+               return layout.getHtml(false, false);
        }
 
        public DirectoryMetadata getMetadataForPath(final String requestPath)
index 4c00985..c51d7fa 100755 (executable)
@@ -219,25 +219,31 @@ public class MixedLayout implements Layout {
 
        /** {@inheritDoc} */
        @Override
-       public String getHtml() {
+       public String getHtml(final boolean showTitle,
+                       final boolean doHtmlHeaderAndFooter) {
 
                // assemble final page HTML
                final StringBuffer finalHtml = new StringBuffer();
 
-               // page header
-               finalHtml.append("<HTML>\n");
-               finalHtml.append("<HEAD>\n");
-               finalHtml
-                               .append("    <meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\"/>\n");
-               finalHtml.append("</HEAD>\n");
-               finalHtml
-                               .append("<BODY bgcolor=\"#000000\" alink=\"#50ffff\" link=\"#50ffff\" vlink=\"#ff50ff\" text=\"#ffffff\">\n");
-               finalHtml.append("<!-- " + Constants.HTML_MAGIC_STRING + " -->\n");
-               finalHtml.append("<!-- " + Constants.HTML_MEMO + " -->\n");
-               finalHtml.append("<FONT color=\"#ffffff\">\n");
-               finalHtml.append("<CENTER><H1>" + galleryTitle + "</H1>\n");
-
-               finalHtml.append("<H2>");
+               if (doHtmlHeaderAndFooter) {
+                       // page header
+                       finalHtml.append("<HTML>\n");
+                       finalHtml.append("<HEAD>\n");
+                       finalHtml
+                                       .append("    <meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=UTF-8\"/>\n");
+                       finalHtml.append("</HEAD>\n");
+                       finalHtml
+                                       .append("<BODY bgcolor=\"#000000\" alink=\"#50ffff\" link=\"#50ffff\" vlink=\"#ff50ff\" text=\"#ffffff\">\n");
+                       finalHtml.append("<!-- " + Constants.HTML_MAGIC_STRING + " -->\n");
+                       finalHtml.append("<!-- " + Constants.HTML_MEMO + " -->\n");
+                       finalHtml.append("<font color=\"#ffffff\">\n");
+               }
+
+               if (showTitle)
+                       finalHtml
+                                       .append("<CENTER><H1>" + galleryTitle + "</H1></CENTER>\n");
+
+               finalHtml.append("<CENTER><H2>");
                for (final String p : path)
                        finalHtml.append(" / " + p);
                finalHtml.append("</H2></CENTER>\n");
@@ -264,7 +270,8 @@ public class MixedLayout implements Layout {
                finalHtml.append(filesHtml.toString());
                finalHtml.append("\n</TABLE>\n");
 
-               finalHtml.append("</font></BODY></HTML>\n");
+               if (doHtmlHeaderAndFooter)
+                       finalHtml.append("</font></BODY></HTML>\n");
 
                return finalHtml.toString();
        }