@(issue: Option[gitbucket.core.model.Issue], comments: List[gitbucket.core.model.Comment], isManageable: Boolean, repository: gitbucket.core.service.RepositoryService.RepositoryInfo, pullreq: Option[gitbucket.core.model.PullRequest] = None, commitId: Option[String] = None, renderScript: Boolean = true)(implicit context: gitbucket.core.controller.Context) @import gitbucket.core.view.helpers @import gitbucket.core.util.StringUtil._ @issueOrPullRequest()={ @if(issue.exists(_.isPullRequest))( "pull request" )else( "issue" ) } @showFormattedComment(comment: gitbucket.core.model.IssueComment)={
@helpers.avatarLink(comment.commentedUserName, 20) @helpers.user(comment.commentedUserName, styleClass="username strong") @if(comment.action == "comment"){ commented } else { referenced the @issueOrPullRequest() } @gitbucket.core.helper.html.datetimeago(comment.registeredDate) @if(comment.action != "commit" && comment.action != "merge" && comment.action != "refer" && (isManageable || context.loginAccount.map(_.userName == comment.commentedUserName).getOrElse(false))){ }
@helpers.markdown( markdown = comment.content, repository = repository, branch = repository.repository.defaultBranch, enableWikiLink = false, enableRefsLink = true, enableLineBreaks = true, enableTaskList = true, hasWritePermission = isManageable )
} @if(issue.isDefined){
@helpers.avatarLink(issue.get.openedUserName, 20) @helpers.user(issue.get.openedUserName, styleClass="username strong") commented @gitbucket.core.helper.html.datetimeago(issue.get.registeredDate) @if(isManageable || context.loginAccount.map(_.userName == issue.get.openedUserName).getOrElse(false)){ }
@helpers.markdown( markdown = issue.get.content getOrElse "No description provided.", repository = repository, branch = repository.repository.defaultBranch, enableWikiLink = false, enableRefsLink = true, enableLineBreaks = true, enableTaskList = true, hasWritePermission = isManageable )
} @comments.map { case comment: gitbucket.core.model.IssueComment => { @comment.action match { case "commit" => { @defining({ val (content, id) = " ([a-f0-9]{40})$".r.findFirstMatchIn(comment.content) .map(m => (m.before.toString -> Some(m.group(1)))) .getOrElse(comment.content -> None) val head = content.take(100).takeWhile(_ != '\n') (id, head, if(head == content){ None }else{ Some(content.drop(head.length).dropWhile(_ == '\n')) }.filter(_.nonEmpty)) }){ case (commitId, head, rest) =>
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") added a commit that referenced this @issueOrPullRequest() @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
@commitId.map{ id => @id.substring(0, 7) } @helpers.link(head, repository) @rest.map{ content => ...

    @helpers.link(content, repository)

}
} } case "refer" => {
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") referenced the @issueOrPullRequest() @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
@defining(comment.content.split(":")){ case Array(issueId, rest @ _*) => {@helpers.issueLink(repository.owner, repository.name, issueId.toInt, rest.mkString(":"))} }
} case "refer_global" => {
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") referenced the @issueOrPullRequest() @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
@defining(comment.content.split(":")){ case Array(issueId, ownerName, repositoryName, rest @ _*) => { @helpers.issueGlobalLink(ownerName, repositoryName, issueId.toInt, rest.mkString(":")) }}
} case "merge" => { @showFormattedComment(comment)
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") merged commit `@pullreq.map(_.commitIdTo.substring(0, 7))` into @if(pullreq.get.requestUserName == repository.owner){ `@pullreq.map(_.branch)` from `@pullreq.map(_.requestBranch)` } else { `@pullreq.map(_.userName):@pullreq.map(_.branch)` from `@pullreq.map(_.requestUserName):@pullreq.map(_.requestBranch)` } @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "close" | "close_comment" => { @if(comment.action == "close_comment"){ @showFormattedComment(comment) }
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") closed this @issueOrPullRequest() @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "reopen" | "reopen_comment" => { @if(comment.action == "reopen_comment"){ @showFormattedComment(comment) }
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") reopened the @issueOrPullRequest() @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "delete_branch" => {
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") deleted the `@pullreq.map(_.requestBranch)` branch @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "add_label" => {
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") added the `@comment.content` label @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "delete_label" => {
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") removed the `@comment.content` label @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "change_priority" => {
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") changed priority from `@comment.content.split(":")(0)` to `@comment.content.split(":")(1)` @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "change_milestone" => {
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") changed milestone from `@comment.content.split(":")(0)` to `@comment.content.split(":")(1)` @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "assign" => { @* for backward compatibility *@
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") changed assignee from `@comment.content.split(":")(0)` to `@comment.content.split(":")(1)` @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "add_assignee" => {
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") assigned `@comment.content` @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "delete_assignee" => {
@helpers.avatarLink(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") unassigned `@comment.content` @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "change_title" => {
@helpers.avatar(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") changed title from `@convertLineSeparator(comment.content, "LF").split("\n")(0)` to `@convertLineSeparator(comment.content, "LF").split("\n")(1)` @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "change_base_branch" => {
@helpers.avatar(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") changed base branch from `@convertLineSeparator(comment.content, "LF").split("\n")(0)` to `@convertLineSeparator(comment.content, "LF").split("\n")(1)` @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case "delete_comment" => {
@helpers.avatar(comment.commentedUserName, 16) @helpers.user(comment.commentedUserName, styleClass="username strong") deleted the comment @gitbucket.core.helper.html.datetimeago(comment.registeredDate)
} case _ => { @showFormattedComment(comment) } } } case comments: gitbucket.core.model.CommitComments => { @gitbucket.core.helper.html.commitcomments(comments, isManageable, repository, commitId.orElse(pullreq.map(_.commitIdTo))) } case comment: gitbucket.core.model.CommitComment => {
@helpers.avatarLink(comment.commentedUserName, 20) @helpers.user(comment.commentedUserName, styleClass="username strong") commented @gitbucket.core.helper.html.datetimeago(comment.registeredDate) on @comment.commitId.substring(0, 7) @if((isManageable || context.loginAccount.map(_.userName == comment.commentedUserName).getOrElse(false))){ }
@helpers.markdown( markdown = comment.content, repository = repository, branch = repository.repository.defaultBranch, enableWikiLink = false, enableRefsLink = true, enableLineBreaks = true, enableTaskList = true, hasWritePermission = isManageable )
} } @if(renderScript){
}