added feature that get branc...
|
1 |
<% |
2 |
# API |
|
added compare branch popup t...
|
3 |
my $api = gitprep_api; |
added feature that get branc...
|
4 | |
5 |
# Parameters |
|
6 |
my $user = param('user'); |
|
7 |
my $project = param('project'); |
|
cleanup
|
8 |
my $from_rev = param('rev1'); |
9 |
my $rev = param('rev2'); |
|
added feature that get branc...
|
10 |
my $page = param('page') || 0; |
11 |
|
|
12 |
# Git |
|
revert encoding support
|
13 |
my $git = $self->app->git; |
added feature that get branc...
|
14 |
|
15 |
# Commits |
|
cleanup
|
16 |
my $commits = $git->forward_commits($user, $project, $from_rev, $rev); |
added feature that get branc...
|
17 |
my $commits_count = @$commits; |
18 |
my $commits_date = {}; |
|
improved compare page commit...
|
19 |
my $authors = {}; |
added feature that get branc...
|
20 |
for my $commit (@$commits) { |
support time zone
|
21 |
my $date = $commit->{age_string_date_local}; |
added feature that get branc...
|
22 |
$commits_date->{$date} ||= []; |
improved compare page commit...
|
23 |
$authors->{$commit->{author}} = 1; |
added feature that get branc...
|
24 |
push @{$commits_date->{$date}}, $commit; |
25 |
} |
|
improved compare page commit...
|
26 |
my $authors_count = keys %$authors; |
added compare page file chan...
|
27 | |
28 |
# Start commit |
|
cleanup
|
29 |
my $start_commit = $git->separated_commit($user, $project, $from_rev, $rev); |
added compare page file chan...
|
30 | |
31 |
# End commit |
|
cleanup
|
32 |
my $end_commit = $git->get_commit($user, $project, $rev); |
cleanup
|
33 |
|
34 |
if (!$start_commit || !$end_commit) { |
|
do success xt tests
|
35 |
$self->reply->not_found; |
cleanup
|
36 |
return; |
37 |
} |
|
added compare page file chan...
|
38 |
|
added base branch selection ...
|
39 |
# Branches |
40 |
my $branches = $git->branches($user, $project); |
|
41 |
@$branches = sort { $a->{commit}{age} <=> $b->{commit}{age} } @$branches; |
|
42 |
|
|
improve compare page design
|
43 |
# Variables |
44 |
stash id => $end_commit->{id}; |
|
45 |
stash from_id => $start_commit->{id}; |
|
46 |
stash rev => $end_commit->{id}; |
|
47 |
stash from_rev => $start_commit->{id}; |
|
48 | ||
49 |
layout 'common', title => "Comparing $rev1...$rev2 \x{30fb} $user/$project"; |
|
added feature that get branc...
|
50 |
%> |
51 | ||
cleanup compare page
|
52 | |
improve compare page design
|
53 |
%= javascript begin |
54 |
$(document).ready(function () { |
|
55 |
|
|
56 |
// Change base branch |
|
57 |
$('#base-branch-btn').on('click', function () { |
|
58 |
$('#base-branch-popup') |
|
59 |
.css('display', 'block') |
|
60 |
.css('top', '40px') |
|
61 |
.css('left', '10px') |
|
62 |
; |
|
63 |
}); |
|
64 |
$('#base-branch-close').on('click', function () { |
|
65 |
$('#base-branch-popup').css('display', 'none'); |
|
66 |
}); |
|
67 |
$('[name=base-branch]').on('keypress', function (e) { |
|
68 |
// Enter |
|
69 |
if (e.which == 13) { |
|
70 |
location.href = '<%= url_for("/$user/$project/compare/") %>' + $(this).val() + '...<%= $rev %>'; |
|
71 |
} |
|
72 |
}); |
|
added compare branch popup t...
|
73 | |
improve compare page design
|
74 |
// Change compare branch |
75 |
$('#compare-branch-btn').on('click', function () { |
|
76 |
$('#compare-branch-popup') |
|
77 |
.css('display', 'block') |
|
78 |
.css('top', '40px') |
|
79 |
.css('left', '96px') |
|
80 |
; |
|
81 |
}); |
|
82 |
$('#compare-branch-close').on('click', function () { |
|
83 |
$('#compare-branch-popup').css('display', 'none'); |
|
84 |
}); |
|
85 |
$('[name=compare-branch]').on('keypress', function (e) { |
|
86 |
// Enter |
|
87 |
if (e.which == 13) { |
|
88 |
location.href = '<%= url_for("/$user/$project/compare/") %>' + '<%= $from_rev %>...' + $(this).val(); |
|
89 |
} |
|
improved compare page design
|
90 |
}); |
improve compare page design
|
91 |
}); |
92 |
% end |
|
cleanup
|
93 | |
improve compare page design
|
94 |
%= include '/include/header'; |
cleanup
|
95 | |
improve compare page design
|
96 |
<div class="container"> |
97 |
<div class="topic1">Compare View</div> |
|
98 |
<div class="compare-select"> |
|
99 |
<div> |
|
100 |
<div> |
|
101 |
<button id="base-branch-btn" class="btn btn-small"> |
|
102 |
<span>base:</span><b> <%= $from_rev %></b><i class="icon-arrow-down"></i> |
|
103 |
</button> |
|
104 |
... |
|
105 |
<button id="compare-branch-btn" class="btn btn-small"> |
|
106 |
<span>compare:</span> <b><%= $rev %></b><i class="icon-arrow-down"></i> |
|
107 |
</button> |
|
cleanup
|
108 |
</div> |
improve compare page design
|
109 |
</div> |
added base branch popup to c...
|
110 | |
improve compare page design
|
111 |
<div id="base-branch-popup" style="display:none;width:330px;position:absolute"> |
112 |
<div class="radius-top border-gray" style="background:#E6E6FA;padding:10px"> |
|
113 |
<div style="overflow:hidden"> |
|
114 |
<div style="float:left;width:90%;"> |
|
115 |
<b>Choose a base branch</b> |
|
116 |
</div> |
|
117 |
<div style="float:left:width:10%;text-align:right;"> |
|
118 |
<i id="base-branch-close" class="icon-remove-circle"></i> |
|
added base branch selection ...
|
119 |
</div> |
120 |
</div> |
|
improve compare page design
|
121 |
</div> |
122 |
<div class="border-gray" style="background:#F5F5F5;border-top:none;border-bottom:none;text-align:center;padding:10px 0"> |
|
123 |
%= text_field 'base-branch', style => 'margin-bottom:0;width:270px', placeholder => 'Branch, tag, commit, or history marker'; |
|
124 |
</div> |
|
125 |
<div style="background:white;max-height:500px;overflow:auto;"> |
|
added base branch popup to c...
|
126 |
<ul class="nav nav-tabs nav-stacked"> |
127 |
% for (my $i = 0; $i < @$branches; $i++) { |
|
128 |
% my $branch = $branches->[$i]; |
|
129 |
<li> |
|
cleanup
|
130 |
<a style="border-top-left-radius:0px;border-top-right-radius:0px;" href="<%= url_for("/$user/$project/compare/$branch->{name}...$rev") %>"> |
added base branch popup to c...
|
131 |
<%= $branch->{name} %> |
132 |
</a> |
|
133 |
</li> |
|
134 |
% } |
|
135 |
</ul> |
|
added base branch selection ...
|
136 |
</div> |
improve compare page design
|
137 |
</div> |
added compare branch popup t...
|
138 | |
improve compare page design
|
139 |
<div id="compare-branch-popup" style="display:none;width:330px;position:absolute"> |
140 |
<div class="radius-top border-gray" style="background:#E6E6FA;padding:10px"> |
|
141 |
<div style="overflow:hidden"> |
|
142 |
<div style="float:left;width:90%;"> |
|
143 |
<b>Choose a compare branch</b> |
|
144 |
</div> |
|
145 |
<div style="float:left:width:10%;text-align:right;"> |
|
146 |
<i id="compare-branch-close" class="icon-remove-circle"></i> |
|
added compare branch popup t...
|
147 |
</div> |
148 |
</div> |
|
149 |
</div> |
|
improve compare page design
|
150 |
<div class="border-gray" style="background:#F5F5F5;border-top:none;border-bottom:none;text-align:center;padding:10px 0"> |
151 |
%= text_field 'compare-branch', style => 'margin-bottom:0;width:270px', placeholder => 'Branch, tag, commit, or history marker'; |
|
152 |
</div> |
|
153 |
<div style="background:white;max-height:500px;overflow:auto;"> |
|
154 |
<ul class="nav nav-tabs nav-stacked"> |
|
155 |
% for (my $i = 0; $i < @$branches; $i++) { |
|
156 |
% my $branch = $branches->[$i]; |
|
157 |
<li> |
|
158 |
<a style="border-top-left-radius:0px;border-top-right-radius:0px;" href="<%= url_for("/$user/$project/compare/$from_rev...$branch->{name}") %>"> |
|
159 |
<%= $branch->{name} %> |
|
160 |
</a> |
|
161 |
</li> |
|
162 |
% } |
|
163 |
</ul> |
|
164 |
</div> |
|
added base branch selection ...
|
165 |
</div> |
improve compare page design
|
166 |
</div> |
added base branch popup to c...
|
167 | |
improve compare page design
|
168 |
% if (keys %$commits_date) { |
169 |
<ul class="compare-header"> |
|
170 |
<li> |
|
171 |
<b><%= @$commits %></b> <span>commit</span> |
|
172 |
</li> |
|
173 |
<li> |
|
174 |
<b><%= $authors_count %></b> <span>contributor</span> |
|
175 |
</li> |
|
176 |
<li> |
|
177 |
|
|
178 |
</li> |
|
179 |
<li> |
|
180 |
|
|
181 |
</li> |
|
182 |
</ul> |
|
improved compare page design
|
183 |
|
improve compare page design
|
184 |
<div class="commits"> |
expand compare page tabs
|
185 |
% for my $date (reverse sort keys %$commits_date) { |
186 |
% my $commits = $commits_date->{$date}; |
|
187 |
|
|
improve compare page design
|
188 |
<div class="commit-date"> |
189 |
<i class="icon-off"></i><span>Commits on <%= $date %></span> |
|
expand compare page tabs
|
190 |
</div> |
191 |
|
|
improve compare page design
|
192 |
<ul class="compare-commits-date-container"> |
expand compare page tabs
|
193 |
% for my $commit (sort {$b->{author_epoch} <=> $a->{author_epoch}} @$commits) { |
improve compare page design
|
194 |
<li> |
195 |
<div class="compare-commits-author"> |
|
196 |
<span title="<%= $commit->{author_email} %>"><%= $commit->{author_name} %></span> |
|
expand compare page tabs
|
197 |
</div> |
improve compare page design
|
198 |
<div class="compare-commits-commit-title"> |
199 |
<a style="color:#333" href="<%= url_for("/$user/$project/commit/$commit->{id}") %>"> |
|
200 |
<%= $commit->{title_short} %> |
|
201 |
</a> |
|
202 |
</div> |
|
203 |
<div class="compare-commits-commit-id"> |
|
204 |
<a href="<%= url_for("/$user/$project/commit/$commit->{id}") %>"> |
|
205 |
<%= substr($commit->{id}, 0, 7) %> |
|
206 |
</a> |
|
207 |
</div> |
|
208 |
</li> |
|
improved branches page and c...
|
209 |
% } |
improve compare page design
|
210 |
</ul> |
expand compare page tabs
|
211 |
% } |
improve compare page design
|
212 |
</div> |
213 |
|
|
214 |
%= include '/include/commit_body'; |
|
215 |
% } else { |
|
216 |
<div> |
|
217 |
<b>There isn't anything to compare.</b> |
|
218 |
</div> |
|
219 |
% } |
|
220 |
</div> |
|
221 |
%= include '/include/footer'; |