From: James Moger Date: Wed, 12 Feb 2014 13:18:33 +0000 (-0500) Subject: Add support for the Asciidoc markup format X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d5e662b043b47fcd310f7ba5e80a64ab2f17f844;p=gitblit.git Add support for the Asciidoc markup format --- diff --git a/.classpath b/.classpath index 519aa513..42b0efc7 100644 --- a/.classpath +++ b/.classpath @@ -40,6 +40,9 @@ + + + diff --git a/build.moxie b/build.moxie index d834eabc..a8780303 100644 --- a/build.moxie +++ b/build.moxie @@ -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 diff --git a/gitblit.iml b/gitblit.iml index 78828b68..1811093d 100644 --- a/gitblit.iml +++ b/gitblit.iml @@ -396,6 +396,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/distrib/data/gitblit.properties b/src/main/distrib/data/gitblit.properties index 7d74c281..e956bac4 100644 --- a/src/main/distrib/data/gitblit.properties +++ b/src/main/distrib/data/gitblit.properties @@ -1334,6 +1334,13 @@ web.confluenceExtensions = confluence # SINCE 1.4.0 web.tracwikiExtensions = tracwiki +# Registered extensions for asciidoc transformation +# +# SPACE-DELIMITED +# CASE-SENSITIVE +# SINCE 1.4.0 +web.asciidocExtensions = ad adoc asciidoc + # Image extensions # # SPACE-DELIMITED diff --git a/src/main/java/com/gitblit/wicket/MarkupProcessor.java b/src/main/java/com/gitblit/wicket/MarkupProcessor.java index e7681f2c..79e3e227 100644 --- a/src/main/java/com/gitblit/wicket/MarkupProcessor.java +++ b/src/main/java/com/gitblit/wicket/MarkupProcessor.java @@ -31,6 +31,7 @@ import java.util.Map; import org.apache.wicket.Page; import org.apache.wicket.RequestCycle; +import org.asciidoctor.Asciidoctor; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.mylyn.wikitext.confluence.core.ConfluenceLanguage; @@ -73,7 +74,7 @@ import com.google.common.base.Joiner; public class MarkupProcessor { public enum MarkupSyntax { - PLAIN, MARKDOWN, TWIKI, TRACWIKI, TEXTILE, MEDIAWIKI, CONFLUENCE + PLAIN, MARKDOWN, TWIKI, TRACWIKI, TEXTILE, MEDIAWIKI, CONFLUENCE, ASCIIDOC } private Logger logger = LoggerFactory.getLogger(getClass()); @@ -86,6 +87,7 @@ public class MarkupProcessor { public List getMarkupExtensions() { List list = new ArrayList(); + list.addAll(settings.getStrings(Keys.web.asciidocExtensions)); list.addAll(settings.getStrings(Keys.web.confluenceExtensions)); list.addAll(settings.getStrings(Keys.web.markdownExtensions)); list.addAll(settings.getStrings(Keys.web.mediawikiExtensions)); @@ -116,7 +118,9 @@ public class MarkupProcessor { return MarkupSyntax.PLAIN; } - if (settings.getStrings(Keys.web.confluenceExtensions).contains(ext)) { + if (settings.getStrings(Keys.web.asciidocExtensions).contains(ext)) { + return MarkupSyntax.ASCIIDOC; + } else if (settings.getStrings(Keys.web.confluenceExtensions).contains(ext)) { return MarkupSyntax.CONFLUENCE; } else if (settings.getStrings(Keys.web.markdownExtensions).contains(ext)) { return MarkupSyntax.MARKDOWN; @@ -203,6 +207,9 @@ public class MarkupProcessor { if (markupText != null) { try { switch (syntax){ + case ASCIIDOC: + asciidoc(doc, repositoryName, commitId); + break; case CONFLUENCE: parse(doc, repositoryName, commitId, new ConfluenceLanguage()); break; @@ -348,6 +355,18 @@ public class MarkupProcessor { doc.html = MarkdownUtils.transformMarkdown(doc.markup, renderer); } + /** + * Parses the document as Asciidoc using Asciidoctor. + * + * @param doc + * @param repositoryName + * @param commitId + */ + private void asciidoc(final MarkupDocument doc, final String repositoryName, final String commitId) { + Asciidoctor asciidoctor = org.asciidoctor.Asciidoctor.Factory.create(); + doc.html = asciidoctor.render(doc.markup, new HashMap()); + } + private String getWicketUrl(Class pageClass, final String repositoryName, final String commitId, final String document) { String fsc = settings.getString(Keys.web.forwardSlashCharacter, "/"); String encodedPath = document.replace(' ', '-');