gitprep / templates / commits.html.ep /
Newer Older
197 lines | 6.817kb
added Commits link
Yuki Kimoto authored on 2012-11-28
1
<%
2
  # API
cleanup
Yuki Kimoto authored on 2013-03-19
3
  my $api = gitprep_api;
cleanup commits page
Yuki Kimoto authored on 2013-01-29
4

            
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
5
  # Git
revert encoding support
Yuki Kimoto authored on 2013-11-22
6
  my $git = $self->app->git;
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
7

            
cleanup commits page
Yuki Kimoto authored on 2013-01-29
8
  # Parameters
added Commits link
Yuki Kimoto authored on 2012-11-28
9
  my $user = param('user');
cleanup, rename repository t...
Yuki Kimoto authored on 2013-01-29
10
  my $project = param('project');
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
11
  my $rev_file = param('rev_file');
add atom feed part
Yuki Kimoto authored on 2014-10-02
12
  
support atom feed of commits...
Yuki Kimoto authored on 2014-10-03
13
  my $render_atom_feed = $rev_file =~ s/\.atom$// ? 1 : 0;
add atom feed part
Yuki Kimoto authored on 2014-10-02
14
  
cleanup parse_rev_path
Yuki Kimoto authored on 2016-04-16
15
  my ($rev, $file) = $git->parse_rev_path(app->rep_info($user, $project), $rev_file);
added commits page pagenatio...
Yuki Kimoto authored on 2012-12-04
16
  my $page = param('page') || 0;
added Commits link
Yuki Kimoto authored on 2012-11-28
17
  
cleanup commits page
Yuki Kimoto authored on 2016-05-18
18
  # Latest commit
19
  my $latest_commit = $git->get_commit(app->rep_info($user, $project), $rev);
Fetch author_ids to show cor...
Dmitry Kopytov authored on 2016-05-17
20

            
21
  # Authors
22
  my %author_id_of = map { $_->{email} => $_->{id} }
23
    @{ app->dbi->model('user')->select( [ 'id', 'email' ] )->all };
add atom feed part
Yuki Kimoto authored on 2014-10-02
24
    
added Commits link
Yuki Kimoto authored on 2012-11-28
25
  # Commits
improved commits page design
Yuki Kimoto authored on 2012-12-03
26
  my $page_count = 30;
cleanup
Yuki Kimoto authored on 2013-04-30
27
  my $commits = $git->get_commits(
cleanup import_branch
Yuki Kimoto authored on 2016-04-16
28
    app->rep_info($user, $project),
cleanup commits page
Yuki Kimoto authored on 2016-05-18
29
    $latest_commit->{id},
cleanup
Yuki Kimoto authored on 2013-03-19
30
    $page_count,
31
    $page_count * $page,
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
32
    $file
cleanup
Yuki Kimoto authored on 2013-03-19
33
  );
added commits page pagenatio...
Yuki Kimoto authored on 2012-12-04
34
  my $commits_count = @$commits;
improved commits page design
Yuki Kimoto authored on 2012-12-03
35
  my $commits_date = {};
added Commits link
Yuki Kimoto authored on 2012-11-28
36
  for my $commit (@$commits) {
support time zone
Yuki Kimoto authored on 2014-03-08
37
    my $date = $commit->{age_string_date_local};
improved commits page design
Yuki Kimoto authored on 2012-12-03
38
    $commits_date->{$date} ||= [];
39
    push @{$commits_date->{$date}}, $commit;
added Commits link
Yuki Kimoto authored on 2012-11-28
40
  }
41
  
added commits page header an...
Yuki Kimoto authored on 2012-11-30
42
  # Global variable
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
43
  stash(user => $user, project => $project, rev => $rev);
add atom feed part
Yuki Kimoto authored on 2014-10-02
44
  
add time zone to commit time
Yuki Kimoto authored on 2014-10-03
45
  # Render atom xml feed
