+++ /dev/null
-<project>
- <modelVersion>4.0.0</modelVersion>
-
- <artifactId>net.wpitchoune.asciidoctor</artifactId>
- <groupId>net.wpitchoune.net</groupId>
- <packaging>jar</packaging>
- <name>asciidoctor</name>
- <version>1.0</version>
-
- <dependencies>
- <dependency>
- <groupId>org.asciidoctor</groupId>
- <artifactId>asciidoctorj</artifactId>
- <version>1.5.4</version>
- </dependency>
-
- <dependency>
- <groupId>com.rometools</groupId>
- <artifactId>rome</artifactId>
- <version>1.6.0</version>
- </dependency>
-
- </dependencies>
-</project>
+++ /dev/null
-import java.io.*;
-import java.util.*;
-
-import org.asciidoctor.Asciidoctor;
-import org.asciidoctor.Asciidoctor.Factory;
-import org.asciidoctor.Options;
-import org.asciidoctor.ast.Document;
-import org.asciidoctor.ast.DocumentHeader;
-
-import com.rometools.rome.feed.synd.*;
-import com.rometools.rome.io.FeedException;
-import com.rometools.rome.io.SyndFeedOutput;
-
-public class Main {
- private static File toHTMLFile(File dir, File adoc) {
- int idx;
- String name;
-
- name = adoc.getName();
-
- idx = name.lastIndexOf('.');
-
- if (idx >= 0)
- name = name.substring(0, idx);
-
- return new File(dir, name + ".html");
- }
-
- public static void main(String[] args) throws FileNotFoundException, IOException, FeedException {
- File inDir, html, outDir;
- File[] adocs;
- StringWriter sw;
- Asciidoctor asciidoctor;
- Options opts;
- SyndFeed feed;
- Properties props;
- ArrayList<SyndEntry> entries;
- SyndEntryImpl e;
- InputStream in;
- DocumentHeader h;
- SyndContentImpl c;
-
- inDir = new File(args[0]);
- outDir = new File(args[1]);
-
- props = new Properties();
- in = new FileInputStream(args[2]);
- props.load(in);
- in.close();
-
- adocs = inDir.listFiles();
-
- asciidoctor = Factory.create();
-
- feed = new SyndFeedImpl();
- feed.setTitle(props.getProperty("feed.title"));
- feed.setDescription(props.getProperty("feed.description"));
- feed.setLink(props.getProperty("feed.link"));
-
- entries = new ArrayList<SyndEntry>();
-
- for (File adoc: adocs) {
- if (!adoc.getName().endsWith(".adoc"))
- continue;
- sw = new StringWriter();
-
- html = toHTMLFile(outDir, adoc);
-
- h = asciidoctor.readDocumentHeader(adoc);
-
- asciidoctor.convert(new FileReader(adoc), sw, new HashMap<String,Object>());
-
- e = new SyndEntryImpl();
- e.setTitle(h.getDocumentTitle().getMain());
- e.setUri(props.getProperty("feed.baseurl") + "/" + html.getName());
-
- c = new SyndContentImpl();
- c.setType("text/html");
- c.setValue(sw.toString());
-
- e.setDescription(c);
-
- entries.add(e);
- }
-
- feed.setEntries(entries);
-
- feed.setFeedType("rss_2.0");
- SyndFeedOutput output = new SyndFeedOutput();
- output.output(feed, new File(outDir, "feed.xml"));
- }
-}
\ No newline at end of file