Sort branches by age
authorJoachim Breitner <mail@joachim-breitner.de>
Thu, 31 Mar 2016 21:06:44 +0000 (23:06 +0200)
committerJoachim Breitner <mail@joachim-breitner.de>
Thu, 31 Mar 2016 21:06:44 +0000 (23:06 +0200)
site/index.html
site/js/gipeda.js

index e8e3a90..a2786ba 100644 (file)
@@ -262,7 +262,7 @@ html {
 <script id="branches"  type="text/x-handlebars-template">
   <h2>Branches</h2>
   <table class="table branch-table">
-   {{#each_unnaturally branches}}
+   {{#each_branch branches}}
      {{#with (lookup ../revisions this)}}
       {{#with this.summary}}
       <tr
@@ -308,7 +308,7 @@ html {
        </td>
       </tr>
      {{/with}}
-   {{/each_unnaturally}}
+   {{/each_branch}}
   </table>
 </script>
 
index 2d7fa3d..b06f6cd 100644 (file)
@@ -250,6 +250,20 @@ Handlebars.registerHelper('each_unnaturally', function(context,options){
     return output;
 });
 
+// Sort by age, then by name
+Handlebars.registerHelper('each_branch', function(context,options){
+    var output = '';
+    if (context) {
+       console.log(context);
+       jQuery.map(context, function (b,i) { return {branch: b, branchName: i}; })
+            .sort(function(a,b) { return a.branch.gitDate - b.branch.gitDate; })
+            .map(function (b,i) {
+                output += options.fn(b.branch, {data: {key: b.branchName, index: i}});
+            });
+    }
+    return output;
+});
+
 // We cache everything
 var jsonSeen = {};
 var jsonFetching = {};