X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fwpitchoune%2Fasciidoctor%2FMain.java;h=adbb92dd27d6684f3139844d0296405051c09604;hb=94281535899dbc050e86cea4f2eeca068cb5193e;hp=1e09ab05848de427c4130d9f22fd69306c9e0f79;hpb=af6778182487ef8a3a0603f31665314cd4b896f3;p=asciidoctor_to_rss.git diff --git a/src/main/java/net/wpitchoune/asciidoctor/Main.java b/src/main/java/net/wpitchoune/asciidoctor/Main.java index 1e09ab0..adbb92d 100644 --- a/src/main/java/net/wpitchoune/asciidoctor/Main.java +++ b/src/main/java/net/wpitchoune/asciidoctor/Main.java @@ -42,6 +42,7 @@ import com.rometools.rome.feed.synd.SyndEntry; import com.rometools.rome.feed.synd.SyndEntryImpl; import com.rometools.rome.feed.synd.SyndFeed; import com.rometools.rome.feed.synd.SyndFeedImpl; +import com.rometools.rome.feed.synd.SyndLinkImpl; import com.rometools.rome.io.FeedException; import com.rometools.rome.io.SyndFeedOutput; @@ -114,6 +115,7 @@ public class Main { private static void generateHTMLFileItem(File file, String title, String content, + String date, Configuration cfg) throws IOException { StringBuffer buf; @@ -126,6 +128,11 @@ public class Main { appendHTMLContentHeader(buf, title); buf.append("
\n"); + if (date != null) { + buf.append("
"); + buf.append(date); + buf.append("
"); + } buf.append(content); buf.append("
"); @@ -145,7 +152,7 @@ public class Main { DocumentHeader h; SyndContentImpl c; StringBuffer news; - String itemTitle, itemContent, itemURI; + String itemTitle, itemContent, itemURI, itemDate; inDir = new File(args[0]); outDir = new File(args[1]); @@ -179,7 +186,12 @@ public class Main { html = toHTMLFile(outDir, adoc); h = asciidoctor.readDocumentHeader(adoc); - + + if (h.getAttributes().get("date") == null) + itemDate = h.getAttributes().get("docdate").toString(); + else + itemDate = h.getAttributes().get("date").toString(); + asciidoctor.convert(new FileReader(adoc), desc, new HashMap()); itemTitle = h.getDocumentTitle().getMain(); @@ -191,7 +203,6 @@ public class Main { e.setUri(itemURI); e.setLink(itemURI); - c = toSyndContentImpl(itemContent); e.setDescription(c); @@ -205,7 +216,7 @@ public class Main { news.append(desc.toString()); news.append("\n"); - generateHTMLFileItem(html, itemTitle, itemContent, cfg); + generateHTMLFileItem(html, itemTitle, itemContent, itemDate, cfg); } news.append("\n"); @@ -218,7 +229,6 @@ public class Main { SyndFeedOutput output = new SyndFeedOutput(); output.output(feed, new File(outDir, "feed.xml")); - System.out.println(news.toString()); Files.write(new File(outDir, "news.html").toPath(), news.toString().getBytes()); } }