added Commits link
|
1 |
<% |
2 |
# API |
|
cleanup
|
3 |
my $api = gitprep_api; |
cleanup commits page
|
4 | |
added branch long name featu...
|
5 |
# Git |
revert encoding support
|
6 |
my $git = $self->app->git; |
added branch long name featu...
|
7 | |
cleanup commits page
|
8 |
# Parameters |
added Commits link
|
9 |
my $user = param('user'); |
cleanup, rename repository t...
|
10 |
my $project = param('project'); |
added branch long name featu...
|
11 |
my $rev_file = param('rev_file'); |
add atom feed part
|
12 |
|
support atom feed of commits...
|
13 |
my $render_atom_feed = $rev_file =~ s/\.atom$// ? 1 : 0; |
add atom feed part
|
14 |
|
cleanup parse_rev_path
|
15 |
my ($rev, $file) = $git->parse_rev_path(app->rep_info($user, $project), $rev_file); |
added commits page pagenatio...
|
16 |
my $page = param('page') || 0; |
added Commits link
|
17 |
|
cleanup commits page
|
18 |
# Latest commit |
19 |
my $latest_commit = $git->get_commit(app->rep_info($user, $project), $rev); |
|
Fetch author_ids to show cor...
|
20 | |
21 |
# Authors |
|
22 |
my %author_id_of = map { $_->{email} => $_->{id} } |
|
23 |
@{ app->dbi->model('user')->select( [ 'id', 'email' ] )->all }; |
|
add atom feed part
|
24 |
|
added Commits link
|
25 |
# Commits |
improved commits page design
|
26 |
my $page_count = 30; |
cleanup
|
27 |
my $commits = $git->get_commits( |
cleanup import_branch
|
28 |
app->rep_info($user, $project), |
cleanup commits page
|
29 |
$latest_commit->{id}, |
cleanup
|
30 |
$page_count, |
31 |
$page_count * $page, |
|
added branch long name featu...
|
32 |
$file |
cleanup
|
33 |
); |
added commits page pagenatio...
|
34 |
my $commits_count = @$commits; |
improved commits page design
|
35 |
my $commits_date = {}; |
added Commits link
|
36 |
for my $commit (@$commits) { |
support time zone
|
37 |
my $date = $commit->{age_string_date_local}; |
improved commits page design
|
38 |
$commits_date->{$date} ||= []; |
39 |
push @{$commits_date->{$date}}, $commit; |
|
added Commits link
|
40 |
} |
41 |
|
|
added commits page header an...
|
42 |
# Global variable |
added branch long name featu...
|
43 |
stash(user => $user, project => $project, rev => $rev); |
add atom feed part
|
44 |
|
add time zone to commit time
|
45 |
# Render atom xml feed |
support atom feed of commits...
|
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, ...
|
69 |
} |
add commits atom alternate t...
|
70 |
|
71 |
# Set stash |
|
72 |
stash( |
|
73 |
user => $user, |
|
74 |
project => $project, |
|
75 |
rev => $rev |
|
76 |
); |
|
fix atom bug(order, escape, ...
|
77 |
#%> |
78 |
% if ($render_atom_feed) { |
|
79 |
<% |
|
fix atom feed content type t...
|
80 |
$self->res->headers->content_type('application/atom+xml;charset=UTF-8'); |
fix atom bug(order, escape, ...
|
81 |
# Create atom feed |
fix atom feed url bug
|
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, ...
|
85 |
#%> |
add space before ?>
|
86 |
<?xml version="1.0" encoding="UTF-8" ?> |
add atom feed part
|
87 |
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xml:lang="en-US"> |
fix atom feed bug
|
88 |
<id>tag:gitprep,2008:/<%= $user %>/<%= $project %>/commits/<%= $rev_file %></id> |
fix atom feed url bug
|
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, ...
|
91 |
<title>Recent Commits to <%= "$project:$rev" %></title> |
92 |
<updated><%= $commits->[0]->{updated} %></updated> |
|
add atom feed part
|
93 | |
fix atom bug(order, escape, ...
|
94 |
% for my $commit (@$commits) { |
support atom feed of commits...
|
95 |
<entry> |
fix atom bug(order, escape, ...
|
96 |
<id>tag:gitprep,2008:Grit::Commit/<%= $commit->{id} %></id> |
cleanup commits atom page
|
97 |
<link type="text/html" rel="alternate" href="<%= url_for("/$user/$project/commit/$commit->{id}")->to_abs %>" /> |
support atom feed of commits...
|
98 |
<title> |
fix atom bug(order, escape, ...
|
99 |
<%= $commit->{title} %> |
support atom feed of commits...
|
100 |
</title> |
fix atom bug(order, escape, ...
|
101 |
<updated><%= $commit->{updated} %></updated> |
support atom feed of commits...
|
102 |
<author> |
fix atom bug(order, escape, ...
|
103 |
<name><%= $user %></name> |
cleanup commits atom page
|
104 |
<uri><%= url_for("/$user")->to_abs %></uri> |
support atom feed of commits...
|
105 |
</author> |
106 |
<content type="html"> |
|
fix atom bug(order, escape, ...
|
107 |
<%= "<pre style='white-space:pre-wrap;width:81ex'>$commit->{title}</pre>" %> |
support atom feed of commits...
|
108 |
</content> |
109 |
</entry> |
|
fix atom bug(order, escape, ...
|
110 |
% } |
add atom feed part
|
111 |
</feed> |
fix atom bug(order, escape, ...
|
112 |
% } else { |
113 |
% layout 'common', title => "Commit History \x{30fb} $user/$project"; |
|
add atom feed part
|
114 |
|
fix atom bug(order, escape, ...
|
115 |
%= include '/include/header'; |
added commits page header an...
|
116 | |
fix atom bug(order, escape, ...
|
117 |
<div class="container"> |
improve commits page design
|
118 |
<div> |
improve branch_select design
|
119 |
%= include '/include/branch_select', display => 'commits'; |
120 |
</div> |
|
improve commits page design
|
121 |
|
122 |
<div class="commits"> |
|
123 |
% for my $date (reverse sort keys %$commits_date) { |
|
fix atom bug(order, escape, ...
|
124 |
% my $commits = $commits_date->{$date}; |
improve commits page design
|
125 |
<div class="commit-date"> |
126 |
<i class="icon-off"></i><span>Commits on <%= $date %></span> |
|
fix atom bug(order, escape, ...
|
127 |
</div> |
improve commits page design
|
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
|
132 |
<% |
133 |
my $author_id = app->dbi->model('user')->select('id', where => {email => $commit->{author_email}})->value; %> |
|
improve commits page design
|
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...
|
142 |
<span title="<%= $commit->{author_email} %>"> |
cleanup commits page
|
143 |
|
144 |
% if (defined $author_id) { |
|
Fetch author_ids to show cor...
|
145 |
<a href="<%= url_for("/$author_id") %>"><%= $author_id %></a> |
add user page link from user...
|
146 |
% } else { |
147 |
<%= $commit->{author_name} %> |
|
148 |
% } |
|
149 |
</span> |
|
improve commits page design
|
150 |
<span class="muted" title="<%= $commit->{age_string_datetime_local} %>"><%= $commit->{age_string} %></span> |
151 |
</div> |
|
fix atom bug(order, escape, ...
|
152 |
</div> |
improve commits page design
|
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 |
<> |
|
163 |
</a> |
|
164 |
</div> |
|
165 |
</div> |
|
fix atom bug(order, escape, ...
|
166 |
</div> |
improve commits page design
|
167 |
% $num++; |
168 |
</li> |
|
169 |
% } |
|
170 |
</ul> |
|
171 |
% } |
|
172 |
</div> |
|
173 |
|
|
improve pagenation design
|
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, ...
|
194 |
</div> |
195 |
|
|
196 |
%= include '/include/footer'; |
|
197 |
% } |