Fixed the links in the history view.
Dan Brook [Mon, 1 Mar 2010 16:14:05 +0000 (16:14 +0000)]
This fix mostly revolves around getting 'diff to current' to JFW, as such
this isn't the most elegant solution. *ahem*

README
lib/Gitalist/Controller/Fragment/Ref.pm
lib/Gitalist/Git/Object/Commit.pm
lib/Gitalist/Git/Repository.pm
lib/Gitalist/URIStructure/Ref.pm
root/_diff.tt2
root/_diff_tree.tt2
root/fragment/ref/history.tt2
root/ref/diff_fancy.tt2

diff --git a/README b/README
index 86853b2..dcdf72f 100644 (file)
--- a/README
+++ b/README
@@ -41,7 +41,7 @@ GETTING GITALIST
 
     The canonical repository for the master branch is:
 
-        it://git.shadowcat.co.uk/catagits/Gitalist.git
+        git://git.shadowcat.co.uk/catagits/Gitalist.git
 
     Gitalist is also mirrored to github, and a number of people have active
     forks with branches and/or new features in the master branch.
@@ -83,13 +83,13 @@ INITIAL CONFIGURATION
 
     Alternatively, if you only want to set a repository directory and are
     otherwise happy with the default configuration, then you can set the
-    "GITALIST_REPOS_DIR" environment variable, or pass the "--repos_dir"
-    flag to any of the scripts.
+    "GITALIST_REPO_DIR" environment variable, or pass the "--repos_dir" flag
+    to any of the scripts.
 
-        GITALIST_REPOS_DIR=/home/myuser/code/git gitalist_server.pl
+        GITALIST_REPO_DIR=/home/myuser/code/git gitalist_server.pl
         gitalist_server.pl --repos_dir home/myuser/code/git
 
-    The "GITALIST_REPOS_DIR" environment variable will override the
+    The "GITALIST_REPO_DIR" environment variable will override the
     repository directory set in configuration, and will itself be overridden
     by he "--repos_dir" flag.
 
index 24e8d58..c079eb0 100644 (file)
@@ -10,13 +10,15 @@ with qw/
 
 sub base : Chained('/fragment/repository/find') PathPart('') CaptureArgs(0) {}
 
