Moved JS into its own file.
[catagits/Gitalist.git] / root / fragment / ref / tree.tt2
old mode 100644 (file)
new mode 100755 (executable)
index f690386..0ec6c16
@@ -1,39 +1,60 @@
 [% BLOCK tree_table_headfoot %]
 [% SET cell = type == 'head' ? 'th' : 'td' %]
   <tr>
-   <[% cell %]>mode</[% cell %]>
-   <[% cell %]>file</[% cell %]>
-   <[% cell %]>actions</[% cell %]>
+   <[% cell %]>Mode</[% cell %]>
+   <[% cell %]>Folder / File</[% cell %]>
+   <[% cell %]>Actions</[% cell %]>
+   <[% cell %]>Message</[% cell %]>
   </tr>
 [% END %]
-<table class='tree listing'>
- <thead>[% PROCESS tree_table_headfoot type = 'head' %]</thead>
- <tfoot>[% PROCESS tree_table_headfoot type = 'foot' %]</tfoot>
+[%-
+       SET counter         = 1;
+       
+       # sort files and folders
+       SET tree_files          = [];
+       SET tree_folders        = [];
+       FOREACH item IN tree_list;
+               IF item.type == "blob";
+                       tree_files.push(item);
+               ELSE;
+                       tree_folders.push(item);
+               END;
+       END;
+%]
 
- <tbody>
-  [% FOREACH item IN tree_list %]
-  <tr>
-   <td class='file-mode'>[% item.modestr %]</td>
-   [%-
-        action_type = item.type == 'tree' ? 'tree' : 'blob';
-        action_for_link = item.type == 'tree' ? '/ref/tree' : '/ref/blob';
-        blob_or_tree_link = c.uri_for_action(action_for_link, c.req.captures, c.req.args.to_path(item.file))
-   -%]
-   <td class='file-name'>
-    <a href="[% blob_or_tree_link %]">[% item.file %]</a>
-   </td>
-   <td class='action-list'>
-     <a href="[% blob_or_tree_link %]">[% theact %]</a>
+[% BLOCK output_tree %]
+       [% FOREACH item IN tree_type.sort('file') %]
+       <tr [% "class='invert'" IF counter % 2 %]>
+               <td class='file-mode'>[% item.modestr %]</td>
+         [%-
+              action_type     = item.type == 'tree' ? 'tree' : 'blob';
+              action_for_link = item.type == 'tree' ? '/ref/tree' : '/ref/blob';
+              blob_or_tree_link = c.uri_for_action(action_for_link, c.req.captures, c.req.args.to_path(item.file))
+         -%]
+               <td class="file-name"><a href="[% blob_or_tree_link %]" class="[% item.type == 'blob' ? 'file' : 'folder' %]">[% item.file %]</a></td>
+               <td class='action-list'>
+       <a href="[% blob_or_tree_link %]">[% theact %]</a>
          [% IF item.type == 'blob' %]
-         <a href="[% c.uri_for_action('/ref/blob', c.req.captures, c.req.args.to_path(item.file)) %]">blob</a>
-         <a href="[% c.uri_for_action('/ref/blame', c.req.captures, c.req.args.to_path(item.file)) %]">blame</a>
+       <a href="[% c.uri_for_action('/ref/blob', c.req.captures, c.req.args.to_path(item.file)) %]" title="Blob" class="button blob">Blob</a>
+       <a href="[% c.uri_for_action('/ref/raw', c.req.captures, c.req.args.to_path(item.file)) %]" title="Raw" class="button raw">raw</a>
+       <a href="[% c.uri_for_action('/ref/blame', c.req.captures, c.req.args.to_path(item.file)) %]" title="Blame" class="button blame">blame</a>
          [% END %]
-     <a href="[% c.uri_for_action('/ref/history', c.req.captures, c.req.args.to_path(item.file)) %]">history</a>
-     [% IF item.type == 'blob' %]
-     <a href="[% c.uri_for_action('/ref/raw', c.req.captures, c.req.args.to_path(item.file)) %]">raw</a>
-     [% END %]
-   </td>
-  </tr>
-  [% END %]
- </tbody>
+           <a href="[% c.uri_for_action('/ref/history', c.req.captures, c.req.args.to_path(item.file)) %]" title="History (Short log)" class="button shortlog">Short log</a>
+               </td>
+          <td class="message"><span class='js-data'>[% c.req.args.to_path(item.file) %]</span>Loading commit info ...</td>
+       </tr>
+               [% counter = counter + 1 %]
+       [% END %]
+[% END %]
+
+<table class="listing" id="commit-tree">
+<thead>[% PROCESS tree_table_headfoot type = 'head' %]</thead>
+<tbody>
+       [% INCLUDE output_tree tree_type => tree_folders %]
+       [% PROCESS output_tree tree_type => tree_files   %]
+</tbody>
 </table>
+
+[%- # We use uri_for instead of uri_for_action as we *want* a /fragment URI in this case %]
+<span id='file_commit_info-uri' class='js-data'>[% c.uri_for('/fragment/' _ Repository.name _ '/' _ Commit.sha1 _ '/file_commit_info') %]</span>
+<span id='commit-uri' class='js-data'>[% c.uri_for_action('/ref/commit', [Repository.name, 'HEAD']) %]</span>
\ No newline at end of file