From 5404ccee528f0fb68cdc12e2db05ebef39ab7539 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Fri, 1 Jul 2016 14:00:02 +0200 Subject: [PATCH] added header file --- src/main/java/Main.java | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/main/java/Main.java b/src/main/java/Main.java index ea54abe..5ce9912 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -5,9 +5,12 @@ import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.ArrayList; import java.util.HashMap; import java.util.Properties; +import java.util.logging.Logger; import org.asciidoctor.Asciidoctor; import org.asciidoctor.Asciidoctor.Factory; @@ -22,7 +25,8 @@ import com.rometools.rome.io.FeedException; import com.rometools.rome.io.SyndFeedOutput; public class Main { - private static String KEY_HTML_HEADER = "html.header"; + private static Logger LOG = Logger.getLogger(Main.class.getSimpleName()); + private static String KEY_HTML_HEADER_FILE = "html.header.file"; private static File toHTMLFile(File dir, File adoc) { int idx; @@ -48,8 +52,20 @@ public class Main { return ret; } - private static String getHTMLHeader(Properties props) { - return null; + private static String getHTMLHeader(Properties props) throws IOException { + String fileName; + File f; + + fileName = props.getProperty(KEY_HTML_HEADER_FILE); + + if (fileName == null) { + LOG.info(KEY_HTML_HEADER_FILE + " is not set"); + return null; + } + + f = new File(fileName); + return new String(Files.readAllBytes(f.toPath()), + StandardCharsets.UTF_8); } public static void main(String[] args) throws FileNotFoundException, IOException, FeedException { @@ -87,6 +103,9 @@ public class Main { news = new StringBuffer(); news.append("\n"); + + getHTMLHeader(props); + news.append("\n"); for (File adoc: adocs) { if (!adoc.getName().endsWith(".adoc")) @@ -126,5 +145,6 @@ public class Main { output.output(feed, new File(outDir, "feed.xml")); System.out.println(news.toString()); + Files.write(new File(outDir, "news.html").toPath(), news.toString().getBytes()); } } \ No newline at end of file -- 2.7.4