support atom feed of commits...
Yuki Kimoto authored on 2014-10-03
46
  if ($render_atom_feed) {
47
    # Add updated date time
48
    for my $commit (@$commits) {
49
      my $committer_epoch = $commit->{committer_epoch};
50
      my $committer_tz = $commit->{committer_tz};
51
      
52
      my $time_zone_second;
53
      my $time_zone;
54
      if ($committer_tz =~ /^(\+|\-)([0-9]{2})([0-9]{2})$/) {
55
        my $time_zone_sign = $1;
56
        my $time_zone_hour = $2;
57
        my $time_zone_min = $3;
58
        $time_zone_second = $time_zone_sign . ($time_zone_hour * (60 * 60) + $time_zone_min * 60);
59
        $time_zone = sprintf("$time_zone_sign%02d:%02d", $time_zone_hour, $time_zone_min);
60
      }
61

            
62
      # updated datetime
63
      my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($committer_epoch + $time_zone_second);
64
      my $updated = sprintf('%4d-%02d-%02dT%02d:%02d:%02d', 1900 + $year, $mon + 1, $mday, $hour, $min, $sec);
65
      $updated .= $time_zone;
66
      
67
      $commit->{updated} = $updated;
68
    }
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
69
  }
add commits atom alternate t...
Yuki Kimoto authored on 2014-12-03
70
  
71
  # Set stash
