projects
/
asciidoctor_to_rss.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
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
5e687c3
..
355008c
100644
(file)
--- a/
src/main/java/net/wpitchoune/asciidoctor/Main.java
+++ b/
src/main/java/net/wpitchoune/asciidoctor/Main.java
@@
-22,6
+22,7
@@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
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.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
@@
-41,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.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;
@@
-88,8
+90,6
@@
public class Main {
LOG.info("There is no declared HTML header file.");
return ;
}
LOG.info("There is no declared HTML header file.");
return ;
}
-
-
sb.append("<!DOCTYPE html>\n");
sb.append("<html>\n");
sb.append("<!DOCTYPE html>\n");
sb.append("<html>\n");
@@
-99,16
+99,46
@@
public class Main {
sb.append("</head>\n");
}
sb.append("</head>\n");
}
- private static void appendHTMLContentHeader(StringBuffer sb, String title) {
+ private static void appendHTMLFooter(StringBuffer sb) {
+ sb.append("</body>\n");
+ sb.append("</html>");
+ }
+
+ private static void appendHTMLContentHeader(StringBuffer sb, String title, String date) {
sb.append("<div id='header'>\n");
sb.append("<h1>");
sb.append(title);
sb.append("</h1>\n");
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>");
}
sb.append("</div>");
}
- private static void generateHTMLFileItem(String itemTitle, String itemContent) {
+ private static void generateHTMLFileItem(File file,
+ String title,
+ String content,
+ String date,
+ Configuration cfg) throws IOException {
+ StringBuffer buf;
+
+ buf = new StringBuffer();
+
+ appendHTMLHead(buf, cfg);
+ buf.append("<body>\n");
+
+ appendHTMLContentHeader(buf, title, date);
+
+ buf.append("<div id='content'>\n");
+ buf.append(content);
+ buf.append("</div>");
+
+ appendHTMLFooter(buf);
+
+ 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 {
@@
-122,7
+152,7
@@
public class Main {
DocumentHeader h;
SyndContentImpl c;
StringBuffer news;
DocumentHeader h;
SyndContentImpl c;
StringBuffer news;
- String itemTitle, itemContent;
+ String itemTitle, itemContent
, itemURI, itemDate
;
inDir = new File(args[0]);
outDir = new File(args[1]);
inDir = new File(args[0]);
outDir = new File(args[1]);
@@
-144,7
+174,7
@@
public class Main {
news.append("<body>\n");
news.append("<body>\n");
- appendHTMLContentHeader(news, cfg.getFeedTitle());
+ appendHTMLContentHeader(news, cfg.getFeedTitle()
, null
);
news.append("<div id='content'>\n");
news.append("<div id='content'>\n");
@@
-156,7
+186,12
@@
public class Main {
html = toHTMLFile(outDir, adoc);
h = asciidoctor.readDocumentHeader(adoc);
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<String,Object>());
itemTitle = h.getDocumentTitle().getMain();
asciidoctor.convert(new FileReader(adoc), desc, new HashMap<String,Object>());
itemTitle = h.getDocumentTitle().getMain();
@@
-164,7
+199,9
@@
public class Main {
e = new SyndEntryImpl();
e.setTitle(itemTitle);
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);
c = toSyndContentImpl(itemContent);
@@
-172,20
+209,22
@@
public class Main {
entries.add(e);
entries.add(e);
- news.append("\n<div>
\n
");
+ news.append("\n<div>");
news.append("<h2>");
news.append("<h2>");
- news.append(h.getDocumentTitle().getMain());
- news.append("</h2>\n");
+ news.append(itemTitle);
+ news.append("</h2>");
+ news.append("<div class='date'>");
+ news.append(itemDate);
+ news.append("</div>");
news.append(desc.toString());
news.append(desc.toString());
- news.append("
\n
</div>\n");
+ news.append("</div>\n");
- generateHTMLFileItem(
itemTitle, itemContent
);
+ generateHTMLFileItem(
html, itemTitle, itemContent, itemDate, cfg
);
}
news.append("</div>\n");
}
news.append("</div>\n");
- news.append("</body>\n");
- news.append("</html>\n");
+ appendHTMLFooter(news);
feed.setEntries(entries);
feed.setEntries(entries);
@@
-193,7
+232,6
@@
public class Main {
SyndFeedOutput output = new SyndFeedOutput();
output.output(feed, new File(outDir, "feed.xml"));
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());
}
}
Files.write(new File(outDir, "news.html").toPath(), news.toString().getBytes());
}
}