Newer
Older
gitbucket_jkp / src / main / twirl / repo / commit.scala.html
@takezoe takezoe on 9 Jul 2013 5 KB Small fix.
@(commitId: String,
  commit: util.JGitUtil.CommitInfo,
  branches: List[String],
  tags: List[String],
  repository: service.RepositoryService.RepositoryInfo,
  diffs: Seq[util.JGitUtil.DiffInfo])(implicit context: app.Context)
@import context._
@import view.helpers._
@import util.Implicits._
@import org.eclipse.jgit.diff.DiffEntry.ChangeType
@html.main(commit.shortMessage){
  @html.header("code", repository)
  @tab(commitId, repository, "commits")
  <table class="table table-bordered">
    <tr>
      <th>
        <div class="pull-right align-right">
          <a href="@url(repository)/tree/@commit.id" class="btn btn-small">Browse code</a>
        </div>
        <div class="commit-log">@link(commit.summary, repository)</div>
        @if(commit.description.isDefined){
          <pre class="commit-description">@link(commit.description.get, repository)</pre>
        }
        <div class="small" style="font-weight: normal;">
          @if(branches.nonEmpty){
            <span class="muted">
              <img src="@assets/common/images/branch.png"/>
              @branches.zipWithIndex.map { case (branch, i) =>
                <a href="@url(repository)/tree/@branch" class="branch" id="branch-@i">@branch</a>
              }
            </span>
          }
          @if(tags.nonEmpty){
            <span class="muted">
              <img src="@assets/common/images/tag.png"/>
              @tags.zipWithIndex.map { case (tag, i) =>
                <a href="@url(repository)/tree/@tag" class="tag" id="tag-@i">@tag</a>
              }
            </span>
          }
        </div>
      </th>
    </tr>
    <tr>
      <td>
        <a href="@url(commit.committer)" class="username strong">@commit.committer</a> <span class="muted">@datetime(commit.time)</span>
        <div class="pull-right monospace small" style="text-align: right;">
          <div>
            @if(commit.parents.size == 0){
              <span class="muted">0 parent</span>
            }
            @if(commit.parents.size == 1){
              <span class="muted">1 parent</span>
              <a href="@url(repository)/commit/@commit.parents(0)" class="commit-id">@commit.parents(0).substring(0, 7)</a>
            }
            <span class="muted">commit</span> @commit.id
          </div>
          @if(commit.parents.size > 1){
            <div>
              <span class="muted">@commit.parents.size parents
              @commit.parents.map { parent =>
                <a href="@url(repository)/commit/@parent" class="commit-id">@parent.substring(0, 7)</a>
              }.mkHtml(" + ")
              </span>
            </div>
          }
        </div>
      </td>
    </tr>
  </table>
  <div>
    <div class="pull-right" style="margin-bottom: 10px;">
      <input id="toggle-file-list" type="button" class="btn" value="Show file list"/>
    </div>
    Showing @diffs.size changed @plural(diffs.size, "file")
    @*
    @if(diffs.size == 1){
      Showing 1 changed file
    } else {
      Showing @diffs.size changed files
    }
    *@
  </div>
  <ul id="commit-file-list" style="display: none;">
  @diffs.zipWithIndex.map { case (diff, i) =>
    <li@if(i > 0){ class="border"}>
      <a href="#diff-@i">
        @if(diff.changeType == ChangeType.COPY || diff.changeType == ChangeType.RENAME){
          <img src="@assets/common/images/diff_move.png"/> @diff.oldPath -> @diff.newPath
        }
        @if(diff.changeType == ChangeType.ADD){
          <img src="@assets/common/images/diff_add.png"/> @diff.newPath
        }
        @if(diff.changeType == ChangeType.MODIFY){
          <img src="@assets/common/images/diff_edit.png"/> @diff.newPath
        }
        @if(diff.changeType == ChangeType.DELETE){
          <img src="@assets/common/images/diff_delete.png"/> @diff.oldPath
        }
      </a>
    </li>
  }
  </ul>
  @helper.html.diff(diffs, repository, Some(commit.id))
}
<script>
$(function(){
  $('#toggle-file-list').click(function(){
    $('#commit-file-list').toggle();
    if($(this).val() == 'Show file list'){
      $(this).val('Hide file list');
    } else {
      $(this).val('Show file list');
    }
  });

  $('a.branch:first, a.tag:first').css({
    'font-weight': 'bold',
    'color': '#555555'
  });

  @if(branches.size > 5){
    // hide branches
    @for(i <- 1 to branches.size - 2){
      $('#branch-@i').hide();
    }
    // add omit link
    $('#branch-@(branches.size - 1)').before(
      $('<a href="javascript:void(0);" class="omit">...</a>').click(function(){
        @for(i <- 1 to branches.size - 2){
          $('#branch-@i').show();
          this.remove();
        }
      })
    );
  }

  @if(tags.size > 5){
    // hide tags
    @for(i <- 1 to tags.size - 2){
      $('#tag-@i').hide();
    }
    // add omit link
    $('#tag-@(tags.size - 1)').before(
      $('<a href="javascript:void(0);" class="omit">...</a>').click(function(){
        @for(i <- 1 to tags.size - 2){
          $('#tag-@i').show();
          this.remove();
        }
      })
    );
  }
});
</script>
<style type="text/css">
a.branch, a.tag {
  color: #888888;
  margin-right: 4px;
}

a.omit {
  margin-right: 4px;
}
</style>