72
  stash(
73
    user => $user,
74
    project => $project,
75
    rev => $rev
76
  );
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
77
#%>
78
% if ($render_atom_feed) {
79
<%
fix atom feed content type t...
Yuki Kimoto authored on 2014-11-17
80
    $self->res->headers->content_type('application/atom+xml;charset=UTF-8');
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
81
    # Create atom feed
fix atom feed url bug
Yuki Kimoto authored on 2014-12-02
82
    my $alternate_url = url_with;
83
    my $alternate_url_path_parts = $alternate_url->path->parts;
84
    $alternate_url_path_parts->[-1] =~ s/\.atom$//;
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
85
#%>
add space before ?>
Yuki Kimoto authored on 2014-11-17
86
<?xml version="1.0" encoding="UTF-8" ?>
add atom feed part
Yuki Kimoto authored on 2014-10-02
87
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US">
fix atom feed bug
Yuki Kimoto authored on 2014-11-17
88
  <id>tag:gitprep,2008:/<%= $user %>/<%= $project %>/commits/<%= $rev_file %></id>
fix atom feed url bug
Yuki Kimoto authored on 2014-12-02
89
  <link type="text/html" rel="alternate" href="<%= $alternate_url->to_abs %>"/>
90
  <link type="application/atom+xml" rel="self" href="<%= url_with->to_abs %>"/>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
91
  <title>Recent Commits to <%= "$project:$rev" %></title>
92
  <updated><%= $commits->[0]->{updated} %></updated>
add atom feed part
Yuki Kimoto authored on 2014-10-02
93

            
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
94
    % for my $commit (@$commits) {
support atom feed of commits...
Yuki Kimoto authored on 2014-10-03
95
  <entry>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
96
    <id>tag:gitprep,2008:Grit::Commit/<%= $commit->{id} %></id>
cleanup commits atom page
Yuki Kimoto authored on 2014-12-03
97
    <link type="text/html" rel="alternate" href="<%= url_for("/$user/$project/commit/$commit->{id}")->to_abs %>" />
support atom feed of commits...
Yuki Kimoto authored on 2014-10-03
98
    <title>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
99
        <%= $commit->{title} %>
support atom feed of commits...
Yuki Kimoto authored on 2014-10-03
100
    </title>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
101
    <updated><%= $commit->{updated} %></updated>
support atom feed of commits...
Yuki Kimoto authored on 2014-10-03
102
    <author>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
103
      <name><%= $user %></name>
cleanup commits atom page
Yuki Kimoto authored on 2014-12-03
104
      <uri><%= url_for("/$user")->to_abs %></uri>
support atom feed of commits...
Yuki Kimoto authored on 2014-10-03
105
    </author>
106
    <content type="html">
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
107
      <%= "<pre style='white-space:pre-wrap;width:81ex'>$commit->{title}</pre>" %>
support atom feed of commits...
Yuki Kimoto authored on 2014-10-03
108
    </content>
109
  </entry>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
110
    % }
add atom feed part
Yuki Kimoto authored on 2014-10-02
111
</feed>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
112
% } else {
113
  % layout 'common', title => "Commit History \x{30fb} $user/$project";
add atom feed part
Yuki Kimoto authored on 2014-10-02
114
    
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
115
    %= include '/include/header';
added commits page header an...
Yuki Kimoto authored on 2012-11-30
116

            
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
117
    <div class="container">
improve commits page design
Yuki Kimoto authored on 2016-01-11
118
      <div>
improve branch_select design
Yuki Kimoto authored on 2015-12-18
119
        %= include '/include/branch_select', display => 'commits';
120
      </div>
improve commits page design
Yuki Kimoto authored on 2016-01-11
121
      
122
      <div class="commits">
123
        % for my $date (reverse sort keys %$commits_date) {
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
124
          % my $commits = $commits_date->{$date};
improve commits page design
Yuki Kimoto authored on 2016-01-11
125
          <div class="commit-date">
126
            <i class="icon-off"></i><span>Commits on <%= $date %></span>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
127
          </div>
improve commits page design
Yuki Kimoto authored on 2016-01-11
128

            
129
          <ul class="commits-date-container">
130
            % my $num = 0;
131
            % for my $commit (sort {$b->{author_epoch} <=> $a->{author_epoch}} @$commits) {
cleanup commits page
Yuki Kimoto authored on 2016-05-18
132
              <%
133
                my $author_id = app->dbi->model('user')->select('id', where => {email => $commit->{author_email}})->value;              %>
improve commits page design
Yuki Kimoto authored on 2016-01-11
134
              <li>
135
                <div class="commit-left">
136
                  <div class="commit-left-title">
137
                    <a href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
138
                      <b><%= $commit->{title_short} %></b>
139
                    </a>
140
                  </div>
141
                  <div class="commit-left-author">
add user page link from user...
Yuki Kimoto authored on 2016-04-11
142
                    <span title="<%= $commit->{author_email} %>">
cleanup commits page
Yuki Kimoto authored on 2016-05-18
143
                    
144
                      % if (defined $author_id) {
Fetch author_ids to show cor...
Dmitry Kopytov authored on 2016-05-17
145
                        <a href="<%= url_for("/$author_id") %>"><%= $author_id %></a>
add user page link from user...
Yuki Kimoto authored on 2016-04-11
146
                      % } else {
147
                        <%= $commit->{author_name} %>
148
                      % }
149
                    </span>
improve commits page design
Yuki Kimoto authored on 2016-01-11
150
                    <span class="muted" title="<%= $commit->{age_string_datetime_local} %>"><%= $commit->{age_string} %></span>
151
                  </div>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
152
                </div>
improve commits page design
Yuki Kimoto authored on 2016-01-11
153
                <div class="commit-right">
154
                  <div class="commit-right-container">
155
                    <div class="commit-right-commit-id">
156
                      <a href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
157
                        <%= substr($commit->{id}, 0, 7) %>
158
                      </a>
159
                    </div>
160
                    <div class="commit-right-browse-repository">
161
                      <a title="Browse the repository at this point in the history" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>">
162
                        &lt;&gt;
163
                      </a>
164
                    </div>
165
                  </div>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
166
                </div>
improve commits page design
Yuki Kimoto authored on 2016-01-11
167
                % $num++;
168
              </li>
169
            % }
170
          </ul>
171
        % }
172
      </div>
173
      
improve pagenation design
Yuki Kimoto authored on 2016-01-11
174
      <div class="pagenation-container">
175
        <ul class="pagenation">
176
          % if ($page == 0) {
177
            <li><span>Newer</span></li>
178
          % } else {
179
            % my $newer_page = $page - 1;
180
            <li>
181
              <a href="<%= url_for("/$user/$project/commits/$rev?page=$newer_page") %>">Newer</a>
182
            </li>
183
          % }
184
          % if ($commits_count < $page_count) {
185
            <li><span>Older</span></li>
186
          % } else {
187
            % my $older_page = $page + 1;
188
            <li>
189
              <a href="<%= url_for("/$user/$project/commits/$rev?page=$older_page") %>">Older</a>
190
            </li>
191
          % }
192
        </ul>
193
      </div>
fix atom bug(order, escape, ...
Yuki Kimoto authored on 2014-11-17
194
    </div>
195
    
196
    %= include '/include/footer';
197
% }