Fixed a couple of bugs.
broquaint [Fri, 6 Nov 2009 16:23:07 +0000 (16:23 +0000)]
One bug involved the template subs not being accessible after forwarding
to View::SyntaxHighlight.
Another where Cat was choking on wide entities e.g viewing 1fd8159 in
/commitdiff would trigger this.

lib/Gitalist/Controller/Root.pm
lib/Gitalist/View/SyntaxHighlight.pm
root/_heads.tt2
root/commit.tt2
root/index.tt2
root/log.tt2
root/static/css/site.css

index 55a320c..550dcb8 100644 (file)
@@ -363,11 +363,24 @@ Populate the header and footer. Perhaps not the best location.
 =cut
 
 sub auto : Private {
-    my($self, $c) = @_;
+  my($self, $c) = @_;
 
-    # Yes, this is hideous.
-    $self->header($c);
-    $self->footer($c);
+  # XXX Move these to a plugin!
+  $c->stash(
+    time_since => sub {
+      return age_string(time - $_[0]->epoch);
+    },
+    short_cmt => sub {
+      my $cmt = shift;
+      my($line) = split /\n/, $cmt;
+      $line =~ s/^(.{70,80}\b).*/$1 …/;
+      return $line;
+    },
+  );
+
+  # Yes, this is hideous.
+  $self->header($c);
+  $self->footer($c);
 }
 
 # XXX This could probably be dropped altogether.
@@ -559,18 +572,6 @@ sub end : ActionClass('RenderView') {
   if ($c->stash->{project}) {
       $c->stash->{HEAD} = $c->model()->head_hash;
   }
-
-  # XXX Move these to a plugin!
-  $c->stash->{time_since} = sub {
-    return age_string(time - $_[0]->epoch);
-  };
-  $c->stash->{short_cmt} = sub {
-    my $cmt = shift;
-    print STDERR "got [$cmt]\n";
-    my($line) = split /\n/, $cmt;
-    $line =~ s/^(.{70,80}\b).*/$1 …/;
-    return $line;
-  };
 }
 
 sub age_string {
index 688be51..5e90ed8 100644 (file)
@@ -77,7 +77,9 @@ sub highlight {
                 },
             );
 
-            $hl->highlightText($blob);
+            my $hltxt = $hl->highlightText($blob);
+            $hltxt =~ s/([^[:ascii:]])/encode_entities($1)/eg;
+            $hltxt;
         };
         warn $@ if $@;
     }
index 74e46ab..4e2415c 100644 (file)
@@ -1,6 +1,7 @@
 <table class='heads'>
  <thead>
   <tr>
+   <th>HEAD</th>
    <th>age</th>
    <th>branch</th>
    <th>actions</th>
@@ -8,6 +9,7 @@
  </thead>
  <tfoot>
   <tr>
+   <td>HEAD</td>
    <td>age</td>
    <td>branch</td>
    <td>actions</td>
  <tbody>
  [% FOREACH head IN heads %]
   <tr>
-   <td>[% time_since(head.last_change) %]</td>
+   <td>[% INCLUDE '_chroma_hash.tt2' sha1 = head.sha1.substr(0,7) %]</td>
+   <td class='time-since'>[% time_since(head.last_change) %]</td>
    <td class='head[% head.sha1 == HEAD ? ' current' : '' %]'>[% head.name %]</td>
    <td class='action-list'>
-     <a href="[% c.uri_for("shortlog", {h=head.sha1}) %]">shortlog</a>
-     <a href="[% c.uri_for("log", {h=head.sha1}) %]">log</a>
-     <a href="[% c.uri_for("tree", {h=head.sha1, hb=head.name}) %]">tree</a>
+     <a href="[% c.uri_for("shortlog", {h='refs/head/' _ head.name}) %]">shortlog</a>
+     <a href="[% c.uri_for("log", {h='refs/head/' _ head.name}) %]">log</a>
+     <a href="[% c.uri_for("tree", {h='refs/head/' _ head.name}) %]">tree</a>
    </td>
   </tr>
  [% END %]
index e27fd09..c13cb61 100644 (file)
  [% END %]
 </dl>
 
-<pre class='commit-message'>[% commit.comment %]</pre>
+<pre class='commit-message'>[% commit.comment | html%]</pre>
 
 [%
-# In the case of merge commits there will be no diff tree.
-IF diff_tree.size > 0;
-       INCLUDE '_diff_tree.tt2';
-END;
+  # In the case of merge commits there will be no diff tree.
+  IF diff_tree.size > 0;
+    INCLUDE '_diff_tree.tt2';
+  END;
 %]
index 4cdf3da..1304e7f 100644 (file)
@@ -40,7 +40,7 @@
         <td><a class="list" href="[% c.uri_for('/summary', {p=p.name}) %]">[% p.name %]</a></td>
         <td><a class="list" title="[% p.description %]" href="[% c.uri_for('/summary', {p=p.name} ) %]">[% p.description.split(' ').slice(0, 10).join(' ') %]</a></td>
         <td>[% p.owner %]</td>
-        <td class="age2">[% time_since(p.last_change) %]</td>
+        <td class="time-since">[% time_since(p.last_change) %]</td>
         <td class="link"><a href="[% c.uri_for("summary", {p=p.name}) %]">summary</a>
             | <a href="[% c.uri_for("shortlog", {p=p.name}) %]">shortlog</a>
             | <a href="[% c.uri_for("log", {p=p.name}) %]">log</a>
index 606d64e..e8c771b 100644 (file)
@@ -20,7 +20,7 @@
       <tr><td>committered time</td><td>[% line.committed_time %]</td></tr>
       [% END %]
      </table>
-     <span class="age">[% time_since(line.authored_time) %]</span>
+     <span class="time-since">[% time_since(line.authored_time) %]</span>
      <div class="action-list">
        <a href="[% c.uri_for("commit", {h=line.sha}) %]">commit</a>
      | <a href="[% c.uri_for("commitdiff", {h=line.sha1}) %]">commitdiff</a>
index a643c36..3775fa6 100644 (file)
@@ -71,8 +71,8 @@ div.commit-message {
   margin-bottom: 10px;
 }
 pre.commit-message {
-  border-top:  solid 2px green;
-  border-bottom:  solid 2px red;
+  border-top:  solid 2px red;
+  border-bottom:  solid 2px green;
   padding: 5px;
 }
 .commit-info dt {
@@ -103,7 +103,7 @@ pre.commit-message {
   text-decoration: underline;
 }
 table.heads {
-  width: 50%;
+  width: 75%;
 }
 
 /* /blob */