fix ajax loading of concatenated js/ css + prefix concat cache files to ease cache clearing
authorFlorent Cayré <florent.cayre@gmail.com>
Thu, 05 May 2011 12:50:21 +0200
changeset 7309 22403d5c3da4
parent 7304 66fa1b7ac784
child 7314 d3104c697adb
fix ajax loading of concatenated js/ css + prefix concat cache files to ease cache clearing
etwist/server.py
web/data/cubicweb.ajax.js
--- a/etwist/server.py	Wed May 04 12:25:50 2011 +0200
+++ b/etwist/server.py	Thu May 05 12:50:21 2011 +0200
@@ -171,7 +171,7 @@
     def __init__(self, config, paths):
         _, ext = osp.splitext(paths[0])
         # create a unique / predictable filename
-        fname = hashlib.md5(';'.join(paths)).hexdigest() + ext
+        fname = 'cache_concat_' + hashlib.md5(';'.join(paths)).hexdigest() + ext
         filepath = osp.join(config.appdatahome, 'uicache', fname)
         LongTimeExpiringFile.__init__(self, config, filepath)
         self._concat_cached_filepath(filepath, paths)
--- a/web/data/cubicweb.ajax.js	Wed May 04 12:25:50 2011 +0200
+++ b/web/data/cubicweb.ajax.js	Thu May 05 12:50:21 2011 +0200
@@ -95,7 +95,7 @@
     if (!base.endswith('/')) {
         base += '/';
     }
-    var modconcat_rgx = new RegExp('(' + base + 'data/([a-z0-9]+/))?\\?\\?(.+)');
+    var modconcat_rgx = new RegExp('(' + base + 'data/([a-z0-9]+/)?)\\?\\?(.+)');
     return modconcat_rgx.exec(url);
 }
 
@@ -112,7 +112,7 @@
     if (groups == null) {
         resources.push(src);
     } else {
-        var dataurl = groups[0];
+        var dataurl = groups[1];
         $.each(cw.utils.lastOf(groups).split(','),
                function() {
                    resources.push(dataurl + this);
@@ -150,12 +150,10 @@
                     // server-response event, since we loose control on when the
                     // script is loaded (jQuery load it immediatly).
                     loaded.push(resource);
-                    jQuery(srcnode).appendTo($head);
                 }
             });
-        } else {
-            jQuery(srcnode).appendTo($head);
         }
+	jQuery(srcnode).appendTo($head);
     });
     $node.find(jqtagfilter).remove();
 }