Fix commit log presentation.

This commit is contained in:
takezoe
2013-06-19 11:07:48 +09:00
parent 7a3512ee18
commit 63d76a3c6e
5 changed files with 24 additions and 41 deletions

View File

@@ -15,27 +15,6 @@ object helpers {
*/ */
def date(date: Date): String = new SimpleDateFormat("yyyy/MM/dd").format(date) def date(date: Date): String = new SimpleDateFormat("yyyy/MM/dd").format(date)
def format(value: String): Html =
Html(value.replaceAll(" ", "&nbsp;").replaceAll("\t", "&nbsp;&nbsp;&nbsp;&nbsp;").replaceAll("\n", "<br>"))
// TODO escape html tags using HtmlEscapeUtils (Commons Lang)
def formatCommitLog(message: String): Html = {
val i = message.trim.indexOf("\n")
val (firstLine, description) = if(i >= 0){
(message.trim.substring(0, i).trim, Some(message.trim.substring(i).trim))
} else {
(message.trim, None)
}
val sb = new StringBuilder()
sb.append("<div class=\"summary\">").append(format(firstLine).text).append("</div>")
if(description.isDefined){
sb.append("<div class=\"description\">").append(format(description.get).text).append("</div>")
}
Html(sb.toString)
}
/** /**
* Converts Markdown of Wiki pages to HTML. * Converts Markdown of Wiki pages to HTML.
*/ */
@@ -43,16 +22,5 @@ object helpers {
enableWikiLink: Boolean, enableCommitLink: Boolean, enableIssueLink: Boolean)(implicit context: app.Context): Html = { enableWikiLink: Boolean, enableCommitLink: Boolean, enableIssueLink: Boolean)(implicit context: app.Context): Html = {
Html(Markdown.toHtml(value, repository, enableWikiLink, enableCommitLink, enableIssueLink)) Html(Markdown.toHtml(value, repository, enableWikiLink, enableCommitLink, enableIssueLink))
} }
// /**
// * Cut the given string by specified length.
// */
// def cut(message: String, length: Int): String = {
// if(message.length > length){
// message.substring(0, length) + "..."
// } else {
// message
// }
// }
} }

View File

@@ -8,7 +8,10 @@
<table class="table table-bordered"> <table class="table table-bordered">
<tr> <tr>
<th> <th>
<div class="commit-log">@helpers.formatCommitLog(commit.fullMessage)</div> <div class="commit-log">@commit.shortMessage</div>
@if(commit.description.isDefined){
<pre class="commit-description">@commit.description.get</pre>
}
<div class="small" style="font-weight: normal;"><span class="description">@branch</span></div> <div class="small" style="font-weight: normal;"><span class="description">@branch</span></div>
</th> </th>
</tr> </tr>

View File

@@ -36,9 +36,7 @@
} }
<br> <br>
@if(commit.description.isDefined){ @if(commit.description.isDefined){
<div class="small" id="description-@commit.id" style="display: none;"> <pre id="description-@commit.id" style="display: none;" class="commit-description">@commit.description.get</pre>
@helpers.format(commit.description.get)
</div>
} }
<div class="small"> <div class="small">
<a href="@path/@commit.committer">@commit.committer</a> <a href="@path/@commit.committer">@commit.committer</a>

View File

@@ -14,15 +14,25 @@
<table class="table table-file-list" style="border: 1px solid silver;"> <table class="table table-file-list" style="border: 1px solid silver;">
<tr> <tr>
<th colspan="4" style="font-weight: normal;"> <th colspan="4" style="font-weight: normal;">
<a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@latestCommit.shortMessage</a>
@if(latestCommit.description.isDefined){
<a href="javascript:void(0)" onclick="$('#description-@latestCommit.id').toggle();">...</a>
}
@if(latestCommit.description.isDefined){
<pre id="description-@latestCommit.id" class="commit-description" style="display: none;">@latestCommit.description.get</pre>
}
</th>
</tr>
<tr>
<td colspan="4">
<div> <div>
<strong><a href="@path/@repository.owner/@repository.name/@latestCommit.committer">@latestCommit.committer</a></strong> <strong><a href="@path/@repository.owner/@repository.name/@latestCommit.committer">@latestCommit.committer</a></strong>
<a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id" class="commit-message">@latestCommit.shortMessage</a>
<div class="pull-right align-right"> <div class="pull-right align-right">
@helpers.datetime(latestCommit.time) @helpers.datetime(latestCommit.time)
<a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id">@latestCommit.id.substring(0, 10)</a> <a href="@path/@repository.owner/@repository.name/commit/@latestCommit.id">@latestCommit.id.substring(0, 10)</a>
</div> </div>
</div> </div>
</th> </td>
</tr> </tr>
@if(pathList.size > 0){ @if(pathList.size > 0){
<tr> <tr>

View File

@@ -97,8 +97,12 @@ div.block {
border-bottom: 1px solid silver; border-bottom: 1px solid silver;
} }
div.commit-log div.description { pre.commit-description {
font-weight: normal; font-weight: normal;
border: none;
background-color: transparent;
padding: 2px;
margin: 0px;
} }
h1.wiki-title { h1.wiki-title {