Another freshly added action - /tree.
broquaint [Fri, 23 Oct 2009 17:01:39 +0000 (18:01 +0100)]
TODO
lib/Gitalist/Controller/Root.pm
lib/Gitalist/Model/Git.pm
templates/blob.tt2
templates/shortlog.tt2
templates/tree.tt2 [new file with mode: 0644]

diff --git a/TODO b/TODO
index 2071fd0..6a05e77 100644 (file)
--- a/TODO
+++ b/TODO
@@ -2,3 +2,4 @@
 * An action to find what branches have been merged, either as a list or through a search mechanism.
 * An action to find which branches a given commit is on.
 * Fix any not text/html bits e.g the patch action.
+* Simplify the creation of links.
index 7fac165..706d024 100644 (file)
@@ -157,6 +157,23 @@ sub shortlog : Local {
   );
 }
 
+=head2 tree
+
+The tree of a given commit.
+
+=cut
+
+sub tree : Local {
+  my ( $self, $c ) = @_;
+
+  $c->stash(
+      # XXX Useful defaults needed ...
+      commit => $c->model('Git')->get_object($c->req->param('h')),
+      tree   => $c->model('Git')->get_object($c->req->param('hb')),
+      action => 'tree',
+  );
+}
+
 =head2 auto
 
 Populate the header and footer. Perhaps not the best location.
index aa45676..2ba3717 100644 (file)
@@ -316,10 +316,11 @@ sub list_tree {
     my ($mode, $type, $object, $file) = split /\s+/, $line, 4;
 
     push @ret, {
-      mode   => oct $mode,
-      type   => $type,
-      object => $object,
-      file   => $file,
+      mode    => oct $mode,
+      modestr => $self->get_object_mode_string({mode=>oct $mode}),
+      type    => $type,
+      object  => $object,
+      file    => $file,
     };
   }
 
index 4c2a5bb..e23dfb0 100644 (file)
@@ -1,5 +1,6 @@
-[% PROCESS 'commit-nav.tt2' object = head %]
 <link rel="stylesheet" type="text/css" href="/static/css/syntax-dark.css"/>
+
+[% PROCESS 'commit-nav.tt2' object = head %]
 <div class='commit-message'>
 [% head.comment.substr(0, 85) %] ...
 </div>
index 6211d3b..a84b00b 100644 (file)
@@ -23,7 +23,7 @@
    <td class='action-list'>
      <a href="/commit?p=[% project %];h=[% line.sha1 %]">commit</a>
      <a href="/commitdiff?p=[% project %];h=[% line.sha1 %]">commitdiff</a>
-     <a href="/tree?p=[% project %];h=[% line.sha1 %];hb=[% line.tree_sha1 %]">history</a>
+     <a href="/tree?p=[% project %];h=[% line.sha1 %];hb=[% line.tree_sha1 %]">tree</a>
    </td>
   </tr>
  [% END %]
diff --git a/templates/tree.tt2 b/templates/tree.tt2
new file mode 100644 (file)
index 0000000..82580b1
--- /dev/null
@@ -0,0 +1,40 @@
+[% INCLUDE 'commit-nav.tt2' object = commit %]
+
+<div class='commit-message'>
+[% commit.comment.substr(0, 85) %] ...
+</div>
+
+<table>
+ <thead>
+  <tr>
+   <td>mode</td>
+   <td>file</td>
+   <td>actions</td>
+  </tr>
+ </thead>
+
+ <tbody>
+  [% FOREACH item IN c.model('Git').list_tree(commit.sha1) %]
+  <tr>
+   <td>[% item.modestr %]</td>
+   [% theact = item.type == 'tree' ? 'tree' : 'blob' -%]
+   <td>
+    <a href="/[% theact %]?h=[% item.object %];hb=[% commit.sha1 %];f=[% item.file %]">[% item.file %]</a>
+   </td>
+   <td class='action-list'>
+     <a href="/[% theact %]?p=[% project %];h=[% item.object %]">[% theact %]</a>
+     <a href="/history?p=[% project %];h=[% item.object %]">history</a>
+     <a href="/raw?p=[% project %];h=[% item.object %]">raw</a>
+   </td>
+  </tr>
+  [% END %]
+ </tbody>
+
+ <tfoot>
+  <tr>
+   <td>mode</td>
+   <td>file</td>
+   <td>actions</td>
+  </tr>
+ </tfoot>
+</table>