*/
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
-import java.io.FileWriter;
import java.io.IOException;
-import java.io.InputStream;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashMap;
-import java.util.Properties;
import java.util.logging.Logger;
import org.asciidoctor.Asciidoctor;
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;
sb.append("</html>");
}
- private static void appendHTMLContentHeader(StringBuffer sb, String title, String date) {
+ private static void appendHTMLContentHeader(StringBuffer sb, String title) {
sb.append("<div id='header'>\n");
sb.append("<h1>");
sb.append(title);
sb.append("</h1>\n");
- if (date != null) {
- sb.append("<div class='date'>");
- sb.append(date);
- sb.append("</div>");
- }
sb.append("</div>");
}
buf.append("<body>\n");
- appendHTMLContentHeader(buf, title, date);
+ appendHTMLContentHeader(buf, title);
buf.append("<div id='content'>\n");
+ if (date != null) {
+ buf.append("<div class='date'>");
+ buf.append(date);
+ buf.append("</div>");
+ }
buf.append(content);
buf.append("</div>");
Files.write(file.toPath(), buf.toString().getBytes());
}
- public static void main(String[] args) throws FileNotFoundException, IOException, FeedException {
+ public static void main(String[] args) throws FileNotFoundException, IOException, FeedException, ParseException {
File inDir, html, outDir;
File[] adocs;
StringWriter desc;
DocumentHeader h;
SyndContentImpl c;
StringBuffer news;
- String itemTitle, itemContent, itemURI, itemDate;
+ String itemTitle, itemContent, itemURI, strDate;
+ Date itemDate;
+ SimpleDateFormat sdf;
+
+ sdf = new SimpleDateFormat("yyyy-dd-MM");
inDir = new File(args[0]);
outDir = new File(args[1]);
news.append("<body>\n");
- appendHTMLContentHeader(news, cfg.getFeedTitle(), null);
+ appendHTMLContentHeader(news, cfg.getFeedTitle());
news.append("<div id='content'>\n");
h = asciidoctor.readDocumentHeader(adoc);
if (h.getAttributes().get("date") == null)
- itemDate = h.getAttributes().get("docdate").toString();
+ strDate = h.getAttributes().get("docdate").toString();
else
- itemDate = h.getAttributes().get("date").toString();
+ strDate = h.getAttributes().get("date").toString();
+
+ itemDate = sdf.parse(strDate);
asciidoctor.convert(new FileReader(adoc), desc, new HashMap<String,Object>());
itemURI = cfg.getFeedBaseURL() + "/" + html.getName();
e.setUri(itemURI);
e.setLink(itemURI);
+ e.setPublishedDate(itemDate);
c = toSyndContentImpl(itemContent);
news.append("<h2>");
news.append(itemTitle);
news.append("</h2>");
- news.append("<div class='date'>");
- news.append(itemDate);
- news.append("</div>");
+ if (news != null) {
+ news.append("<div class='date'>");
+ news.append(itemDate);
+ news.append("</div>");
+ }
news.append(desc.toString());
news.append("</div>\n");
- generateHTMLFileItem(html, itemTitle, itemContent, itemDate, cfg);
+ generateHTMLFileItem(html, itemTitle, itemContent, itemDate.toString(), cfg);
}
news.append("</div>\n");