From: Jean-Philippe Orsini Date: Fri, 1 Jul 2016 12:00:16 +0000 (+0200) Subject: Merge branch 'master' of ssh://wpitchoune.net/srv/git/asciidoctor_to_rss X-Git-Url: http://git.wpitchoune.net/gitweb/?p=asciidoctor_to_rss.git;a=commitdiff_plain;h=c8adf3e9a509f2db077ff551fe49c9b3ccfd7dec;hp=-c Merge branch 'master' of ssh://wpitchoune.net/srv/git/asciidoctor_to_rss --- c8adf3e9a509f2db077ff551fe49c9b3ccfd7dec diff --combined src/main/java/Main.java index 5ce9912,6f97ae4..d012144 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@@ -5,12 -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; @@@ -25,8 -22,7 +25,8 @@@ import com.rometools.rome.io.FeedExcept 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; @@@ -52,20 -48,8 +52,20 @@@ 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 { @@@ -103,9 -87,6 +103,9 @@@ news = new StringBuffer(); news.append("\n"); + + getHTMLHeader(props); + news.append("\n"); for (File adoc: adocs) { if (!adoc.getName().endsWith(".adoc")) @@@ -145,6 -126,5 +145,6 @@@ output.output(feed, new File(outDir, "feed.xml")); System.out.println(news.toString()); + Files.write(new File(outDir, "news.html").toPath(), news.toString().getBytes()); } - } + }