Limit the number of branches/tags listed by default.
Dan Brook [Fri, 13 Aug 2010 11:18:11 +0000 (12:18 +0100)]
In the quick branch switch and the summary page the number of
branches/tags is now limited to the paging.summary config
setting. This way repos with large numbers of refs no longer bog down
every page or the overview that is the summary.

lib/Gitalist/URIStructure/Repository.pm
root/fragment/ref/commit.tt2
root/fragment/repository/heads.tt2
root/fragment/repository/longlog.tt2
root/fragment/repository/shortlog.tt2
root/repository/summary.tt2
root/static/js/site.js
root/wrapper.tt2

index a2c22db..2e142bd 100644 (file)
@@ -45,8 +45,8 @@ sub object : Chained('find') PathPart('') Args(1) {
 
 sub summary : Chained('find') PathPart('') Args() {}
 
-sub heads : Chained('find') Args(0) {}
+sub heads : Chained('find') Args() {}
 
-sub tags : Chained('find') Args(0) {}
+sub tags : Chained('find') Args() {}
 
 1;
index 8560e1f..9719b1b 100755 (executable)
 <tr class="invert">
        <td class='sha1' title='[% Commit.sha1 %]'>[% INCLUDE 'inc/chroma_hash.tt2' sha1 = Commit.sha1.substr(0, 7) %]</td>
        <td class='time-since'>[% time_since(Commit.authored_time) %]</td>
-       <td rowspan="2">
-       [% Commit.comment | html%]
-       [%
-    INCLUDE '_refs.tt2' object = commit;
-  %]</td>
+       <td rowspan="2">[%
+            message = Commit.comment | html; message.replace("\n", "<br/>");
+           INCLUDE '_refs.tt2' object = commit;
+       %]</td>
        <td class='author'><a href="mailto:[% Commit.author.email %]" title="Email"><img style="float: left; padding-right: 10px" src="[% uri_for_gravatar(Commit.committer.email, 21) %]">[% Commit.author.name | html %]</a></td>
        <td class='action-list'>Author</td>
 </tr>
index 69c5766..be7b04d 100755 (executable)
@@ -22,6 +22,7 @@
      <a href="[% c.uri_for_action('/ref/tree', [Repository.name, head.name]) %]" title="Tree" class="button tree">tree</a>
    </td>
   </tr>
+  [% LAST IF c.req.args.0 AND c.req.args.0 == loop.count %]
  [% END %]
  </tbody>
 </table>
index 3f11484..3ff258d 100755 (executable)
@@ -1,5 +1 @@
 [% INCLUDE 'fragment/repository/shortlog.tt2' longlogformat = 1 %]
-
-
-<h2>Branches</h2>
-[% subinclude('/fragment/repository/heads', [Repository.name]) %]
index 0cde010..70ca25e 100755 (executable)
@@ -42,7 +42,7 @@
 </tr>
 </tbody>
 </table>
-</form
+</form>
 
 <span id="diff-uri" class="js-data">[% c.uri_for_action('/ref/diff_fancy', [Repository.name, 'HEAD']) %]</span> 
 
index a0646e8..a819455 100755 (executable)
@@ -6,10 +6,10 @@
   [% subinclude('/fragment/repository/shortlog', c.req.captures) %]
 
   <h2><a href='[% c.uri_for(c.controller.action_for('heads'), c.req.captures) %]'>Branches</a></h2>
-  [% subinclude('/fragment/repository/heads', c.req.captures) %]
+  [% subinclude('/fragment/repository/heads', c.req.captures, c.config.paging.summary) %]
 
   [% IF Repository.tags.size > 0 %]
   <h2><a href='[% c.uri_for(c.controller.action_for('tags'), c.req.captures) %]'>Tags</a></h2>
-  [% subinclude('/fragment/repository/tags', c.req.captures) %]
+  [% subinclude('/fragment/repository/tags', c.req.captures, c.config.paging.summary) %]
   [% END %]
 
index 076a377..43340d2 100755 (executable)
@@ -45,8 +45,9 @@ function uriFor(action, sha1) {
 }
 
 function switchBranch() {
-    var branch = jQuery('#branch-list').val();
-    document.location.href = uriFor('current', branch);
+    var branch = jQuery('#branch-list').val(),
+        action = branch != '...' ? 'current' : 'heads';
+    document.location.href = uriFor(action, branch);
 }
 
 function compareDiffs(){
index c03a4b2..e4a9057 100755 (executable)
                                        Branches 
                                        <select id='branch-list'>
                                                <option value="">HEAD</option>
-                                       [% FOREACH branch IN Repository.heads %]
+                                       [%- FOREACH branch IN Repository.heads -%]
                                                <option value="[% branch.name %]">[% branch.name %]</option>
-                                       [% END %]
+                                               [% IF loop.count == c.config.paging.summary %]
+                                               <option value="...">&gt;Branch list</option>
+                                               [% LAST %]
+                                               [% END %]
+                                       [% END -%]
                                        
                                        </select>
                                </li>
                        /
                        [%- IF Repository %]
                                [%# FIXME: output branch name in a nicer way!!!  #%]
-                               [% FOREACH branch_head IN Repository.heads %]
-                                       [% IF c.req.path.search(branch_head.name) %]
+                               [%- FOREACH branch_head IN Repository.heads %]
+                                       [%- IF c.req.path.search(branch_head.name) %]
                                <a href="[% c.uri_for_action('/repository/summary', [Repository.name]) %]/[% branch_head.name %]/shortlog">[% branch_head.name %]</a> /
-                                       [% END %]
-                               [% END %]
+                                       [% END -%]
+                               [% END -%]
                        [%- END %]
                        
                        
           c.uri_for_action(cur_uri, [Repository.name, 'HEAD']);
       END;
 %]</span>
+<span id="heads-uri" class="js-data">[% c.uri_for_action('/repository/heads', [Repository.name]) %]</span>
 
 </body>
 </html>