-after diff => sub {
+sub _diff {
     my ($self, $c) = @_;
     my $commit = $c->stash->{Commit};
+    my %filename = $c->stash->{filename} ? (filename => $c->stash->{filename}) : ();
     my($tree, $patch) = $c->stash->{Repository}->diff(
         commit => $commit,
-        parent => $c->req->param('hp') || undef,
+        parent => $c->stash->{parent},
         patch  => 1,
+        %filename,
     );
     $c->stash(
       diff_tree => $tree,
@@ -24,16 +26,19 @@ after diff => sub {
       # XXX Hack hack hack, see View::SyntaxHighlight
       blobs     => [map $_->{diff}, @$patch],
       language  => 'Diff',
+      %filename,
     );
-};
+}
 
 after diff_fancy => sub {
     my ($self, $c) = @_;
+    $self->_diff($c);
     $c->forward('View::SyntaxHighlight');
 };
 
 after diff_plain => sub {
     my ($self, $c) = @_;
+    $self->_diff($c);
     $c->response->content_type('text/plain; charset=utf-8');
 };
 
index ef36f05..921fb6b 100644 (file)
@@ -49,7 +49,7 @@ class Gitalist::Git::Object::Commit
 
         method diff ( Maybe[Bool] :$patch?,
                        Maybe[NonEmptySimpleStr] :$parent?,
-                       Maybe[NonEmptySimpleStr] :$file?
+                       Maybe[NonEmptySimpleStr] :$filename?
                    ) {
             $parent = $parent
                 ? $parent
@@ -57,7 +57,7 @@ class Gitalist::Git::Object::Commit
                         ? $self->parent_sha1
                             : '-c';
             my @etc = (
-                ( $file  ? ('--', $file) : () ),
+                ( $filename  ? ('--', $filename) : () ),
             );
 
             my @out = $self->_raw_diff(
index f65eb0b..5a3fa0f 100644 (file)
@@ -186,11 +186,11 @@ class Gitalist::Git::Repository with Gitalist::Git::HasUtils {
     method diff ( Gitalist::Git::Object :$commit!,
                   Bool :$patch?,
                   Maybe[NonEmptySimpleStr] :$parent?,
-                  NonEmptySimpleStr :$file?
+                  NonEmptySimpleStr :$filename?
               ) {
               return $commit->diff( patch => $patch,
                                     parent => $parent,
-                                    file => $file);
+                                    filename => $filename);
     }
 
     method reflog (@logargs) {
index afea1ee..659ccc0 100644 (file)
@@ -24,7 +24,14 @@ sub find : Chained('base') PathPart('') CaptureArgs(1) {
 
 sub diff : Chained('find') CaptureArgs(0) {}
 
-sub diff_fancy : Chained('diff') PathPart('') Args(0) {}
+sub diff_fancy : Chained('diff') PathPart('') Args() {
+    my($self, $c, $comparison, @rest) = @_;
+    # FIXME - This ain't pretty
+    $c->stash->{parent}   = $comparison
+      if $comparison;
+    $c->stash->{filename} = $rest[0]
+      if @rest;
+}
 
 sub diff_plain : Chained('diff') PathPart('plain') Args(0) {}
 
index 146f778..404de8b 100644 (file)
@@ -2,7 +2,7 @@
 [% FOREACH item IN diff %]
 <div class='diff-head'>
  diff --git [%# FIXME %]
- <a href='[% c.uri_for_action("/ref/blob", [Repository.name, Commit.sha1], item.file) %]'>[% item.a %][% item %]</a>
+ <a href='[% c.uri_for_action("/ref/blob", [Repository.name, Commit.sha1], item.file) %]'>[% item.a %]</a>
  <a href='[% c.uri_for_action("/ref/blob", [Repository.name, Commit.sha1], item.file) %]'>[% item.b %]</a>
 </div>
 <div class='diff-index'>
index 792591e..eb9a845 100644 (file)
@@ -32,7 +32,7 @@
     %]
    </td>
    <td class='action-list'>
-     [% IF !line.is_new %]<a href="[% c.uri_for_action("/ref/diff", [Repository.name, Commit.sha1], line.file.to_path) %]">diff</a>[% END %]
+     [% IF !line.is_new %]<a href="[% c.uri_for_action("/ref/diff_fancy", [Repository.name, Commit.sha1], line.file.to_path) %]">diff</a>[% END %]
      <a href="[% c.uri_for_action("/ref/blob", [Repository.name, Commit.sha1], line.file.to_path) %]">blob</a>
      [% IF !line.is_new %]<a href="[% c.uri_for("/ref/shortlog", [Repository.name, Commit.sha1], line.file.to_path) %]">history</a>[% END %]
    </td>
index a411337..41dd259 100644 (file)
      </td>
      <td class='action-list'>
      [% IF filetype == 'tree' %]
-       <a href="[% c.uri_for("tree", {h=line.sha1, hb=line.sha1}) %]">tree</a>
+       <a href="[% c.uri_for_action("/ref/tree", [Repository.name, line.sha1], filename) %]">blob</a>
       [% ELSIF filetype == 'blob' %]
-       <a href="[% c.uri_for("blob", {hb=line.sha1, f=filename}) %]">blob</a>
+       <a href="[% c.uri_for_action("/ref/blob", [Repository.name, line.sha1], filename) %]">blob</a>
       [% END %]
-       <a href="[% c.uri_for("commitdiff", {h=line.sha1}) %]">commitdiff</a>
+       <a href="[% c.uri_for_action("/ref/diff_fancy", [Repository.name, line.sha1]) %]">commitdiff</a>
       [% IF filetype == 'blob' %]
-       <a href="[% c.uri_for("blobdiff", {hb="HEAD", hpb=line.sha1, f=filename}) %]">diff to current</a>
+       <a href="[% c.uri_for_action("/ref/diff_fancy", [Repository.name, line.sha1], 'HEAD', filename) %]">diff to current</a>
        [% END %]
      </td>
     </tr>
index bdecf06..82a2740 100644 (file)
@@ -9,6 +9,8 @@
     <img style="float: left; padding-right: 10px" src="[% uri_for_gravatar(Commit.committer.email, 40) %]">[% Commit.author.name | html %] <br />[% time_since(Commit.authored_time) %]
   </div>
 
-
-  [% subinclude('/fragment/ref/diff_fancy', c.req.captures c.req.args.to_path) %]
+  [%
+    # What I really want is @{ c.req.args }
+    subinclude('/fragment/' _ c.action, c.req.captures, c.req.args.0 c.req.args.1)
+  %]
 </div>