]> source.dussan.org Git - gitblit.git/commitdiff
Add support for the Asciidoc markup format
authorJames Moger <james.moger@gitblit.com>
Wed, 12 Feb 2014 13:18:33 +0000 (08:18 -0500)
committerJames Moger <james.moger@gitblit.com>
Thu, 15 May 2014 22:42:53 +0000 (18:42 -0400)
.classpath
build.moxie
gitblit.iml
src/main/distrib/data/gitblit.properties
src/main/java/com/gitblit/wicket/MarkupProcessor.java

index 519aa51303c4c4550d4665a5153005f873842bd0..42b0efc79248eda74de4a1e402ad5ccefbeb4929 100644 (file)
@@ -40,6 +40,9 @@
        <classpathentry kind="lib" path="ext/tracwiki-core-1.4.jar" sourcepath="ext/src/tracwiki-core-1.4.jar" />
        <classpathentry kind="lib" path="ext/mediawiki-core-1.4.jar" sourcepath="ext/src/mediawiki-core-1.4.jar" />
        <classpathentry kind="lib" path="ext/confluence-core-1.4.jar" sourcepath="ext/src/confluence-core-1.4.jar" />
+       <classpathentry kind="lib" path="ext/asciidoctor-java-integration-0.1.4.jar" sourcepath="ext/src/asciidoctor-java-integration-0.1.4.jar" />
+       <classpathentry kind="lib" path="ext/jruby-complete-1.7.4.jar" sourcepath="ext/src/jruby-complete-1.7.4.jar" />
+       <classpathentry kind="lib" path="ext/jcommander-1.30.jar" sourcepath="ext/src/jcommander-1.30.jar" />
        <classpathentry kind="lib" path="ext/org.eclipse.jgit-3.3.1.201403241930-r.jar" sourcepath="ext/src/org.eclipse.jgit-3.3.1.201403241930-r.jar" />
        <classpathentry kind="lib" path="ext/jsch-0.1.50.jar" sourcepath="ext/src/jsch-0.1.50.jar" />
        <classpathentry kind="lib" path="ext/JavaEWAH-0.7.9.jar" sourcepath="ext/src/JavaEWAH-0.7.9.jar" />
index d834eabcc84eb4eba50a1edc4ddaa4f03cc43d7c..a87803038430d5d35a070a8727b55e24ee254bef 100644 (file)
@@ -111,6 +111,7 @@ properties: {
   wikitext.version : 1.4
   sshd.version: 0.11.0
   mina.version: 2.0.7
+  asciidoctorj.version : 0.1.4
   }
 
 # Dependencies
@@ -151,6 +152,7 @@ dependencies:
 - compile 'org.fusesource.wikitext:tracwiki-core:${wikitext.version}' :war
 - compile 'org.fusesource.wikitext:mediawiki-core:${wikitext.version}' :war
 - compile 'org.fusesource.wikitext:confluence-core:${wikitext.version}' :war
+- compile 'org.asciidoctor:asciidoctor-java-integration:${asciidoctorj.version}' :war
 - compile 'org.eclipse.jgit:org.eclipse.jgit:${jgit.version}' :war :fedclient :manager :authority !junit
 - compile 'org.eclipse.jgit:org.eclipse.jgit.http.server:${jgit.version}' :war :manager :authority !junit
 - compile 'org.bouncycastle:bcprov-jdk15on:${bouncycastle.version}' :war :authority
index 78828b680d8155c5004a6c798d5d3ebbf9ad8b50..1811093d81d15918efb2140038ecfa3e74effae8 100644 (file)
         </SOURCES>
       </library>
     </orderEntry>
+    <orderEntry type="module-library">
+      <library name="asciidoctor-java-integration-0.1.4.jar">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/ext/asciidoctor-java-integration-0.1.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/ext/src/asciidoctor-java-integration-0.1.4.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="jruby-complete-1.7.4.jar">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/ext/jruby-complete-1.7.4.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/ext/src/jruby-complete-1.7.4.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
+    <orderEntry type="module-library">
+      <library name="jcommander-1.30.jar">
+        <CLASSES>
+          <root url="jar://$MODULE_DIR$/ext/jcommander-1.30.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES>
+          <root url="jar://$MODULE_DIR$/ext/src/jcommander-1.30.jar!/" />
+        </SOURCES>
+      </library>
+    </orderEntry>
     <orderEntry type="module-library">
       <library name="org.eclipse.jgit-3.3.1.201403241930-r.jar">
         <CLASSES>
