You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2016/09/03 07:45:56 UTC

[08/12] incubator-ponymail git commit: more work on the listview base functions

more work on the listview base functions

set up args properly, default to 30d if no month specified
start calling the listview class (TBD)


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

Branch: refs/heads/coffee-and-cake
Commit: 2ee3d35385ab3bd8f37bf0e29f558a4a12e1f86f
Parents: b7fe4de
Author: Daniel Gruno <hu...@apache.org>
Authored: Sat Sep 3 09:41:53 2016 +0200
Committer: Daniel Gruno <hu...@apache.org>
Committed: Sat Sep 3 09:41:53 2016 +0200

----------------------------------------------------------------------
 site/js/coffee/listview.coffee | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/2ee3d353/site/js/coffee/listview.coffee
----------------------------------------------------------------------
diff --git a/site/js/coffee/listview.coffee b/site/js/coffee/listview.coffee
index fd0017a..5ace897 100644
--- a/site/js/coffee/listview.coffee
+++ b/site/js/coffee/listview.coffee
@@ -26,8 +26,9 @@ window.onpopstate = (event) ->
 parseURL = () ->
     [list, month, query] = window.location.search.substr(1).split(":", 3)
     ponymail_list = list
-    ponymail_month = month
-    ponymail_query = query
+    ponymail_month = month||""
+    ponymail_query = query||""
+    
     
 
 listView = (hash, reParse) ->
@@ -48,17 +49,20 @@ listView = (hash, reParse) ->
             ponymail_query = hash.query
     
     ### First, check that we have a list to view! ###
-    if not (ponymail_list and ponymail_list.match(/.+@.+/))
+    if not (ponymail_list and ponymail_list.match(/.+?@.+/))
         ### Do we at least have a domain part? ###
         if ponymail_list and ponymail_list.match(/.+?\..+/)
             ### Check if there's a $default list in this domain ###
-            d = ponymail_list
+            [l, d] = ponymail_list.split("@", 2)
+            if not d
+                d = l
+                
             ### Do we have this domain listed? If not, redirect to front page ###
-            if not ponymail_domains[d]
+            if not d or not ponymail_lists[d]
                 location.href = "./"
                 return
             
-            if ponymail_domains[d] and ponymail_domains[d][pm_config.default_list]
+            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}"
                 return
@@ -77,13 +81,28 @@ listView = (hash, reParse) ->
         args += ":" + ponymail_query
         
     ### Push a new history state using new args ###
-    window.history.pushState({}, "", "#{htmlfile}?#{args}")
+    newhref = "#{htmlfile}?#{args}"
+    if location.href != newhref
+        window.history.pushState({}, newhref)
     
+    [list, domain] = ponymail_list.split("@", 2)
     ### Request month view from API, send to list view callback ###
+    pargs = "d=30"
+    if ponymail_month and ponymail_month.length > 0
+        pargs = "s=#{ponymail_month}&e=#{ponymail_month}"
     r = new HTTPRequest(
-        "api/stats.lua?list=#{ponymail_list}&d=#{ponymail_month}",
+        "api/stats.lua?list=#{list}&domain=#{domain}&#{pargs}",
         {
             callback: renderListView
         }
         )
+    
+renderListView = (json, state) ->
+    
+    ### Start by adding the calendar ###
+    if json.firstYear and json.lastYear
+        cal = new Calendar(json.firstYear, json.lastYear)
+        get('calendar').empty().inject(cal)
+        
+    lv = new BasicListView(json)
     
\ No newline at end of file