gitprep / templates / blame.html.ep /
Newer Older
137 lines | 4.572kb
add blame method
Yuki Kimoto authored on 2013-08-10
1
<%
2
  # API
3
  my $api = gitprep_api;
4

            
5
  # Git
revert encoding support
Yuki Kimoto authored on 2013-11-22
6
  my $git = $self->app->git;
add blame method
Yuki Kimoto authored on 2013-08-10
7
  
8
  # Parameters
9
  my $user = param('user');
10
  my $project = param('project');
11
  my $rev_file = param('rev_file');
cleanup parse_rev_path
Yuki Kimoto authored on 2016-04-16
12
  my ($rev, $file) = $git->parse_rev_path(app->rep_info($user, $project), $rev_file);
add blame method
Yuki Kimoto authored on 2013-08-10
13

            
14
  # Commit
cleanup methods
Yuki Kimoto authored on 2016-04-16
15
  my $commit = $git->last_change_commit(app->rep_info($user, $project), $rev, $file);
add blame method
Yuki Kimoto authored on 2013-08-10
16
  
17
  # Authors
cleanup blob_size
Yuki Kimoto authored on 2016-04-16
18
  my $authors = $git->authors(app->rep_info($user, $project), $rev, $file);
add blame method
Yuki Kimoto authored on 2013-08-10
19
  
20
  # File size
cleanup blob_size
Yuki Kimoto authored on 2016-04-16
21
  my $file_size = $git->blob_size(app->rep_info($user, $project), $rev, $file);
add blame method
Yuki Kimoto authored on 2013-08-10
22

            
23
  # File mode
cleanup blob_mode
Yuki Kimoto authored on 2016-04-16
24
  my $mode = $git->blob_mode(app->rep_info($user, $project), $rev, $file);
add blame method
Yuki Kimoto authored on 2013-08-10
25
  my $file_type = $git->file_type_long($mode);
26

            
27
  # MIME type
cleanup rep_info
Yuki Kimoto authored on 2016-04-16
28
  my $mime_type = $git->blob_mime_type(app->rep_info($user, $project), $rev, $file);
add blame method
Yuki Kimoto authored on 2013-08-10
29

            
30
  # Blame
cleanup rep_info
Yuki Kimoto authored on 2016-04-16
31
  my $blame = $git->blame(app->rep_info($user, $project), $rev, $file);
add hot color to blame page
Yuki Kimoto authored on 2013-08-10
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
Yuki Kimoto authored on 2013-08-10
50
  # Variables for included template
51
  stash(id => $rev, project => $project, rev => $rev);
52
%>
53

            
add hot color to blame page
Yuki Kimoto authored on 2013-08-10
54
% layout 'common' , title => "$user/$project at $rev";
add blame method
Yuki Kimoto authored on 2013-08-10
55

            
56
  %= include '/include/header';
fix blame page desing bug an...
Yuki Kimoto authored on 2013-08-10
57
  
58
  <!-- Blame page -->
add blame method
Yuki Kimoto authored on 2013-08-10
59
  <div class="container">
improve blame page design
Yuki Kimoto authored on 2016-01-13
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
Yuki Kimoto authored on 2013-08-10
69
    </div>
improve blame page design
Yuki Kimoto authored on 2016-01-13
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
Yuki Kimoto authored on 2013-08-10
89
      </div>
90
    </div>
improve blame page design
Yuki Kimoto authored on 2016-01-13
91
    <div class="blame-body-container">
92
      <table class="blame-body">
improve blame design
Yuki Kimoto authored on 2013-08-10
93
        % for my $line (@$blame_lines) {
improve blame page design
Yuki Kimoto authored on 2016-01-13
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...
Yuki Kimoto authored on 2013-08-10
105
          <tr id="L<%= $line->{number} %>">
improve blame design
Yuki Kimoto authored on 2013-08-10
106
            % if ($line->{before_same_commit}) {
improve blame page design
Yuki Kimoto authored on 2016-01-13
107
              <td class="blame-body-left" nowrap style="border-right:2px solid <%= $hot_color %>"></td>
improve blame design
Yuki Kimoto authored on 2013-08-10
108
            % } else {
improve blame page design
Yuki Kimoto authored on 2016-01-13
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
Yuki Kimoto authored on 2013-08-10
112
                    <%= $summary_short %>
113
                  </div>
improve blame page design
Yuki Kimoto authored on 2016-01-13
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
Yuki Kimoto authored on 2013-08-10
123
              </td>
124
            % }
improve blame page design
Yuki Kimoto authored on 2016-01-13
125
            <td class="blame-body-center" nowrap>
improve blame design
Yuki Kimoto authored on 2013-08-10
126
              <%= $line->{number} %>
127
            </td>
improve blame page design
Yuki Kimoto authored on 2016-01-13
128
            <td nowrap class="blame-body-right">
improve blame design
Yuki Kimoto authored on 2013-08-10
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
Yuki Kimoto authored on 2013-08-10
135
  </div>
136
  
137
  %= include '/include/footer';