gitprep / templates / commits.html.ep /
1e740ab 12 years ago
1 contributor
121 lines | 3.486kb
<%
  # API
  my $api = gitprep_api;

  # Parameters
  my $user = param('user');
  my $project = param('project');
  my $rev = param('rev');
  my $blob = param('blob');
  my $page = param('page') || 0;
  
  # Git
  my $git = $self->app->git;
  
  # Commit
  my $commit = $git->parse_commit($user, $project, $rev);
  
  # Commits
  my $page_count = 30;
  my $commits = $git->parse_commits(
    $user,
    $project,
    $commit->{id},
    $page_count,
    $page_count * $page,
    $blob
  );
  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, project => $project);
%>

% layout 'common';
  
  %= include '/include/header';

  <div class="container">
    %= include '/include/project_header';
    %= include '/include/code_menu', display => 'commits';
        
    <div>
      <b>
        % if (defined $blob) {
          History for
          %= include '/include/page_path', type => 'blob', Path => $blob, operation => 'commits';
        % } else {
          <a class="ubar" href="<%= url_for("/$user/$project") %>">
            <%= $project %>
          </a>
          /
          Commit History
        % }
      </b>
    </div>

    % for my $date (reverse sort keys %$commits_date) {
      <div style="margin-bottom:20px">
        % my $commits = $commits_date->{$date};
        
        <div class="padding5 bk-blue-light border-gray" style="border-bottom:none">
          <b><%= $date %></b>
        </div>
        % for my $commit (sort {$b->{author_epoch} <=> $a->{author_epoch}} @$commits) {
          <div class="padding5 border-gray" style="padding-bottom:0;border-top:none;border-bottom:none">
            <div class="row">
              <div class="span8">
                <a class="font-black" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
                  <b><%= $commit->{title_short} %></b>
                </a>
              </div>
              <div class="span3 offset1-mini text-right">
                <a href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
                  <%= substr($commit->{id}, 0, 10) %>
                </a>
              </div>
            </div>
          </div>
          <div class="padding5 border-gray" style="border-top:none">
            <div class="row">
              <div class="span8 muted">
                yuki-kimoto authored 7 days ago
              </div>
              <div class="span3 offset1-mini text-right">
                <a href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
                  Browse code
                </a>
              </div>
            </div>
          </div>
        % }
      </div>
    % }

    <ul class="pager">
      % if ($page == 0) {
        <li class="disabled">&laquo; Newer</li>
      % } else {
        % my $newer_page = $page - 1;
        <li class="disable">
          <a href="<%= url_for("/$user/$project/commits/$rev?page=$newer_page") %>">&laquo; Newer</a>
        </li>
      % }
      % if ($commits_count < $page_count) {
        <li class="disabled">Older &raquo;</li>
      % } else {
        % my $older_page = $page + 1;
        <li>
          <a href="<%= url_for("/$user/$project/commits/$rev?page=$older_page") %>">Older &raquo;</a>
        </li>
      % }
    </ul>
  </div>
  
  %= include '/include/footer';