Hacked in syntax highlighting to the blame view.
Dan Brook [Wed, 25 Nov 2009 14:07:57 +0000 (14:07 +0000)]
lib/Gitalist/Controller/Root.pm
root/blame.tt2

index c479ee3..6203900 100644 (file)
@@ -160,12 +160,19 @@ sub blame : Local {
        || die "Couldn't discern the corresponding head.";
   my $filename = $c->req->param('f') || '';
 
+  my $blame = $project->get_object($hb)->blame($filename);
   $c->stash(
-    blame    => $project->get_object($hb)->blame($filename),
+    blame    => $blame,
     head     => $project->get_object($hb),
     filename => $filename,
+
+    # XXX Hack hack hack, see View::SyntaxHighlight
+    language => ($filename =~ /\.p[lm]$/i ? 'Perl' : ''),
+    blob     => join("\n", map $_->{line}, @$blame),
   );
-  
+
+  $c->forward('View::SyntaxHighlight')
+    unless $c->stash->{no_wrapper};
 }
 
 sub _blob_objs {
@@ -203,7 +210,7 @@ sub blob : Local {
     head     => $head,
     filename => $filename,
     # XXX Hack hack hack, see View::SyntaxHighlight
-    language => ($filename =~ /\.p[lm]$/ ? 'Perl' : ''),
+    language => ($filename =~ /\.p[lm]$/i ? 'Perl' : ''),
     action   => 'blob',
   );
 
index 685867d..92ba1c6 100644 (file)
@@ -1,8 +1,7 @@
+<link rel="stylesheet" type="text/css" href="/static/css/syntax/[% language %].css"/>
 [% PROCESS 'nav/actions.tt2' object = head %]
 [% IF object.type == 'commit' %]
-<div class='commit-message'>
-[% head.comment.substr(0, 85) %] ...
-</div>
+<div class='commit-message'>[% short_cmt(head.comment) %]</div>
 [% END %]
 
 [% INCLUDE 'nav/path.tt2' %]
@@ -30,6 +29,7 @@
  </tfoot>
 
  <tbody>
+ [% blame_lines = blob.split("\n") %]
  [% FOR info IN blame %]
  <tr class=''>
    [%-
@@ -45,7 +45,7 @@
      <td class='commit-info'></td>
      [%- END -%]
    <td class='lineno' style='border-right: solid 3px #[% linecolour %]; border-left: solid 3px #[% linecolour %];'><tt>[% info.meta.lineno %]</tt></td>
-   <td class='data'><pre>[% info.line | html %]</pre></td>
+   <td class='data'><pre>[% blame_lines.${loop.index} %]</pre></td>
    [% lastsha1 = info.commit.sha1 %]
  </tr>
  [% END %]