ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject incubator-ponymail git commit: Properly handle list.html?domain where default list does not exist
Date Sat, 29 Oct 2016 10:10:09 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/coffee-and-cake 11d591911 -> c6acf6784


Properly handle list.html?domain where default list does not exist


Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/c6acf678
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/c6acf678
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/c6acf678

Branch: refs/heads/coffee-and-cake
Commit: c6acf6784595a1d4e9343972d95706cb309bc26b
Parents: 11d5919
Author: Sebb <sebb@apache.org>
Authored: Sat Oct 29 11:09:52 2016 +0100
Committer: Sebb <sebb@apache.org>
Committed: Sat Oct 29 11:09:52 2016 +0100

----------------------------------------------------------------------
 site/js/coffee/listview_basiclib.coffee | 21 +++++++++++++++---
 site/js/ponymail-coffee.js              | 33 +++++++++++++++++++++++-----
 2 files changed, 46 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/c6acf678/site/js/coffee/listview_basiclib.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/listview_basiclib.coffee b/site/js/coffee/listview_basiclib.coffee
index 0e6c625..3d466dc 100644
--- a/site/js/coffee/listview_basiclib.coffee
+++ b/site/js/coffee/listview_basiclib.coffee
@@ -63,9 +63,24 @@ listView = (hash, reParse) ->
                 location.href = "./"
                 return
             
-            if ponymail_lists[d] not ponymail_lists[d][l] and ponymail_lists[d][pm_config.default_list]
-                ### Redirect to this list then ... ###
-                location.href = "#{htmlfile}?#{pm_config.default_list}@#{d}"
+            if ponymail_lists[d] and not ponymail_lists[d][l]
+                ### we don't have a matching list, check for the default (or pick busiest)
###
+                l = pm_config.default_list
+                ### does the default exist ? ###
+                if not ponymail_lists[d][l]
+                    ### If not, pick busiest ###
+                    max = -1
+                    for k,v of ponymail_lists[d]
+                        if v > max
+                            max = v
+                            l = k
+
+                ### Redirect to the list ###
+                location.href = "#{htmlfile}?#{l}@#{d}"
+                return
+            else
+                ### No list specified, redirect to front page ###
+                location.href = "./"
                 return
         else
             ### No domain specified, redirect to front page ###

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/c6acf678/site/js/ponymail-coffee.js
----------------------------------------------------------------------
diff --git a/site/js/ponymail-coffee.js b/site/js/ponymail-coffee.js
index 83036dc..150f995 100644
--- a/site/js/ponymail-coffee.js
+++ b/site/js/ponymail-coffee.js
@@ -2044,7 +2044,7 @@ parseURL = function() {
 listView = function(hash, reParse) {
 
   /* Get the HTML filename */
-  var args, d, domain, etc, htmlfile, l, list, newhref, pargs, r, ref, ref1, ref2, since;
+  var args, d, domain, etc, htmlfile, k, l, list, max, newhref, pargs, r, ref, ref1, ref2,
ref3, since, v;
   ref = location.href.split("?"), htmlfile = ref[0], etc = ref[1];
 
   /* Do we need to call the URL parser here? */
@@ -2082,10 +2082,33 @@ listView = function(hash, reParse) {
         location.href = "./";
         return;
       }
-      if (ponymail_lists[d](!ponymail_lists[d][l] && ponymail_lists[d][pm_config.default_list]))
{
+      if (ponymail_lists[d] && !ponymail_lists[d][l]) {
+
+        /* we don't have a matching list, check for the default (or pick busiest) */
+        l = pm_config.default_list;
+
+        /* does the default exist ? */
+        if (!ponymail_lists[d][l]) {
+
+          /* If not, pick busiest */
+          max = -1;
+          ref2 = ponymail_lists[d];
+          for (k in ref2) {
+            v = ref2[k];
+            if (v > max) {
+              max = v;
+              l = k;
+            }
+          }
+        }
 
-        /* Redirect to this list then ... */
-        location.href = htmlfile + "?" + pm_config.default_list + "@" + d;
+        /* Redirect to the list */
+        location.href = htmlfile + "?" + l + "@" + d;
+        return;
+      } else {
+
+        /* No list specified, redirect to front page */
+        location.href = "./";
         return;
       }
     } else {
@@ -2116,7 +2139,7 @@ listView = function(hash, reParse) {
   if (location.href !== newhref) {
     window.history.pushState({}, null, newhref);
   }
-  ref2 = ponymail_list.split("@", 2), list = ref2[0], domain = ref2[1];
+  ref3 = ponymail_list.split("@", 2), list = ref3[0], domain = ref3[1];
 
   /* Request month view from API, send to list view callback */
   pargs = "d=30";


Mime
View raw message