Merge branch 'master' of ssh://wpitchoune.net/srv/git/asciidoctor_to_rss
authorJean-Philippe Orsini <orsinije@fr.ibm.com>
Fri, 1 Jul 2016 12:00:16 +0000 (14:00 +0200)
committerJean-Philippe Orsini <orsinije@fr.ibm.com>
Fri, 1 Jul 2016 12:00:16 +0000 (14:00 +0200)
1  2 
src/main/java/Main.java

diff --combined 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;
                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 {
                
                news = new StringBuffer();
                news.append("<html>\n");
 +              
 +              getHTMLHeader(props);
 +              
                news.append("<body>\n");
                for (File adoc: adocs) {
                        if (!adoc.getName().endsWith(".adoc"))
                output.output(feed, new File(outDir, "feed.xml"));
        
                System.out.println(news.toString());
 +              Files.write(new File(outDir, "news.html").toPath(), news.toString().getBytes());
        }
- }
+ }