added footer support master
authorJean-Philippe Orsini <orsinije@fr.ibm.com>
Tue, 12 Jul 2016 12:53:11 +0000 (14:53 +0200)
committerJean-Philippe Orsini <orsinije@fr.ibm.com>
Tue, 12 Jul 2016 12:53:11 +0000 (14:53 +0200)
src/main/java/net/wpitchoune/asciidoctor/Configuration.java
src/main/java/net/wpitchoune/asciidoctor/HTML.java

index 64668a5..e8c2a84 100644 (file)
@@ -8,6 +8,7 @@ import java.util.Properties;
 
 public final class Configuration {
        private static final String KEY_HTML_HEADER_FILE = "html.header.file";
+       private static final String KEY_HTML_FOOTER_FILE = "html.footer.file";
        private static final String KEY_FEED_TITLE = "feed.title";
        private static final String KEY_FEED_LINK = "feed.link";
        private static final String KEY_FEED_DESCRIPTION = "feed.description";
@@ -44,6 +45,17 @@ public final class Configuration {
                
                return new File(str);
         }
+
+        public File getHTMLFooterFile() {
+                String str;
+                
+                str = properties.getProperty(KEY_HTML_FOOTER_FILE);
+                                
+                if (str == null)
+                        return null;
+                
+                return new File(str);
+        }
         
         public static Configuration load(File f) throws IOException {
                Properties props;
index 8c3bc0b..9e150bf 100644 (file)
@@ -76,9 +76,11 @@ public final class HTML {
        }   
        
         
-       public static void appendHTMLFooter(StringBuffer sb) {
-               sb.append("</body>\n");
-               sb.append("</html>");           
+       private void appendHTMLFooter(StringBuffer sb) throws IOException {
+               sb.append(new String(Files.readAllBytes(config.getHTMLFooterFile().toPath()),
+                                    StandardCharsets.UTF_8));
+               appendEndTag(sb, "body", 1, true);
+               appendEndTag(sb, "html", 0, false);
        }                     
        
        public String toHTML(SyndEntry entry) throws IOException {
@@ -181,7 +183,7 @@ public final class HTML {
                                
                buf.append("</div>\n");
                
-               HTML.appendHTMLFooter(buf);
+               appendHTMLFooter(buf);
                
                return buf.toString();
        }