diff --git a/src/main/scala/util/JGitUtil.scala b/src/main/scala/util/JGitUtil.scala index 8d9b6eb..bf8c0a7 100644 --- a/src/main/scala/util/JGitUtil.scala +++ b/src/main/scala/util/JGitUtil.scala @@ -43,8 +43,10 @@ * @param message the last commit message * @param commitId the last commit id * @param committer the last committer name + * @param mailAddress the committer's mail address */ - case class FileInfo(id: ObjectId, isDirectory: Boolean, name: String, time: Date, message: String, commitId: String, committer: String) + case class FileInfo(id: ObjectId, isDirectory: Boolean, name: String, time: Date, message: String, commitId: String, + committer: String, mailAddress: String) /** * The commit data. @@ -52,14 +54,18 @@ * @param id the commit id * @param time the commit time * @param committer the committer name + * @param mailAddress the committer's mail address * @param shortMessage the short message * @param fullMessage the full message * @param parents the list of parent commit id */ - case class CommitInfo(id: String, time: Date, committer: String, shortMessage: String, fullMessage: String, parents: List[String]){ + case class CommitInfo(id: String, time: Date, committer: String, mailAddress: String, + shortMessage: String, fullMessage: String, parents: List[String]){ def this(rev: org.eclipse.jgit.revwalk.RevCommit) = this( - rev.getName, rev.getCommitterIdent.getWhen, rev.getCommitterIdent.getName, rev.getShortMessage, rev.getFullMessage, + rev.getName, rev.getCommitterIdent.getWhen, + rev.getCommitterIdent.getName, rev.getCommitterIdent.getEmailAddress, + rev.getShortMessage, rev.getFullMessage, rev.getParents().map(_.name).toList) val summary = { @@ -233,7 +239,8 @@ commits(path).getCommitterIdent.getWhen, commits(path).getShortMessage, commits(path).getName, - commits(path).getCommitterIdent.getName) + commits(path).getCommitterIdent.getName, + commits(path).getCommitterIdent.getEmailAddress) }.sortWith { (file1, file2) => (file1.isDirectory, file2.isDirectory) match { case (true , false) => true diff --git a/src/main/scala/view/helpers.scala b/src/main/scala/view/helpers.scala index 74d06bf..9b4f09c 100644 --- a/src/main/scala/view/helpers.scala +++ b/src/main/scala/view/helpers.scala @@ -79,13 +79,26 @@ .replaceAll("(^|\\W)([a-f0-9]{40})(\\W|$)", s"""$$1$$2$$3""")) + def user(userName: String, mailAddress: String, styleClass: String = "")(implicit context: app.Context): Html = { + val account = context.cache(s"account.${mailAddress}"){ + new AccountService {}.getAccountByMailAddress(mailAddress) + } + account.map { account => + Html(s"""${userName}""") + } getOrElse Html(userName) + } + /** * Returns <img> which displays the avatar icon. * Looks up Gravatar if avatar icon has not been configured in user settings. */ def avatar(userName: String, size: Int, tooltip: Boolean = false)(implicit context: app.Context): Html = { val account = context.cache(s"account.${userName}"){ - new AccountService {}.getAccountByUserName(userName) + if(userName.contains("@")){ + new AccountService {}.getAccountByMailAddress(userName) + } else { + new AccountService {}.getAccountByUserName(userName) + } } val src = account.collect { case account if(account.image.isEmpty) => s"""http://www.gravatar.com/avatar/${StringUtil.md5(account.mailAddress)}?s=${size}""" diff --git a/src/main/twirl/repo/blob.scala.html b/src/main/twirl/repo/blob.scala.html index a35d9b4..cd47e59 100644 --- a/src/main/twirl/repo/blob.scala.html +++ b/src/main/twirl/repo/blob.scala.html @@ -23,7 +23,8 @@