add blame method
|
1 |
<% |
2 |
# API |
|
3 |
my $api = gitprep_api; |
|
4 | ||
5 |
# Git |
|
revert encoding support
|
6 |
my $git = $self->app->git; |
add blame method
|
7 |
|
8 |
# Parameters |
|
9 |
my $user = param('user'); |
|
10 |
my $project = param('project'); |
|
11 |
my $rev_file = param('rev_file'); |
|
cleanup parse_rev_path
|
12 |
my ($rev, $file) = $git->parse_rev_path(app->rep_info($user, $project), $rev_file); |
add blame method
|
13 | |
14 |
# Commit |
|
15 |
my $commit = $git->last_change_commit($user, $project, $rev, $file); |
|
16 |
|
|
17 |
# Authors |
|
cleanup blob_size
|
18 |
my $authors = $git->authors(app->rep_info($user, $project), $rev, $file); |
add blame method
|
19 |
|
20 |
# File size |
|
cleanup blob_size
|
21 |
my $file_size = $git->blob_size(app->rep_info($user, $project), $rev, $file); |
add blame method
|
22 | |
23 |
# File mode |
|
cleanup blob_mode
|
24 |
my $mode = $git->blob_mode(app->rep_info($user, $project), $rev, $file); |
add blame method
|
25 |
my $file_type = $git->file_type_long($mode); |
26 | ||
27 |
# MIME type |
|
cleanup rep_info
|
28 |
my $mime_type = $git->blob_mime_type(app->rep_info($user, $project), $rev, $file); |
add blame method
|
29 | |
30 |
# Blame |
|
cleanup rep_info
|
31 |
my $blame = $git->blame(app->rep_info($user, $project), $rev, $file); |
add hot color to blame page
|
32 |
my $blame_lines = $blame->{lines}; |
33 |
my $blame_min_author_time = $blame->{min_author_time}; |
|
34 |
my $blame_max_author_time = $blame->{max_author_time}; |
|
35 |
|
|
36 |
# Color |
|
37 |
my $colors = [ |
|
38 |
'#ffeca7', |
|
39 |
'#ffdd8c', |
|
40 |
'#ffdd7c', |
|
41 |
'#fba447', |
|
42 |
'#f68736', |
|
43 |
'#f37636', |
|
44 |
'#ca6632', |
|
45 |
'#c0513f', |
|
46 |
'#a2503a', |
|
47 |
'#793738' |
|
48 |
]; |
|
49 |
|
|
add blame method
|
50 |
# Variables for included template |
51 |
stash(id => $rev, project => $project, rev => $rev); |
|
52 |
%> |
|
53 | ||
add hot color to blame page
|
54 |
% layout 'common' , title => "$user/$project at $rev"; |
add blame method
|
55 | |
56 |
%= include '/include/header'; |
|
fix blame page desing bug an...
|
57 |
|
58 |
<!-- Blame page --> |
|
add blame method
|
59 |
<div class="container"> |
improve blame page design
|
60 |
<div class="blame-page-path"> |
61 |
%= include '/include/page_path', Path => $file; |
|
62 |
<div class="blame-gradation"> |
|
63 |
Newer |
|
64 |
% for my $color (@$colors) { |
|
65 |
<span style="font-size:20px;color:<%= $color %>">■</span> |
|
66 |
% } |
|
67 |
Older |
|
68 |
</div> |
|
add blame method
|
69 |
</div> |
improve blame page design
|
70 |
<div class="file-header"> |
71 |
<div class="file-header-left"> |
|
72 |
<i class="icon-file icon-white"></i> |
|
73 |
<%= @$blame_lines %> lines |
|
74 |
<span style="color:#dcdcdc">|</span> |
|
75 |
<%= $file_size %>kb |
|
76 |
</div> |
|
77 |
<div class="file-header-right"> |
|
78 |
<ul> |
|
79 |
<li> |
|
80 |
<a class="btn btn-small" href="<%= url_for("/$user/$project/raw/$rev/$file") %>">Raw</a> |
|
81 |
</li> |
|
82 |
<li> |
|
83 |
<a class="btn btn-small" href="<%= url_for("/$user/$project/blob/$rev/$file") %>">Normal View</a> |
|
84 |
</li> |
|
85 |
<li> |
|
86 |
<a class="btn btn-small" href="<%= url_for("/$user/$project/commits/$rev/$file") %>">History</a> |
|
87 |
</li> |
|
88 |
</ul> |
|
add blame method
|
89 |
</div> |
90 |
</div> |
|
improve blame page design
|
91 |
<div class="blame-body-container"> |
92 |
<table class="blame-body"> |
|
improve blame design
|
93 |
% for my $line (@$blame_lines) { |
improve blame page design
|
94 |
<% |
95 |
my $blame_commit = $line->{commit}; |
|
96 |
my $summary = $line->{summary}; |
|
97 |
my $summary_short= length $summary > 28 ? substr($summary, 0, 28) . '...' : $summary; |
|
98 |
my $time_rate = $blame_max_author_time == $blame_min_author_time |
|
99 |
? 1 |
|
100 |
: ($blame_max_author_time - $line->{author_time}) / ($blame_max_author_time - $blame_min_author_time); |
|
101 |
my $color_number = int($time_rate * 10); |
|
102 |
$color_number = 9 if $color_number == 10; |
|
103 |
my $hot_color = $colors->[$color_number]; |
|
104 |
%> |
|
fix blame page desing bug an...
|
105 |
<tr id="L<%= $line->{number} %>"> |
improve blame design
|
106 |
% if ($line->{before_same_commit}) { |
improve blame page design
|
107 |
<td class="blame-body-left" nowrap style="border-right:2px solid <%= $hot_color %>"></td> |
improve blame design
|
108 |
% } else { |
improve blame page design
|
109 |
<td class="blame-body-left" nowrap style="border-right:2px solid <%= $hot_color %>"> |
110 |
<div class="blame-summary-container"> |
|
111 |
<div class="blame-summary"> |
|
improve blame design
|
112 |
<%= $summary_short %> |
113 |
</div> |
|
improve blame page design
|
114 |
<div class="blame-commit-id"> |
115 |
<a href="<%= url_for("/$user/$project/commit/$blame_commit") %>" ><%= substr($blame_commit, 0, 7) %></a> |
|
116 |
</div> |
|
117 |
</div> |
|
118 |
<div class="blame-author"> |
|
119 |
<span title="<%= $line->{author_mail} %>"><%= $line->{author} %></span> |
|
120 |
authored on |
|
121 |
<%= $line->{author_age_string_date_local} %> |
|
122 |
</div> |
|
improve blame design
|
123 |
</td> |
124 |
% } |
|
improve blame page design
|
125 |
<td class="blame-body-center" nowrap> |
improve blame design
|
126 |
<%= $line->{number} %> |
127 |
</td> |
|
improve blame page design
|
128 |
<td nowrap class="blame-body-right"> |
improve blame design
|
129 |
<pre style="border:none;background:white;margin:0;padding:0;white-space: nowrap;"><%= $line->{content} %></pre> |
130 |
</td> |
|
131 |
</tr> |
|
132 |
% } |
|
133 |
</table> |
|
134 |
</div> |
|
add blame method
|
135 |
</div> |
136 |
|
|
137 |
%= include '/include/footer'; |