generate rss feed from asciidoctor files
authorJean-Philippe Orsini <orsinije@fr.ibm.com>
Wed, 29 Jun 2016 14:34:17 +0000 (16:34 +0200)
committerJean-Philippe Orsini <orsinije@fr.ibm.com>
Wed, 29 Jun 2016 14:34:17 +0000 (16:34 +0200)
17 files changed:
asciidoctor/asciidoctorfeed.props [new file with mode: 0644]
asciidoctor/lib/asciidoctorj-1.5.4.jar [new file with mode: 0644]
asciidoctor/lib/jdom2-2.0.6.jar [new file with mode: 0644]
asciidoctor/lib/jruby-complete-1.7.21.jar [new file with mode: 0644]
asciidoctor/lib/rome-1.6.0.jar [new file with mode: 0644]
asciidoctor/lib/rome-utils-1.6.0.jar [new file with mode: 0644]
asciidoctor/lib/slf4j-api-1.7.6.jar [new file with mode: 0644]
asciidoctor/lib/slf4j-nop-1.7.6.jar [new file with mode: 0644]
asciidoctor/pdoc.sh [new file with mode: 0755]
asciidoctor/pom.xml [new file with mode: 0644]
asciidoctor/src/main/java/Main.java [new file with mode: 0644]
src/news/call_contribution.adoc [new file with mode: 0644]
src/news/docinfo.html [new file with mode: 0644]
src/news/new_website.adoc [new file with mode: 0644]
www/news/asciidoctor.css [new symlink]
www/news/call_contribution.html [new file with mode: 0644]
www/news/new_website.html [new file with mode: 0644]

diff --git a/asciidoctor/asciidoctorfeed.props b/asciidoctor/asciidoctorfeed.props
new file mode 100644 (file)
index 0000000..b43f4af
--- /dev/null
@@ -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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (file)
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 (executable)
index 0000000..1758471
--- /dev/null
@@ -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 (file)
index 0000000..ba3b108
--- /dev/null
@@ -0,0 +1,24 @@
+<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>
diff --git a/asciidoctor/src/main/java/Main.java b/asciidoctor/src/main/java/Main.java
new file mode 100644 (file)
index 0000000..228935d
--- /dev/null
@@ -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<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);
+                       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 (file)
index 0000000..c79adf3
--- /dev/null
@@ -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 (file)
index 0000000..de6e343
--- /dev/null
@@ -0,0 +1,2 @@
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
+<script src="../nav.js"></script>
diff --git a/src/news/new_website.adoc b/src/news/new_website.adoc
new file mode 100644 (file)
index 0000000..812d550
--- /dev/null
@@ -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 (symlink)
index 0000000..5191bf7
--- /dev/null
@@ -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 (file)
index 0000000..d2a1332
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="generator" content="Asciidoctor 1.5.4">
+<title>2016/06/14 - Call for contributions for the translation of psensor</title>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
+<link rel="stylesheet" href="./asciidoctor.css">
+</head>
+<body class="article">
+<div id="header">
+<h1>2016/06/14 - Call for contributions for the translation of psensor</h1>
+</div>
+<div id="content">
+<div class="paragraph">
+<p>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
+<a href="/psensor/contribute.html">instructions</a>.</p>
+</div>
+</div>
+<div id="footer">
+<div id="footer-text">
+Last updated 2016-06-29 13:24:57 +02:00
+</div>
+</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/www/news/new_website.html b/www/news/new_website.html
new file mode 100644 (file)
index 0000000..9a1f34c
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<meta name="generator" content="Asciidoctor 1.5.4">
+<title>2016/06/14 - New website</title>
+<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
+<link rel="stylesheet" href="./asciidoctor.css">
+</head>
+<body class="article">
+<div id="header">
+<h1>2016/06/14 - New website</h1>
+</div>
+<div id="content">
+<div class="paragraph">
+<p>After being bored with Wordpress for years, the <a href="http://wpitchoune.net">wpitchoune.net</a>
+website is changing. It is now based on <a href="http://asciidoctor.org">Asciidoctor</a> and
+a simple shell script to generate it.</p>
+</div>
+<div class="paragraph">
+<p>With the help of <a href="http://atom.io">Atom</a> 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.</p>
+</div>
+<div class="paragraph">
+<p>If you want to know how the website is built, everything is on
+a GIT repository: <a href="http://git.wpitchoune.net/gitweb/?p=www.git" class="bare">http://git.wpitchoune.net/gitweb/?p=www.git</a>.
+It is simple, really simple&#8230;&#8203; but enough for my needs.</p>
+</div>
+</div>
+<div id="footer">
+<div id="footer-text">
+Last updated 2016-06-29 13:03:11 +02:00
+</div>
+</div>
+</body>
+</html>
\ No newline at end of file