gitprep / templates / main / commits.html.ep /
7ae0a85 12 years ago
1 contributor
205 lines | 5.094kb
<%
  # API
  my $api = Gitprep::API->new($self);
  
  my $user = param('user');
  my $repository = param('repository');
  my $id = param('id');
  my $page = param('page') || 0;

  my $root_ns = $api->root_ns(config->{root});
  
  # Parameters
  my $project_ns = "$root_ns/$user/$repository.git";
  my $project = "/$project_ns";
  my $home_ns = $api->dirname($project_ns);
  my $home = "/$home_ns";
  
  # Git
  my $git = $self->app->git;
  
  # Commit
  my $commit = $git->parse_commit($project, $id);
  
  # Commits
  my $page_count = 30;
  my $commits = $git->parse_commits(
    $project, $commit->{id}, $page_count, $page_count * $page);
  my $commits_count = @$commits;
  my $commits_date = {};
  for my $commit (@$commits) {
    my $date = $commit->{age_string_date};
    $commits_date->{$date} ||= [];
    push @{$commits_date->{$date}}, $commit;
  }
  
  # Global variable
  stash(user => $user, repository => $repository);
%>

% layout 'new_common';
  %= include '/css/common';
  
  %= stylesheet begin
    /* Code menu */
    .code_menu_commits {
      border:1px solid gray;
      border-bottom:none;
      background-color:white;
      font-weight:bold;
    }
    
    /* Commit history */
    .commit_history {
      font-weight:bold;
      margin: 1em 0;
    }
    .commit_history a {
      color:#4183C4;
    }
    
    /* Commit */
    .commit {
      border:1px solid gray;
      border-bottom:none;
      margin-bottom:15px;
    }
    .commit_date {
      border-bottom:1px solid gray;
      padding:5px;
      background-color:#E6F1F6;
      color:#3A505B;
      font-weight:bold;
    }
    .commit_content {
    }
    .commit_first {
      overflow:hidden;
      padding:8px;
      padding-bottom:1px;
    }
    .commit_first_left {
      float:left;
      color:black;
    }
    .commit_first_left a {
      color:black;
      font-weight:bold;
    }
    .commit_first_right {
      float:right;
    }
    .commit_first_right a {
      color:#4183C4;
    }
    .commit_second {
      overflow:hidden;
      border-bottom:1px solid gray;
      padding:8px;
      padding-top:1px;
    }
    .commit_second_left {
      float:left;
    }
    .commit_second_right {
      float:right;
    }
    .commit_second_right a {
      color:#4183C4;
    }
    
    /* Pagenation */
    .pagination {
      overflow:hidden;
      border-radius:3px;
      border:1px solid gray;
      display:inline-block;
      color:black
    }
    .pagination .left {
      border-right:1px solid gray;
      padding:5px;
      display:block;
      float:left
    }
    .pagination .right {
      padding:5px;
      display:block;
      float:left;
    }
    .pagination a {
      color:black;
      height:100%;
    }
    .pagination a:hover {
      background-color:#4183C4;
    }
    .pagination .disable {
      color:gray;
      cursor:default;
    }    
  % end
  
  %= include '/include/new_header';

  <div class="main_panel">
    %= include '/include/sub_header';
    
    %= include '/include/code_menu';
    
    <div class="commit_history">
      <a class="ubar" href="<%= url_for("/$user/$repository") %>">
        <%= $repository %>
      </a>
      /
      Commit History
    </div>
    
    % for my $date (sort keys %$commits_date) {
      <div class="commit">
        % my $commits = $commits_date->{$date};
        
        <div class="commit_date"><%= $date %></div>
        % for my $commit (sort {$a->{author_epoch} <=> $b->{author_epoch}} @$commits) {
          <div class="commit_content">
            <div class="commit_first">
              <div class="commit_first_left">
                <a class="ubar" href="<%= url_for("/$user/$repository/commit/$commit->{id}") %>">
                  <%= $commit->{title_short} %>
                </a>
              </div>
              <div class="commit_first_right a_dec_on a_blue">
                <a class="ubar" href="<%= url_for("/$user/$repository/commit/$commit->{id}") %>">
                  <%= substr($commit->{id}, 0, 10) %>
                </a>
              </div>
            </div>
            <div class="commit_second">
              <div class="commit_second_left">yuki-kimoto authored 7 days ago</div>
              <div class="commit_second_right">
                <a class="ubar" href="<%= url_for("/$user/$repository/commit/$commit->{id}") %>">
                  Browse code
                </a>
              </div>
            </div>
          </div>
        % }
      </div>
    % }
    <div class="pagination">
      % if ($page == 0) {
        <span class="left disable">&laquo; Newer</span>
      % } else {
        % my $newer_page = $page - 1;
        <a class="left" href="<%= url_for("/$user/$repository/commits/$id?page=$newer_page") %>">&laquo; Newer</a>
      % }
      % if ($commits_count < $page_count) {
        <span class="right disable">Older &raquo;</span>
      % } else {
        % my $older_page = $page + 1;
        <a class="right" href="<%= url_for("/$user/$repository/commits/$id?page=$older_page") %>">Older &raquo;</a>
      % }
    </div>
  </div>
  
  %= include '/include/footer';