projects
/
asciidoctor_to_rss.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added date support
[asciidoctor_to_rss.git]
/
src
/
main
/
java
/
net
/
wpitchoune
/
asciidoctor
/
Main.java
diff --git
a/src/main/java/net/wpitchoune/asciidoctor/Main.java
b/src/main/java/net/wpitchoune/asciidoctor/Main.java
index
b3e2de2
..
43f0a88
100644
(file)
--- a/
src/main/java/net/wpitchoune/asciidoctor/Main.java
+++ b/
src/main/java/net/wpitchoune/asciidoctor/Main.java
@@
-19,18
+19,17
@@
package net.wpitchoune.asciidoctor;
*/
import java.io.File;
*/
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.IOException;
-import java.io.InputStream;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
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.ArrayList;
+import java.util.Date;
import java.util.HashMap;
import java.util.HashMap;
-import java.util.Properties;
import java.util.logging.Logger;
import org.asciidoctor.Asciidoctor;
import java.util.logging.Logger;
import org.asciidoctor.Asciidoctor;
@@
-42,7
+41,6
@@
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.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;
import com.rometools.rome.io.FeedException;
import com.rometools.rome.io.SyndFeedOutput;
@@
-141,7
+139,7
@@
public class Main {
Files.write(file.toPath(), buf.toString().getBytes());
}
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;
File inDir, html, outDir;
File[] adocs;
StringWriter desc;
@@
-152,7
+150,11
@@
public class Main {
DocumentHeader h;
SyndContentImpl c;
StringBuffer news;
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]);
inDir = new File(args[0]);
outDir = new File(args[1]);
@@
-188,9
+190,11
@@
public class Main {
h = asciidoctor.readDocumentHeader(adoc);
if (h.getAttributes().get("date") == null)
h = asciidoctor.readDocumentHeader(adoc);
if (h.getAttributes().get("date") == null)
-
item
Date = h.getAttributes().get("docdate").toString();
+
str
Date = h.getAttributes().get("docdate").toString();
else
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>());
asciidoctor.convert(new FileReader(adoc), desc, new HashMap<String,Object>());
@@
-202,6
+206,7
@@
public class Main {
itemURI = cfg.getFeedBaseURL() + "/" + html.getName();
e.setUri(itemURI);
e.setLink(itemURI);
itemURI = cfg.getFeedBaseURL() + "/" + html.getName();
e.setUri(itemURI);
e.setLink(itemURI);
+ e.setPublishedDate(itemDate);
c = toSyndContentImpl(itemContent);
c = toSyndContentImpl(itemContent);
@@
-221,7
+226,7
@@
public class Main {
news.append(desc.toString());
news.append("</div>\n");
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");
}
news.append("</div>\n");