Showing 2 changed files with 52 additions and 31 deletions
+15 -2
lib/Gitprep/Git.pm
... ...
@@ -179,7 +179,6 @@ sub blame {
179 179
   my $blame_lines = [];
180 180
   my $blame_line;
181 181
   while (my $line = $self->_dec(scalar <$fh>)) {
182
-    warn $line;
183 182
     chomp $line;
184 183
     
185 184
     if ($blame_line) {
... ...
@@ -189,6 +188,11 @@ sub blame {
189 188
       elsif ($line =~ /^author-mail +(.+)/) {
190 189
         $blame_line->{author_mail} = $1;
191 190
       }
191
+      elsif ($line =~ /^author-time +(.+)/) {
192
+        my $author_time = $1;
193
+        my $author_age_string_date = $self->_age_string_date($author_time);
194
+        $blame_line->{author_age_string_date} = $author_age_string_date;
195
+      }
192 196
       elsif ($line =~ /^summary +(.+)/) {
193 197
         $blame_line->{summary} = $1;
194 198
       }
... ...
@@ -203,7 +207,7 @@ sub blame {
203 207
     elsif ($line =~ /^([a-fA-F0-9]{40}) +\d+ +(\d+)/) {
204 208
       $blame_line = {};
205 209
       $blame_line->{commit} = $1;
206
-      $blame_line->{line} = $2;
210
+      $blame_line->{number} = $2;
207 211
       if ($blame_lines->[-1]
208 212
         && $blame_lines->[-1]{commit} eq $blame_line->{commit})
209 213
       {
... ...
@@ -215,6 +219,15 @@ sub blame {
215 219
   return $blame_lines;
216 220
 }
217 221
 
222
+sub _age_string_date {
223
+  my ($self, $age) = @_;
224
+
225
+  my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday) = gmtime($age);
226
+  my $age_string_date = sprintf '%4d-%02d-%02d', 1900 + $year, $mon + 1, $mday;
227
+  
228
+  return $age_string_date;
229
+}
230
+
218 231
 sub blob {
219 232
   my ($self, $user, $project, $rev, $file) = @_;
220 233
   
+37 -29
templates/blame.html.ep
... ...
@@ -28,7 +28,7 @@
28 28
   my $mime_type = $git->blob_mime_type($user, $project, $rev, $file);
29 29
 
30 30
   # Blame
31
-  my $lines = $git->blame($user, $project, $rev, $file);
31
+  my $blame_lines = $git->blame($user, $project, $rev, $file);
32 32
 
33 33
   # Variables for included template
34 34
   stash(id => $rev, project => $project, rev => $rev);
... ...
@@ -36,7 +36,6 @@
36 36
 
37 37
 % layout 'common' , title => "$project/$file at $rev \x{30fb} $user/$project";
38 38
 
39
-%
40 39
   %= include '/include/header';
41 40
 
42 41
   <div class="container">
... ...
@@ -57,45 +56,54 @@
57 56
       </div>
58 57
     </div>
59 58
 
60
-    <div class="border-gray bk-gray-light" style="padding:5px">
59
+    <div class="border-gray bk-gray-light" style="padding:5px; border-bottom:none">
61 60
       <div class="row">
62 61
         <div class="span7" style="padding-top:5px">
63 62
           <i class="icon-file icon-white"></i>
64 63
           <%= $file_type %>
65 64
           <span class="muted">|</span>
66
-          <%= @$lines %> lines
65
+          <%= @$blame_lines %> lines
67 66
           <span class="muted">|</span>
68 67
           <%= $file_size %>kb
69 68
         </div>
70 69
         <div class="text-right">
71
-          <a class="btn" href="<%= url_for("/$user/$project/raw/$rev/$file") %>">Raw</a>
72
-          <a class="btn" href="<%= url_for("/$user/$project/blame/$rev/$file") %>">Normal View</a>
73
-          <a class="btn" href="<%= url_for("/$user/$project/commits/$rev/$file") %>">History</a>
70
+          <a class="btn" href="<%= url_for("/$user/$project/raw/$rev/$file") %>">Raw</a><a class="btn" href="<%= url_for("/$user/$project/blob/$rev/$file") %>">Normal View</a><a class="btn" href="<%= url_for("/$user/$project/commits/$rev/$file") %>">History</a>
74 71
         </div>
75 72
       </div>
76 73
     </div>
77
-    % if ($mime_type =~ m#^image/#) {
78
-      <div style="background:#ddd;text-align:center;padding-top:30px;padding-bottom:30px;margin-bottom:30px">
79
-        <img type="<%= $mime_type %>
80
-          % if (defined $file) {
81
-            alt="<%= $file %>" title="<%= $file %>"
82
-          % }
83
-          src="<%= url_for("/$user/$project/raw/$rev/$file") %>"
84
-        />
85
-      </div>
86
-    % } elsif ($mime_type =~ m#^text/#) {
87
-      <pre class="prettyprint linenums"><% for my $line (@$lines) { %><%= "$line\n" %><% } %></pre>
88
-    % } else {
89
-      <div style="font-size:16px;background:#ddd;text-align:center;padding-top:30px;padding-bottom:30px;margin-bottom:30px">
90
-        <a href="<%= url_for("/$user/$project/raw/$rev/$file") %>">View raw</a>
91
-      </div>
92
-    % }
74
+    <div class="border-gray" style="width:938px;overflow-x:scroll;border-top:none">
75
+      <table>
76
+        % for my $line (@$blame_lines) {
77
+          % my $blame_commit = $line->{commit};
78
+          % my $summary = $line->{summary};
79
+          % my $summary_short= length $summary > 28 ? substr($summary, 0, 28) . '...' : $summary;
80
+          <tr>
81
+            % if ($line->{before_same_commit}) {
82
+              <td nowrap class="border-gray" style="padding:5px 10px; background:#f7f7f7;vertical-align:middle;border-left:none;border-top:none" >
83
+              </td>
84
+            % } else {
85
+              <td nowrap class="border-gray" style="padding:5px 10px; background:#f7f7f7;vertical-align:middle;border-left:none;border-bottom:none" >
86
+                  <div style="margin-bottom:0;padding-botttom:0">
87
+                    <a href="<%= url_for("/$user/$project/commit/$blame_commit") %>" ><%= substr($blame_commit, 0, 8) %></a>
88
+                    <a href="<%= url_for("/$user/$project/blame/$blame_commit/$file") %>" >»</a>
89
+                    <span title="<%= $line->{author_mail} %>"><%= $line->{author} %></span>
90
+                  </div>
91
+                  <div style="margin-top:0;padding-top:0">
92
+                    <%= $line->{author_age_string_date} %>
93
+                    <%= $summary_short %>
94
+                  </div>
95
+              </td>
96
+            % }
97
+            <td nowrap class="border-gray" style="padding:5px 10px;color:gray;font-size:12px;vertical-align:middle;">
98
+              <%= $line->{number} %>
99
+            </td>
100
+            <td nowrap class="border-gray" style="padding:5px 10px;vertical-align:middle;white-space: nowrap;border-right:none">
101
+              <pre style="border:none;background:white;margin:0;padding:0;white-space: nowrap;"><%= $line->{content} %></pre>
102
+            </td>
103
+          </tr>
104
+        % }
105
+      </table>
106
+    </div>
93 107
   </div>
94 108
   
95
-  %= javascript '/js/google-code-prettify/prettify.js';
96
-  %= javascript begin
97
-    // Google prety print
98
-    prettyPrint();
99
-  % end
100
-  
101 109
   %= include '/include/footer';