X-Git-Url: http://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2FMain.java;h=64b4d8820b65610dd7cbb20e25e957fc9d881dc5;hb=76238691b4a28a8d248bad0f17245ac273ff3ace;hp=5ce991290e49713252086aba92bd4d9892928ea5;hpb=5404ccee528f0fb68cdc12e2db05ebef39ab7539;p=asciidoctor_to_rss.git diff --git a/src/main/java/Main.java b/src/main/java/Main.java index 5ce9912..64b4d88 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -25,8 +25,9 @@ import com.rometools.rome.io.FeedException; import com.rometools.rome.io.SyndFeedOutput; public class Main { - private static Logger LOG = Logger.getLogger(Main.class.getSimpleName()); - private static String KEY_HTML_HEADER_FILE = "html.header.file"; + private static final Logger LOG = Logger.getLogger(Main.class.getSimpleName()); + private static final String KEY_HTML_HEADER_FILE = "html.header.file"; + private static final String KEY_FEED_TITLE = "feed.title"; private static File toHTMLFile(File dir, File adoc) { int idx; @@ -52,7 +53,12 @@ public class Main { return ret; } - private static String getHTMLHeader(Properties props) throws IOException { + private static String getFeedTitle(Properties props) { + return props.getProperty(KEY_FEED_TITLE); + } + + private static void appendHTMLHeader(StringBuffer sb, Properties props) + throws IOException { String fileName; File f; @@ -60,12 +66,15 @@ public class Main { if (fileName == null) { LOG.info(KEY_HTML_HEADER_FILE + " is not set"); - return null; + return ; } f = new File(fileName); - return new String(Files.readAllBytes(f.toPath()), - StandardCharsets.UTF_8); + + sb.append("\n"); + sb.append(new String(Files.readAllBytes(f.toPath()), + StandardCharsets.UTF_8)); + sb.append("\n"); } public static void main(String[] args) throws FileNotFoundException, IOException, FeedException { @@ -95,18 +104,28 @@ public class Main { asciidoctor = Factory.create(); feed = new SyndFeedImpl(); - feed.setTitle(props.getProperty("feed.title")); + feed.setTitle(getFeedTitle(props)); feed.setDescription(props.getProperty("feed.description")); feed.setLink(props.getProperty("feed.link")); entries = new ArrayList(); news = new StringBuffer(); - news.append("\n"); + news.append("\n"); + news.append("\n"); - getHTMLHeader(props); + appendHTMLHeader(news, props); news.append("\n"); + + news.append(""); + + news.append("
\n"); + for (File adoc: adocs) { if (!adoc.getName().endsWith(".adoc")) continue; @@ -135,6 +154,8 @@ public class Main { news.append(desc.toString()); news.append("\n
\n"); } + + news.append("\n"); news.append("\n"); news.append("\n"); @@ -147,4 +168,4 @@ public class Main { System.out.println(news.toString()); Files.write(new File(outDir, "news.html").toPath(), news.toString().getBytes()); } -} \ No newline at end of file +}