summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/gitblit/wicket/pages/DocsPage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/MarkdownPage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RepositoryPage.java13
-rw-r--r--src/main/java/com/gitblit/wicket/pages/SummaryPage.java2
4 files changed, 15 insertions, 4 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/DocsPage.java b/src/main/java/com/gitblit/wicket/pages/DocsPage.java
index 58471ef9..2634ea8e 100644
--- a/src/main/java/com/gitblit/wicket/pages/DocsPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/DocsPage.java
@@ -74,7 +74,7 @@ public class DocsPage extends RepositoryPage {
// load the document
String [] encodings = GitBlit.getEncodings();
markdown = JGitUtils.getStringContent(r, head.getTree(), doc, encodings);
- html = MarkdownUtils.transformMarkdown(markdown, getLinkRenderer());
+ html = MarkdownUtils.transformMarkdown(markdown, getMarkdownLinkRenderer());
}
Fragment fragment = null;
diff --git a/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java b/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java
index e0c85cf5..0034984c 100644
--- a/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/MarkdownPage.java
@@ -79,7 +79,7 @@ public class MarkdownPage extends RepositoryPage {
String htmlText;
try {
- htmlText = MarkdownUtils.transformMarkdown(markdownText, getLinkRenderer());
+ htmlText = MarkdownUtils.transformMarkdown(markdownText, getMarkdownLinkRenderer());
} catch (Exception e) {
logger.error("failed to transform markdown", e);
if (markdownText == null) {
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
index 157f9e7c..508b8654 100644
--- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java
@@ -653,7 +653,7 @@ public abstract class RepositoryPage extends RootPage {
*
* @return a link renderer
*/
- protected LinkRenderer getLinkRenderer() {
+ protected LinkRenderer getMarkdownLinkRenderer() {
RevCommit head = JGitUtils.getCommit(r, "HEAD");
final String id = getBestCommitId(head);
LinkRenderer renderer = new LinkRenderer() {
@@ -662,10 +662,21 @@ public abstract class RepositoryPage extends RootPage {
try {
String fsc = GitBlit.getString(Keys.web.forwardSlashCharacter, "/");
String path = URLEncoder.encode(node.getText().replace(' ', '-'), "UTF-8").replace("%2F", fsc);
+
+ // extract document name
String name = node.getText();
if (name.indexOf('/') > -1) {
name = name.substring(name.lastIndexOf('/') + 1);
}
+
+ // strip Markdown extension
+ for (String ext : GitBlit.getStrings(Keys.web.markdownExtensions)) {
+ String x = "." + ext;
+ if (name.endsWith(x)) {
+ name = name.substring(0, name.length() - x.length());
+ break;
+ }
+ }
String url = urlFor(MarkdownPage.class, WicketUtils.newPathParameter(repositoryName, id, path)).toString();
return new Rendering(url, name);
} catch (UnsupportedEncodingException e) {
diff --git a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java
index 827e0799..3ea71d67 100644
--- a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java
@@ -167,7 +167,7 @@ public class SummaryPage extends RepositoryPage {
String [] encodings = GitBlit.getEncodings();
markdownText = JGitUtils.getStringContent(r, head.getTree(), readme, encodings);
if (isMarkdown) {
- htmlText = MarkdownUtils.transformMarkdown(markdownText, getLinkRenderer());
+ htmlText = MarkdownUtils.transformMarkdown(markdownText, getMarkdownLinkRenderer());
} else {
htmlText = MarkdownUtils.transformPlainText(markdownText);
}