X-Git-Url: https://git.wpitchoune.net/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fwpitchoune%2Fasciidoctor%2FMain.java;h=355008c0249a7ea3d3bbf5bddd8b5e7ed262d9e8;hb=378caa6275b4bb28a70e1555e8d5edfade62d0bd;hp=f68f3548b973626bbbda9f7d997343a9423f56e5;hpb=135a8fb99a00a8a9457d3f5365bd0b6068d43e64;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 f68f354..355008c 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; @@ -103,17 +104,23 @@ public class Main { sb.append(""); } - private static void appendHTMLContentHeader(StringBuffer sb, String title) { + private static void appendHTMLContentHeader(StringBuffer sb, String title, String date) { sb.append(""); } private static void generateHTMLFileItem(File file, String title, String content, + String date, Configuration cfg) throws IOException { StringBuffer buf; @@ -123,7 +130,7 @@ public class Main { buf.append("\n"); - appendHTMLContentHeader(buf, title); + appendHTMLContentHeader(buf, title, date); buf.append("
\n"); buf.append(content); @@ -145,7 +152,7 @@ public class Main { DocumentHeader h; SyndContentImpl c; StringBuffer news; - String itemTitle, itemContent; + String itemTitle, itemContent, itemURI, itemDate; inDir = new File(args[0]); outDir = new File(args[1]); @@ -167,7 +174,7 @@ public class Main { news.append("\n"); - appendHTMLContentHeader(news, cfg.getFeedTitle()); + appendHTMLContentHeader(news, cfg.getFeedTitle(), null); news.append("
\n"); @@ -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(); @@ -187,7 +199,9 @@ public class Main { e = new SyndEntryImpl(); e.setTitle(itemTitle); - e.setUri(cfg.getFeedBaseURL() + "/" + html.getName()); + itemURI = cfg.getFeedBaseURL() + "/" + html.getName(); + e.setUri(itemURI); + e.setLink(itemURI); c = toSyndContentImpl(itemContent); @@ -199,10 +213,13 @@ public class Main { news.append("

"); news.append(itemTitle); news.append("

"); + news.append("
"); + news.append(itemDate); + news.append("
"); news.append(desc.toString()); news.append("
\n"); - generateHTMLFileItem(html, itemTitle, itemContent, cfg); + generateHTMLFileItem(html, itemTitle, itemContent, itemDate, cfg); } news.append("
\n"); @@ -215,7 +232,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()); } }