Add age to commit info.
Dan Brook [Sat, 24 Apr 2010 16:29:07 +0000 (17:29 +0100)]
lib/Gitalist/Controller/Fragment/Ref.pm
root/fragment/ref/tree.tt2

index f110803..a2e02e3 100644 (file)
@@ -127,9 +127,13 @@ after file_commit_info => sub {
        file   => $c->stash->{filename},
     );
 
-    my $json_obj = $commit
-                 ? { sha1 => $commit->sha1, comment => $c->stash->{short_cmt}->($commit->comment) }
-                 : { };
+    my $json_obj = !$commit
+                 ? { }
+                 : {
+                    sha1    => $commit->sha1,
+                    comment => $c->stash->{short_cmt}->($commit->comment),
+                    age     => $c->stash->{time_since}->($commit->authored_time),
+                };
 
     $c->response->content_type('application/json');
     # XXX Make use of the json branch
index a946408..4e0965e 100755 (executable)
@@ -7,7 +7,7 @@ $(window).load(function() {
     var filename = cell.parent().find('.file-name').text();
     $.getJSON('/fragment/Gitalist/[% Commit.sha1 %]/file_commit_info/'+filename, {}, function(commitInfo) {
       cell.empty();
-      cell.html('<a href="/Gitalist/'+commitInfo.sha1+'/commit">'+commitInfo.comment+'</a>');
+      cell.html('<a href="/Gitalist/'+commitInfo.sha1+'/commit">'+commitInfo.comment+'</a> '+commitInfo.age);
     });
   });
 });