diff options
author | Bret K. Ikehara <bret.k.ikehara@gmail.com> | 2013-08-04 13:43:25 -1000 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2013-09-18 11:29:45 -0400 |
commit | cd9461c0c05958444d1313b794be57df39d98956 (patch) | |
tree | af4226aeb4ea724d5380e0432935fa826cc3eadc /src/main/java/com/gitblit/wicket/pages | |
parent | a04808340abb7056fefb45645d9f5653813338fc (diff) | |
download | gitblit-cd9461c0c05958444d1313b794be57df39d98956.tar.gz gitblit-cd9461c0c05958444d1313b794be57df39d98956.zip |
Add support for rendering Markdown commit messages (issue-203)
Diffstat (limited to 'src/main/java/com/gitblit/wicket/pages')
9 files changed, 32 insertions, 22 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.html b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.html index 11a0ce3e..7437d2ed 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.html +++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.html @@ -16,7 +16,7 @@ <div wicket:id="commitHeader">[commit header]</div>
<!-- full message -->
- <pre style="border-style:none" "class="commit_message" wicket:id="fullMessage">[commit message]</pre>
+ <div wicket:id="fullMessage">[commit message]</div>
<!-- commit legend -->
<div class="hidden-phone" style="text-align:right;" wicket:id="commitLegend"></div>
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java index 6f1b4598..0a41b67b 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java +++ b/src/main/java/com/gitblit/wicket/pages/CommitDiffPage.java @@ -79,7 +79,7 @@ public class CommitDiffPage extends RepositoryPage { add(new CommitHeaderPanel("commitHeader", repositoryName, commit)); - addFullText("fullMessage", commit.getFullMessage(), true); + addFullText("fullMessage", commit.getFullMessage()); // changed paths list List<PathChangeModel> paths = JGitUtils.getFilesInCommit(r, commit); diff --git a/src/main/java/com/gitblit/wicket/pages/CommitPage.html b/src/main/java/com/gitblit/wicket/pages/CommitPage.html index ab5ddcaa..1ec541c6 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitPage.html +++ b/src/main/java/com/gitblit/wicket/pages/CommitPage.html @@ -49,7 +49,7 @@ </div>
<!-- full message -->
- <pre class="commit_message" wicket:id="fullMessage">[commit message]</pre>
+ <div class="topborder" wicket:id="fullMessage">[commit message]</div>
<!-- git notes -->
<table class="gitnotes">
diff --git a/src/main/java/com/gitblit/wicket/pages/CommitPage.java b/src/main/java/com/gitblit/wicket/pages/CommitPage.java index 1d11d443..1a1d5987 100644 --- a/src/main/java/com/gitblit/wicket/pages/CommitPage.java +++ b/src/main/java/com/gitblit/wicket/pages/CommitPage.java @@ -117,7 +117,7 @@ public class CommitPage extends RepositoryPage { };
add(parentsView);
- addFullText("fullMessage", c.getFullMessage(), true);
+ addFullText("fullMessage", c.getFullMessage());
// git notes
List<GitNote> notes = JGitUtils.getNotesOnCommit(r, c);
@@ -133,8 +133,8 @@ public class CommitPage extends RepositoryPage { item.add(new GravatarImage("noteAuthorAvatar", entry.notesRef.getAuthorIdent()));
item.add(WicketUtils.createTimestampLabel("authorDate", entry.notesRef
.getAuthorIdent().getWhen(), getTimeZone(), getTimeUtils()));
- item.add(new Label("noteContent", GitBlit.self().processCommitMessage(
- repositoryName, entry.content)).setEscapeModelStrings(false));
+ item.add(new Label("noteContent", GitBlit.self().processPlainCommitMessage(repositoryName,
+ entry.content)).setEscapeModelStrings(false));
}
};
add(notesView.setVisible(notes.size() > 0));
diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html index 38070273..f7d1f733 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html +++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.html @@ -42,8 +42,9 @@ <tr><th><wicket:message key="gb.skipSummaryMetrics"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSummaryMetrics" tabindex="12" /> <span class="help-inline"><wicket:message key="gb.skipSummaryMetricsDescription"></wicket:message></span></label></td></tr>
<tr><th><wicket:message key="gb.maxActivityCommits"></wicket:message></th><td class="edit"><select class="span2" wicket:id="maxActivityCommits" tabindex="13" /> <span class="help-inline"><wicket:message key="gb.maxActivityCommitsDescription"></wicket:message></span></td></tr>
<tr><th><wicket:message key="gb.metricAuthorExclusions"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="metricAuthorExclusions" size="40" tabindex="14" /></td></tr>
+ <tr><th><wicket:message key="gb.commitMessageRenderer"></wicket:message></th><td class="edit"><select class="span2" wicket:id="commitMessageRenderer" tabindex="15" /></td></tr>
<tr><th colspan="2"><hr/></th></tr>
- <tr><th><wicket:message key="gb.mailingLists"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="mailingLists" size="40" tabindex="15" /></td></tr>
+ <tr><th><wicket:message key="gb.mailingLists"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="mailingLists" size="40" tabindex="16" /></td></tr>
</tbody>
</table>
</div>
@@ -52,15 +53,15 @@ <div class="tab-pane" id="permissions">
<table class="plain">
<tbody class="settings">
- <tr><th><wicket:message key="gb.owners"></wicket:message></th><td class="edit"><span wicket:id="owners" tabindex="16" /> </td></tr>
+ <tr><th><wicket:message key="gb.owners"></wicket:message></th><td class="edit"><span wicket:id="owners" tabindex="17" /> </td></tr>
<tr><th colspan="2"><hr/></th></tr>
- <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="17" /></td></tr>
+ <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="18" /></td></tr>
<tr><th colspan="2"><hr/></th></tr>
<tr><th><wicket:message key="gb.authorizationControl"></wicket:message></th><td style="padding:2px;"><span class="authorizationControl" wicket:id="authorizationControl"></span></td></tr>
<tr><th colspan="2"><hr/></th></tr>
- <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="18" /> <span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="19" /> <span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>
- <tr><th><wicket:message key="gb.verifyCommitter"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="verifyCommitter" tabindex="20" /> <span class="help-inline"><wicket:message key="gb.verifyCommitterDescription"></wicket:message></span><br/><span class="help-inline" style="padding-left:10px;"><wicket:message key="gb.verifyCommitterNote"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="19" /> <span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="20" /> <span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>
+ <tr><th><wicket:message key="gb.verifyCommitter"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="verifyCommitter" tabindex="21" /> <span class="help-inline"><wicket:message key="gb.verifyCommitterDescription"></wicket:message></span><br/><span class="help-inline" style="padding-left:10px;"><wicket:message key="gb.verifyCommitterNote"></wicket:message></span></label></td></tr>
<tr><th colspan="2"><hr/></th></tr>
<tr><th><wicket:message key="gb.userPermissions"></wicket:message></th><td style="padding:2px;"><span wicket:id="users"></span></td></tr>
<tr><th colspan="2"><hr/></th></tr>
@@ -73,7 +74,7 @@ <div class="tab-pane" id="federation">
<table class="plain">
<tbody class="settings">
- <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span4" wicket:id="federationStrategy" tabindex="21" /></td></tr>
+ <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span4" wicket:id="federationStrategy" tabindex="22" /></td></tr>
<tr><th><wicket:message key="gb.federationSets"></wicket:message></th><td style="padding:2px;"><span wicket:id="federationSets"></span></td></tr>
</tbody>
</table>
diff --git a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java index 4c471a1e..a25797ff 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -52,6 +52,7 @@ import org.apache.wicket.model.util.ListModel; import com.gitblit.Constants;
import com.gitblit.Constants.AccessRestrictionType;
import com.gitblit.Constants.AuthorizationControl;
+import com.gitblit.Constants.CommitMessageRenderer;
import com.gitblit.Constants.FederationStrategy;
import com.gitblit.Constants.RegistrantType;
import com.gitblit.GitBlit;
@@ -552,6 +553,10 @@ public class EditRepositoryPage extends RootSubPage { }
});
+ List<CommitMessageRenderer> renderers = Arrays.asList(CommitMessageRenderer.values());
+ DropDownChoice<CommitMessageRenderer> messageRendererChoice = new DropDownChoice<CommitMessageRenderer>("commitMessageRenderer", renderers);
+ form.add(messageRendererChoice);
+
form.add(new Button("save"));
Button cancel = new Button("cancel") {
private static final long serialVersionUID = 1L;
@@ -721,5 +726,4 @@ public class EditRepositoryPage extends RootSubPage { return Integer.toString(index);
}
}
-
}
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java index afbed86f..e5ce22a1 100644 --- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java @@ -482,12 +482,17 @@ public abstract class RepositoryPage extends RootPage { add(new RefsPanel("refsPanel", repositoryName, c, JGitUtils.getAllRefs(r, getRepositoryModel().showRemoteBranches)));
}
- protected void addFullText(String wicketId, String text, boolean substituteRegex) {
- String html = StringUtils.escapeForHtml(text, false);
- if (substituteRegex) {
- html = GitBlit.self().processCommitMessage(repositoryName, html);
- } else {
- html = StringUtils.breakLinesForHtml(html);
+ protected void addFullText(String wicketId, String text) {
+ RepositoryModel model = getRepositoryModel();
+ String content = GitBlit.self().processCommitMessage(model, text);
+ String html;
+ switch (model.commitMessageRenderer) {
+ case MARKDOWN:
+ html = MessageFormat.format("<div class='commit_message'>{0}</div>", content);
+ break;
+ default:
+ html = MessageFormat.format("<pre class='commit_message'>{0}</pre>", content);
+ break;
}
add(new Label(wicketId, html).setEscapeModelStrings(false));
}
diff --git a/src/main/java/com/gitblit/wicket/pages/TagPage.html b/src/main/java/com/gitblit/wicket/pages/TagPage.html index e719a392..492ece3a 100644 --- a/src/main/java/com/gitblit/wicket/pages/TagPage.html +++ b/src/main/java/com/gitblit/wicket/pages/TagPage.html @@ -22,7 +22,7 @@ </div>
<!-- full message -->
- <pre class="commit_message" wicket:id="fullMessage">[commit message]</pre>
+ <div class="topborder" wicket:id="fullMessage">[commit message]</div>
<wicket:fragment wicket:id="fullPersonIdent">
<span wicket:id="personName"></span><span wicket:id="personAddress"></span>
diff --git a/src/main/java/com/gitblit/wicket/pages/TagPage.java b/src/main/java/com/gitblit/wicket/pages/TagPage.java index 13c10111..b8b6eef0 100644 --- a/src/main/java/com/gitblit/wicket/pages/TagPage.java +++ b/src/main/java/com/gitblit/wicket/pages/TagPage.java @@ -92,7 +92,7 @@ public class TagPage extends RepositoryPage { }
add(WicketUtils.createTimestampLabel("tagDate", when, getTimeZone(), getTimeUtils()));
- addFullText("fullMessage", tagRef.getFullMessage(), true);
+ addFullText("fullMessage", tagRef.getFullMessage());
}
@Override
|