From: Jean-Philippe Orsini Date: Wed, 29 Jun 2016 14:34:17 +0000 (+0200) Subject: generate rss feed from asciidoctor files X-Git-Url: https://git.wpitchoune.net/gitweb/?p=www.git;a=commitdiff_plain;h=7f8bd4e38e4e433e249f772cc1088ff05055937c generate rss feed from asciidoctor files --- diff --git a/asciidoctor/asciidoctorfeed.props b/asciidoctor/asciidoctorfeed.props new file mode 100644 index 0000000..b43f4af --- /dev/null +++ b/asciidoctor/asciidoctorfeed.props @@ -0,0 +1,3 @@ +feed.title=The feed title +feed.description=The description of the feed +feed.link=http://wpitchoune.net/news/rss_2.0.xml \ No newline at end of file diff --git a/asciidoctor/lib/asciidoctorj-1.5.4.jar b/asciidoctor/lib/asciidoctorj-1.5.4.jar new file mode 100644 index 0000000..218a458 Binary files /dev/null and b/asciidoctor/lib/asciidoctorj-1.5.4.jar differ diff --git a/asciidoctor/lib/jdom2-2.0.6.jar b/asciidoctor/lib/jdom2-2.0.6.jar new file mode 100644 index 0000000..2850ca1 Binary files /dev/null and b/asciidoctor/lib/jdom2-2.0.6.jar differ diff --git a/asciidoctor/lib/jruby-complete-1.7.21.jar b/asciidoctor/lib/jruby-complete-1.7.21.jar new file mode 100644 index 0000000..7cde708 Binary files /dev/null and b/asciidoctor/lib/jruby-complete-1.7.21.jar differ diff --git a/asciidoctor/lib/rome-1.6.0.jar b/asciidoctor/lib/rome-1.6.0.jar new file mode 100644 index 0000000..baaf16f Binary files /dev/null and b/asciidoctor/lib/rome-1.6.0.jar differ diff --git a/asciidoctor/lib/rome-utils-1.6.0.jar b/asciidoctor/lib/rome-utils-1.6.0.jar new file mode 100644 index 0000000..f560df6 Binary files /dev/null and b/asciidoctor/lib/rome-utils-1.6.0.jar differ diff --git a/asciidoctor/lib/slf4j-api-1.7.6.jar b/asciidoctor/lib/slf4j-api-1.7.6.jar new file mode 100644 index 0000000..19aaf37 Binary files /dev/null and b/asciidoctor/lib/slf4j-api-1.7.6.jar differ diff --git a/asciidoctor/lib/slf4j-nop-1.7.6.jar b/asciidoctor/lib/slf4j-nop-1.7.6.jar new file mode 100644 index 0000000..52509a2 Binary files /dev/null and b/asciidoctor/lib/slf4j-nop-1.7.6.jar differ diff --git a/asciidoctor/pdoc.sh b/asciidoctor/pdoc.sh new file mode 100755 index 0000000..1758471 --- /dev/null +++ b/asciidoctor/pdoc.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +java -classpath target/classes:lib/asciidoctorj-1.5.4.jar:lib/jruby-complete-1.7.21.jar:target/net.wpitchoune.asciidoctor-1.0.jar:lib/rome-1.6.0.jar:lib/slf4j-api-1.7.6.jar:lib/slf4j-nop-1.7.6.jar:lib/jdom2-2.0.6.jar:lib/rome-utils-1.6.0.jar Main $* diff --git a/asciidoctor/pom.xml b/asciidoctor/pom.xml new file mode 100644 index 0000000..ba3b108 --- /dev/null +++ b/asciidoctor/pom.xml @@ -0,0 +1,24 @@ + + 4.0.0 + + net.wpitchoune.asciidoctor + net.wpitchoune.net + jar + asciidoctor + 1.0 + + + + org.asciidoctor + asciidoctorj + 1.5.4 + + + + com.rometools + rome + 1.6.0 + + + + diff --git a/asciidoctor/src/main/java/Main.java b/asciidoctor/src/main/java/Main.java new file mode 100644 index 0000000..228935d --- /dev/null +++ b/asciidoctor/src/main/java/Main.java @@ -0,0 +1,97 @@ +import java.io.*; +import java.util.*; + +import org.asciidoctor.Asciidoctor; +import org.asciidoctor.Asciidoctor.Factory; +import org.asciidoctor.Options; +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 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(); + + for (File adoc: adocs) { + if (!adoc.getName().endsWith(".adoc")) + continue; + + sw = new StringWriter(); + + html = toHTMLFile(outDir, adoc); + System.out.println(adoc + " => " + html); + + opts = new Options(); + opts.setToFile(html.getAbsolutePath()); + + asciidoctor.renderFile(adoc, opts); + + h = asciidoctor.readDocumentHeader(adoc); + + asciidoctor.convert(new FileReader(adoc), sw, Collections.emptyMap()); + + e = new SyndEntryImpl(); + e.setTitle(h.getDocumentTitle().getMain()); + + 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(); + System.out.println("" + output.outputString(feed)); + } +} \ No newline at end of file diff --git a/src/news/call_contribution.adoc b/src/news/call_contribution.adoc new file mode 100644 index 0000000..c79adf3 --- /dev/null +++ b/src/news/call_contribution.adoc @@ -0,0 +1,8 @@ += 2016/06/14 - Call for contributions for the translation of psensor +:docinfo2: + +The version 1.2.0 of psensor is going to be released in the coming +weeks. This release will include many changes which impact the +translations. If you want to contribute to the translation of psensor +it is now the good timeframe. See the +link:/psensor/contribute.html[instructions]. diff --git a/src/news/docinfo.html b/src/news/docinfo.html new file mode 100644 index 0000000..de6e343 --- /dev/null +++ b/src/news/docinfo.html @@ -0,0 +1,2 @@ + + diff --git a/src/news/new_website.adoc b/src/news/new_website.adoc new file mode 100644 index 0000000..812d550 --- /dev/null +++ b/src/news/new_website.adoc @@ -0,0 +1,15 @@ += 2016/06/14 - New website + +After being bored with Wordpress for years, the link:http://wpitchoune.net[wpitchoune.net] +website is changing. It is now based on link:http://asciidoctor.org[Asciidoctor] and +a simple shell script to generate it. + +With the help of link:http://atom.io[Atom] and a couple of addons dedicated to +Asciidoctor, it is easy and quick to write content. I am happy to no +more have to worry about the painful admistration of Wordpress, +upgrading it, taking care of security, spamming of comments and bot +account creation, and backup of databases. + +If you want to know how the website is built, everything is on +a GIT repository: http://git.wpitchoune.net/gitweb/?p=www.git. +It is simple, really simple... but enough for my needs. diff --git a/www/news/asciidoctor.css b/www/news/asciidoctor.css new file mode 120000 index 0000000..5191bf7 --- /dev/null +++ b/www/news/asciidoctor.css @@ -0,0 +1 @@ +../style.css \ No newline at end of file diff --git a/www/news/call_contribution.html b/www/news/call_contribution.html new file mode 100644 index 0000000..d2a1332 --- /dev/null +++ b/www/news/call_contribution.html @@ -0,0 +1,31 @@ + + + + + + + +2016/06/14 - Call for contributions for the translation of psensor + + + + + +
+
+

The version 1.2.0 of psensor is going to be released in the coming +weeks. This release will include many changes which impact the +translations. If you want to contribute to the translation of psensor +it is now the good timeframe. See the +instructions.

+
+
+ + + \ No newline at end of file diff --git a/www/news/new_website.html b/www/news/new_website.html new file mode 100644 index 0000000..9a1f34c --- /dev/null +++ b/www/news/new_website.html @@ -0,0 +1,41 @@ + + + + + + + +2016/06/14 - New website + + + + + +
+
+

After being bored with Wordpress for years, the wpitchoune.net +website is changing. It is now based on Asciidoctor and +a simple shell script to generate it.

+
+
+

With the help of Atom and a couple of addons dedicated to +Asciidoctor, it is easy and quick to write content. I am happy to no +more have to worry about the painful admistration of Wordpress, +upgrading it, taking care of security, spamming of comments and bot +account creation, and backup of databases.

+
+
+

If you want to know how the website is built, everything is on +a GIT repository: http://git.wpitchoune.net/gitweb/?p=www.git. +It is simple, really simple…​ but enough for my needs.

+
+
+ + + \ No newline at end of file