Browse Source

Add support for the Asciidoc markup format

ticket/7
James Moger 10 years ago
parent
commit
d5e662b043

+ 3
- 0
.classpath View 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" />

+ 2
- 0
build.moxie View 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

+ 33
- 0
gitblit.iml View File

@@ -396,6 +396,39 @@
</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>

+ 7
- 0
src/main/distrib/data/gitblit.properties View File

@@ -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

+ 21
- 2
src/main/java/com/gitblit/wicket/MarkupProcessor.java View File

@@ -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<String> getMarkupExtensions() {
List<String> list = new ArrayList<String>();
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<String, Object>());
}
private String getWicketUrl(Class<? extends Page> pageClass, final String repositoryName, final String commitId, final String document) {
String fsc = settings.getString(Keys.web.forwardSlashCharacter, "/");
String encodedPath = document.replace(' ', '-');

Loading…
Cancel
Save