index 7d74c2812951cf349a1f805646ed563a09ec6441..e956bac4588101ab05f8ef9b21ea8e1161922c07 100644 (file)
@@ -1334,6 +1334,13 @@ web.confluenceExtensions = confluence
 # SINCE 1.4.0\r
 web.tracwikiExtensions = tracwiki\r
 \r
+# Registered extensions for asciidoc transformation\r
+#\r
+# SPACE-DELIMITED\r
+# CASE-SENSITIVE\r
+# SINCE 1.4.0\r
+web.asciidocExtensions = ad adoc asciidoc\r
+\r
 # Image extensions\r
 #\r
 # SPACE-DELIMITED\r
index e7681f2c656544469fd073c017b78919d0a2a235..79e3e22705369d0deeb9a893d981c7db169b7334 100644 (file)
@@ -31,6 +31,7 @@ import java.util.Map;
 \r
 import org.apache.wicket.Page;\r
 import org.apache.wicket.RequestCycle;\r
+import org.asciidoctor.Asciidoctor;\r
 import org.eclipse.jgit.lib.Repository;\r
 import org.eclipse.jgit.revwalk.RevCommit;\r
 import org.eclipse.mylyn.wikitext.confluence.core.ConfluenceLanguage;\r
@@ -73,7 +74,7 @@ import com.google.common.base.Joiner;
 public class MarkupProcessor {\r
 \r
        public enum MarkupSyntax {\r
-               PLAIN, MARKDOWN, TWIKI, TRACWIKI, TEXTILE, MEDIAWIKI, CONFLUENCE\r
+               PLAIN, MARKDOWN, TWIKI, TRACWIKI, TEXTILE, MEDIAWIKI, CONFLUENCE, ASCIIDOC\r
        }\r
 \r
        private Logger logger = LoggerFactory.getLogger(getClass());\r
@@ -86,6 +87,7 @@ public class MarkupProcessor {
 \r
        public List<String> getMarkupExtensions() {\r
                List<String> list = new ArrayList<String>();\r
+               list.addAll(settings.getStrings(Keys.web.asciidocExtensions));\r
                list.addAll(settings.getStrings(Keys.web.confluenceExtensions));\r
                list.addAll(settings.getStrings(Keys.web.markdownExtensions));\r
                list.addAll(settings.getStrings(Keys.web.mediawikiExtensions));\r
@@ -116,7 +118,9 @@ public class MarkupProcessor {
                        return MarkupSyntax.PLAIN;\r
                }\r
 \r
-               if (settings.getStrings(Keys.web.confluenceExtensions).contains(ext)) {\r
+               if (settings.getStrings(Keys.web.asciidocExtensions).contains(ext)) {\r
+                       return MarkupSyntax.ASCIIDOC;\r
+               } else if (settings.getStrings(Keys.web.confluenceExtensions).contains(ext)) {\r
                        return MarkupSyntax.CONFLUENCE;\r
                } else if (settings.getStrings(Keys.web.markdownExtensions).contains(ext)) {\r
                        return MarkupSyntax.MARKDOWN;\r
@@ -203,6 +207,9 @@ public class MarkupProcessor {
                if (markupText != null) {\r
                        try {\r
                                switch (syntax){\r
+                               case ASCIIDOC:\r
+                                       asciidoc(doc, repositoryName, commitId);\r
+                                       break;\r
                                case CONFLUENCE:\r
                                        parse(doc, repositoryName, commitId, new ConfluenceLanguage());\r
                                        break;\r
@@ -348,6 +355,18 @@ public class MarkupProcessor {
                doc.html = MarkdownUtils.transformMarkdown(doc.markup, renderer);\r
        }\r
 \r
+       /**\r
+        * Parses the document as Asciidoc using Asciidoctor.\r
+        *\r
+        * @param doc\r
+        * @param repositoryName\r
+        * @param commitId\r
+        */\r
+       private void asciidoc(final MarkupDocument doc, final String repositoryName, final String commitId) {\r
+               Asciidoctor asciidoctor = org.asciidoctor.Asciidoctor.Factory.create();\r
+               doc.html = asciidoctor.render(doc.markup, new HashMap<String, Object>());\r
+       }\r
+\r
        private String getWicketUrl(Class<? extends Page> pageClass, final String repositoryName, final String commitId, final String document) {\r
                String fsc = settings.getString(Keys.web.forwardSlashCharacter, "/");\r
                String encodedPath = document.replace(' ', '-');\r