diff --git a/src/main/scala/util/JGitUtil.scala b/src/main/scala/util/JGitUtil.scala index ee8043d..669330e 100644 --- a/src/main/scala/util/JGitUtil.scala +++ b/src/main/scala/util/JGitUtil.scala @@ -61,11 +61,15 @@ rev.getParents().map(_.name).toList) val description = { - val i = fullMessage.trim.indexOf("\n") - if(i >= 0){ - Some(fullMessage.trim.substring(i).trim) - } else { + if(shortMessage == fullMessage){ None + } else { + val i = fullMessage.trim.indexOf("\n") + if(i >= 0){ + Some(fullMessage.trim.substring(i).trim) + } else { + None + } } } diff --git a/src/main/scala/view/helpers.scala b/src/main/scala/view/helpers.scala index e7d060a..9af5c36 100644 --- a/src/main/scala/view/helpers.scala +++ b/src/main/scala/view/helpers.scala @@ -26,6 +26,18 @@ Html(Markdown.toHtml(value, repository, enableWikiLink, enableCommitLink, enableIssueLink)) } + /** + * Converts issue id and commit id to link. + */ + def link(value: String, repository: service.RepositoryService.RepositoryInfo)(implicit context: app.Context): Html = + Html(value + // escape HTML tags + .replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """) + // convert issue id to link + .replaceAll("(^|\\W)#([0-9]+)(\\W|$)", "$1#$2$3".format(context.path, repository.owner, repository.name)) + // convert commit id to link + .replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", "$1$2$3").format(context.path, repository.owner, repository.name)) + } /** diff --git a/src/main/twirl/repo/blob.scala.html b/src/main/twirl/repo/blob.scala.html index 3078a52..0d4a8cc 100644 --- a/src/main/twirl/repo/blob.scala.html +++ b/src/main/twirl/repo/blob.scala.html @@ -21,7 +21,7 @@
@latestCommit.committer @helpers.datetime(latestCommit.time) - @latestCommit.shortMessage + @helpers.link(latestCommit.shortMessage, repository)
Raw diff --git a/src/main/twirl/repo/commit.scala.html b/src/main/twirl/repo/commit.scala.html index 2ab694f..0d289b3 100644 --- a/src/main/twirl/repo/commit.scala.html +++ b/src/main/twirl/repo/commit.scala.html @@ -12,9 +12,9 @@
Browse code
-
@commit.shortMessage
+
@helpers.link(commit.shortMessage, repository)
@if(commit.description.isDefined){ -
@commit.description.get
+
@helpers.link(commit.description.get, repository)
}
@if(branches.nonEmpty){ diff --git a/src/main/twirl/repo/commits.scala.html b/src/main/twirl/repo/commits.scala.html index 19fc66c..7828579 100644 --- a/src/main/twirl/repo/commits.scala.html +++ b/src/main/twirl/repo/commits.scala.html @@ -30,13 +30,13 @@
- @commit.shortMessage + @helpers.link(commit.shortMessage, repository) @if(commit.description.isDefined){ ... }
@if(commit.description.isDefined){ - + }
@commit.committer diff --git a/src/main/twirl/repo/files.scala.html b/src/main/twirl/repo/files.scala.html index 403ac88..596917f 100644 --- a/src/main/twirl/repo/files.scala.html +++ b/src/main/twirl/repo/files.scala.html @@ -14,12 +14,12 @@ @@ -59,7 +59,7 @@ } - + }
- @latestCommit.shortMessage + @helpers.link(latestCommit.shortMessage, repository) @if(latestCommit.description.isDefined){ ... } @if(latestCommit.description.isDefined){ - + }
@helpers.datetime(file.time)@file.message [@file.committer]@helpers.link(file.message, repository) [@file.committer]