Newer
Older
GitBucket / src / main / twirl / gitbucket / core / repo / files.scala.html
@Naoki Takezoe Naoki Takezoe on 6 Sep 2015 6 KB Remove last committer from the file list
@(branch: String,
  repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
  pathList: List[String],
  groupNames: List[String],
  latestCommit: gitbucket.core.util.JGitUtil.CommitInfo,
  files: List[gitbucket.core.util.JGitUtil.FileInfo],
  readme: Option[(List[String], String)],
  hasWritePermission: Boolean,
  branchPullRequest: Option[(gitbucket.core.model.PullRequest, gitbucket.core.model.Issue)],
  info: Option[Any] = None,
  error: Option[Any] = None)(implicit context: gitbucket.core.controller.Context)
@import context._
@import gitbucket.core.view.helpers._
@html.main(s"${repository.owner}/${repository.name}", Some(repository)) {
  @html.menu("code", repository, Some(branch), pathList.isEmpty, groupNames.isEmpty, info, error){
    <div class="head">
      <div class="pull-right"><div class="btn-group">
        <a href="@url(repository)/find/@encodeRefName(branch)" class="btn btn-small" data-toggle="tooltip" data-placement="bottom" data-hotkey="t" title="Quickly jump between files"><i class="octicon octicon-list-unordered"></i></a>
        @if(pathList.nonEmpty){
          <a href="@url(repository)/commits/@encodeRefName(branch)/@pathList.mkString("/")" class="btn btn-small" data-toggle="tooltip" data-placement="bottom" title="Browse commits for this branch"><i class="octicon octicon-clock"></i></a>
        }
      </div></div>
      @branchPullRequest.map{ case (pullRequest, issue) =>
        <a href="@url(repository)/pull/@pullRequest.issueId" class="btn btn-small btn-pullrequest-branch" title="@issue.title" data-toggle="tooltip">#@pullRequest.issueId</a>
      }.getOrElse{
        <a href="@url(repository)/compare?head=@urlEncode(encodeRefName(branch))" class="btn btn-small btn-success"><i class="octicon octicon-git-compare" data-toggle="tooltip" title="Compare, review, create a pull request"></i></a>
      }
      @helper.html.branchcontrol(
        branch,
        repository,
        hasWritePermission
      ){
        @repository.branchList.map { x =>
          <li><a href="@url(repository)/tree/@encodeRefName(x)">@helper.html.checkicon(x == branch) @x</a></li>
        }
      }
      <a href="@url(repository)/tree/@encodeRefName(branch)">@repository.name</a> /
      @pathList.zipWithIndex.map { case (section, i) =>
        <a href="@url(repository)/tree/@encodeRefName(branch)/@pathList.take(i + 1).mkString("/")">@section</a> /
      }
      @if(hasWritePermission){
        <a href="@url(repository)/new/@encodeRefName(branch)/@pathList.mkString("/")" title="Create a new file here" style="text-decoration: none;">+</i></a>
      }
    </div>
    <table class="table table-file-list">
      <tr>
        <th colspan="4" style="font-weight: normal; border: none;">
          <a href="@url(repository)/commit/@latestCommit.id" class="commit-message">@link(latestCommit.summary, repository)</a>
          @if(latestCommit.description.isDefined){
            <a href="javascript:void(0)" onclick="$('#description-@latestCommit.id').toggle();" class="omit">...</a>
            <pre id="description-@latestCommit.id" class="commit-description" style="display: none;">@link(latestCommit.description.get, repository)</pre>
          }
        </th>
      </tr>
      <tr>
        <td colspan="4" class="latest-commit">
          <div>
            <div class="pull-right align-right monospace" style="line-height: 18px;">
              <a href="@url(repository)/commit/@latestCommit.id" class="commit-id"><span class="muted">latest commit</span> @latestCommit.id.substring(0, 10)</a>
            </div>
            <div class="author-info">
              <div class="author">
                @avatar(latestCommit, 20)
                <span>@user(latestCommit.authorName, latestCommit.authorEmailAddress, "username strong")</span>
                <span class="muted"> authored @helper.html.datetimeago(latestCommit.authorTime)</span>
              </div>
              @if(latestCommit.isDifferentFromAuthor) {
              <div class="committer">
                <span class="octicon octicon-arrow-right"></span>
                <span>@user(latestCommit.committerName, latestCommit.committerEmailAddress, "username strong")</span>
                <span class="muted"> committed @helper.html.datetimeago(latestCommit.commitTime)</span>
              </div>
              }
            </div>
          </div>
        </td>
      </tr>
      @if(pathList.size > 0){
      <tr>
        <td width="16" class="file-icon"></td>
        <td><a href="@url(repository)@if(pathList.size > 1){/tree/@encodeRefName(branch)/@pathList.init.mkString("/")}">..</a></td>
        <td></td>
        <td></td>
      </tr>
      }
      @files.map { file =>
      <tr>
        <td width="16" class="file-icon">
        @if(file.isDirectory){
          @if(file.linkUrl.isDefined){
            <i class="octicon octicon-file-symlink-directory"></i>
          } else {
            <i class="octicon octicon-file-directory"></i>
          }
        } else {
          <i class="octicon octicon-file-text"></i>
        }
        </td>
        <td class="content-name">
        @if(file.isDirectory){
          @if(file.linkUrl.isDefined){
            <a href="@file.linkUrl">
              <span class="simplified-path">@file.name.split("/").toList.init match {
                case Nil => {}
                case list => {@list.mkString("", "/", "/")}
              }</span>@file.name.split("/").toList.last
            </a>
          } else {
            <a href="@url(repository)/tree@{(encodeRefName(branch) :: pathList).mkString("/", "/", "/")}@file.name">
              <span class="simplified-path">@file.name.split("/").toList.init match {
                case Nil => {}
                case list => {@list.mkString("", "/", "/")}
              }</span>@file.name.split("/").toList.last
            </a>
          }
        } else {
          <a href="@url(repository)/blob@{(encodeRefName(branch) :: pathList).mkString("/", "/", "/")}@file.name">@file.name</a>
        }
        </td>
        <td class="mute">
          <a href="@url(repository)/commit/@file.commitId" class="commit-message shorten-text" title="@file.message">@link(file.message, repository)</a>
        </td>
        <td style="text-align: right;">@helper.html.datetimeago(file.time, false)</td>
      </tr>
      }
    </table>
    @readme.map { case(filePath, content) =>
      <div id="readme">
        <div class="box-header">@filePath.reverse.head</div>
        <div class="box-content-bottom markdown-body" style="padding-left: 16px; padding-right: 16px;">@renderMarkup(filePath, content, branch, repository, false, false, true)</div>
      </div>
    }
  }
}