From: Jean-Philippe Orsini Date: Fri, 1 Jul 2016 11:15:26 +0000 (+0200) Subject: Merge branch 'master' of ssh://git.wpitchoune.net/srv/git/asciidoctor_to_rss X-Git-Url: http://git.wpitchoune.net/gitweb/?p=asciidoctor_to_rss.git;a=commitdiff_plain;h=7ff881d6e99b144fa19f64618e84b47ec8a0a180;hp=-c Merge branch 'master' of ssh://git.wpitchoune.net/srv/git/asciidoctor_to_rss --- 7ff881d6e99b144fa19f64618e84b47ec8a0a180 diff --combined src/main/java/Main.java index 96b8407,ea54abe..6f97ae4 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@@ -22,7 -22,9 +22,9 @@@ import com.rometools.rome.io.FeedExcept import com.rometools.rome.io.SyndFeedOutput; public class Main { - private static File getHTMLFile(File dir, File adoc) { + private static String KEY_HTML_HEADER = "html.header"; + + private static File toHTMLFile(File dir, File adoc) { int idx; String name; @@@ -36,10 -38,24 +38,24 @@@ return new File(dir, name + ".html"); } + private static SyndContentImpl toSyndContentImpl(String description) { + SyndContentImpl ret; + + ret = new SyndContentImpl(); + ret.setType("text/html"); + ret.setValue(description); + + return ret; + } + + private static String getHTMLHeader(Properties props) { + return null; + } + public static void main(String[] args) throws FileNotFoundException, IOException, FeedException { File inDir, html, outDir; File[] adocs; - StringWriter sw; + StringWriter desc; Asciidoctor asciidoctor; SyndFeed feed; Properties props; @@@ -48,6 -64,7 +64,7 @@@ InputStream in; DocumentHeader h; SyndContentImpl c; + StringBuffer news; inDir = new File(args[0]); outDir = new File(args[1]); @@@ -68,34 -85,46 +85,46 @@@ entries = new ArrayList(); + news = new StringBuffer(); + news.append("\n"); + news.append("\n"); for (File adoc: adocs) { if (!adoc.getName().endsWith(".adoc")) continue; - sw = new StringWriter(); + desc = new StringWriter(); - html = getHTMLFile(outDir, adoc); + html = toHTMLFile(outDir, adoc); h = asciidoctor.readDocumentHeader(adoc); - asciidoctor.convert(new FileReader(adoc), sw, new HashMap()); + asciidoctor.convert(new FileReader(adoc), desc, new HashMap()); e = new SyndEntryImpl(); e.setTitle(h.getDocumentTitle().getMain()); e.setUri(props.getProperty("feed.baseurl") + "/" + html.getName()); - c = new SyndContentImpl(); - c.setType("text/html"); - c.setValue(sw.toString()); + c = toSyndContentImpl(desc.toString()); e.setDescription(c); entries.add(e); + + news.append("\n
\n"); + news.append("

"); + news.append(h.getDocumentTitle().getMain()); + news.append("

\n"); + news.append(desc.toString()); + news.append("\n
\n"); } + news.append("\n"); + news.append("\n"); feed.setEntries(entries); feed.setFeedType("rss_2.0"); SyndFeedOutput output = new SyndFeedOutput(); output.output(feed, new File(outDir, "feed.xml")); + + System.out.println(news.toString()); } --} ++}