Make history a fragment properly. It's not working, but doesn't explode any more
Tomas Doran [Fri, 22 Jan 2010 22:06:53 +0000 (22:06 +0000)]
root/_history.tt2 [deleted file]
root/commit/history.tt2
root/fragment/commit/history.tt2 [new file with mode: 0644]
t/01app.t

diff --git a/root/_history.tt2 b/root/_history.tt2
deleted file mode 100644 (file)
index 83f09e1..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-<table class='history listing'>
- <thead>
-  <tr>
-   <th>sha1</th>
-   <th>time</th>
-   <th>author</th>
-   <th>message</th>
-   <th>actions</th>
-  </tr>
- </thead>
-
- <tfoot>
-  <tr>
-   <td>sha1</td>
-   <td>time</td>
-   <td>author</td>
-   <td>message</td>
-   <td>actions</td>
-  </tr>
- </tfoot>
-
- <tbody>
- [% FOREACH line IN log_lines %]
-  <tr>
-   <td class='sha1' title='[% line.sha1 %]'>[% INCLUDE '_chroma_hash.tt2' sha1 = line.sha1.substr(0, 7) %]</td>
-   <td class='time-since' title='[% line.authored_time %]'>[% time_since(line.authored_time) %]</td>
-   <td class='author'>[% line.author.name | html %]</td>
-   <td>
-     [% short_cmt(line.comment) | html %]
-     [% INCLUDE '_refs.tt2' object = line.0 %]
-   </td>
-   <td class='action-list'>
-   [% IF filetype == 'tree' %]
-     <a href="[% c.uri_for("tree", {h=line.sha1, hb=line.sha1}) %]">tree</a>
-    [% ELSIF filetype == 'blob' %]
-     <a href="[% c.uri_for("blob", {hb=line.sha1, f=filename}) %]">blob</a>
-    [% END %]
-     <a href="[% c.uri_for("commitdiff", {h=line.sha1}) %]">commitdiff</a>
-    [% IF filetype == 'blob' %]
-     <a href="[% c.uri_for("blobdiff", {hb="HEAD", hpb=line.sha1, f=filename}) %]">diff to current</a>
-     [% END %]
-   </td>
-  </tr>
- [% END %]
- </tbody>
-</table>
index babb960..e580ead 100644 (file)
@@ -1,7 +1,3 @@
 [% INCLUDE 'nav/actions.tt2' object = commit %]
 
-[%
-  INCLUDE '_log_pager.tt2';
-  INCLUDE '_history.tt2';
-  INCLUDE '_log_pager.tt2';
-%]
+[% subinclude('/fragment/commit/history', c.req.captures, c.req.args.to_path) %]
diff --git a/root/fragment/commit/history.tt2 b/root/fragment/commit/history.tt2
new file mode 100644 (file)
index 0000000..a405234
--- /dev/null
@@ -0,0 +1,51 @@
+[%
+  INCLUDE '_log_pager.tt2';
+%]  <table class='history listing'>
+   <thead>
+    <tr>
+     <th>sha1</th>
+     <th>time</th>
+     <th>author</th>
+     <th>message</th>
+     <th>actions</th>
+    </tr>
+   </thead>
+
+   <tfoot>
+    <tr>
+     <td>sha1</td>
+     <td>time</td>
+     <td>author</td>
+     <td>message</td>
+     <td>actions</td>
+    </tr>
+   </tfoot>
+
+   <tbody>
+   [% FOREACH line IN log_lines %]
+    <tr>
+     <td class='sha1' title='[% line.sha1 %]'>[% INCLUDE '_chroma_hash.tt2' sha1 = line.sha1.substr(0, 7) %]</td>
+     <td class='time-since' title='[% line.authored_time %]'>[% time_since(line.authored_time) %]</td>
+     <td class='author'>[% line.author.name | html %]</td>
+     <td>
+       [% short_cmt(line.comment) | html %]
+       [% INCLUDE '_refs.tt2' object = line.0 %]
+     </td>
+     <td class='action-list'>
+     [% IF filetype == 'tree' %]
+       <a href="[% c.uri_for("tree", {h=line.sha1, hb=line.sha1}) %]">tree</a>
+      [% ELSIF filetype == 'blob' %]
+       <a href="[% c.uri_for("blob", {hb=line.sha1, f=filename}) %]">blob</a>
+      [% END %]
+       <a href="[% c.uri_for("commitdiff", {h=line.sha1}) %]">commitdiff</a>
+      [% IF filetype == 'blob' %]
+       <a href="[% c.uri_for("blobdiff", {hb="HEAD", hpb=line.sha1, f=filename}) %]">diff to current</a>
+       [% END %]
+     </td>
+    </tr>
+   [% END %]
+   </tbody>
+  </table>
+[%
+  INCLUDE '_log_pager.tt2';
+%]
index aea441c..0cb8be5 100644 (file)
--- a/t/01app.t
+++ b/t/01app.t
@@ -12,7 +12,10 @@ BEGIN {
 }
 use TestGitalist;
 
-for my $p ('', qw/ repo1 nodescription bare.git opml search /) {
+for my $p ('', qw{
+    repo1 nodescription bare.git opml search
+    fragment/collectionofrepositories
+}) {
     my $path = '/' . $p;
     ok( request($path)->is_success, "$path should succeed");
 }
@@ -20,7 +23,26 @@ for my $p ('', qw/ repo1 nodescription bare.git opml search /) {
 my $response = request('/DoesNotExist');
 is $response->code, 404, 'invalid repository 404s';
 like $response->content, qr/Page not found/, 'invalid repository handled correctly';
-
+{
+  # URI tests for repo1
+  local *test = curry_test_uri('fragment/repo1');
+  test('');
+  test('shortlog');
+  test('log');
+  test('reflog');
+  test('heads');
+  test('tags');
+  test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818');
+  test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/tree');
+  test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/tree/dir1');
+  test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/diff');
+  test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/diff/plain');
+  test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/shortlog/dir1');
+  test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/history/dir1');
+  test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blame/file1');
+  test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/raw/file1');
+  test('36c6c6708b8360d7023e8a1649c45bcf9b3bd818/blob/file1');
+}
 
 {
   # URI tests for repo1