ping server every 10 minutes
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 7 Jun 2010 12:26:46 +0000 (14:26 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 7 Jun 2010 12:26:46 +0000 (14:26 +0200)
apps/wiki/urls.py
apps/wiki/views.py
redakcja/static/js/wiki/wikiapi.js

index bfc799f..e4e0deb 100644 (file)
@@ -26,4 +26,6 @@ urlpatterns = patterns('wiki.views',
 
     url(r'^(?P<name>[^/]+)$',
         'document_detail', name="wiki_details"),
+    
+    url(r'^ping/$', 'ping', name='ping'),
 )
index 46f0665..c5fd80e 100644 (file)
@@ -256,3 +256,7 @@ def document_publish(request, name):
         return JSONResponse({"result": api.publish_book(document)})
     except wlapi.APICallException, e:
         return JSONServerError({"message": str(e)})
+
+
+def ping(request):
+    return http.HttpResponse('pong')
index 26732bd..13435ea 100644 (file)
@@ -44,6 +44,9 @@
 
                if (vname == "ajax_publish")
                        return base_path + "/" + arguments[1] + "/publish";
+               
+               if (vname == 'ping')
+                   return base_path + '/ping/'
 
                console.log("Couldn't reverse match:", vname);
                return "/404.html";
        };
 
        $.wikiapi.WikiDocument = WikiDocument;
+       
+       
+       var ping = function () {
+        $.ajax({
+            url : reverse('ping'),
+                       timeout: 2000,
+            complete : function () {
+                setTimeout(function () {
+                    ping();
+                }, 600000);
+            }
+        });
+    };
+       
+    ping();
+
 })(jQuery);