remove hardcoded urls to the astakos api services from the cloudar
authorSofia Papagiannaki <papagian@gmail.com>
Sat, 25 Feb 2012 20:38:56 +0000 (22:38 +0200)
committerSofia Papagiannaki <papagian@gmail.com>
Sat, 25 Feb 2012 20:38:56 +0000 (22:38 +0200)
docs/source/devguide.rst
snf-astakos-app/astakos/im/context_processors.py
snf-astakos-app/astakos/im/static/im/cloudbar/cloudbar.js
snf-astakos-app/astakos/im/templates/im/base.html

index ec96ded..ec99147 100644 (file)
@@ -210,6 +210,14 @@ Uri                  Method     Description
 ``/im/get_menu``     GET        Get cloud bar menu
 ==================== =========  ==================
 
+|
+
+======================  =========================
+Request Parameter Name  Value
+======================  =========================
+location                Location to pass in the next parameter
+======================  =========================
+
 Example reply if request user is not authenticated:
 
 ::
index a4d5178..058cb25 100644 (file)
@@ -34,6 +34,7 @@
 from astakos.im.settings import IM_MODULES, INVITATIONS_ENABLED, IM_STATIC_URL, \
         COOKIE_NAME
 from django.conf import settings
+from django.core.urlresolvers import reverse
 
 def im_modules(request):
     return {'im_modules': IM_MODULES}
@@ -60,5 +61,6 @@ def cloudbar(request):
 
     return {'CLOUDBAR_LOC': CB_LOCATION,
             'CLOUDBAR_COOKIE_NAME': CB_COOKIE_NAME,
-            'ACTIVE_SERVICE': CB_ACTIVE_SERVICE}
-
+            'ACTIVE_SERVICE': CB_ACTIVE_SERVICE,
+            'GET_SERVICES_URL': reverse('astakos.im.api.get_services'),
+            'GET_MENU_URL': reverse('astakos.im.api.get_menu')}
index def84d1..a0983ac 100644 (file)
@@ -37,7 +37,7 @@ $(document).ready(function(){
     var profile = $('<div class="profile"></div>');
     
     // create services links and set the active class to the current service
-    $.getJSON('/im/get_services/', function(data) {
+    $.getJSON(window.GET_SERVICES_URL, function(data) {
             $.each(data, function(i, el){
             var slink = $("<a>");
             if (el.icon) {
@@ -58,7 +58,8 @@ $(document).ready(function(){
     var user = $('<div class="user"></div>');    
     var username = $('<a href="#"></a>');
     var usermenu = $("<ul>");
-    $.getJSON('/im/get_menu/?location='.concat(window.location.toString()), function(data) {
+    var get_menu_url = window.GET_MENU_URL.concat('?location=').concat(window.location.toString());
+    $.getJSON(get_menu_url, function(data) {
         $.each(data, function(i,el) {
             if (i == 0){
                 username.text(el.name);
index 9390b53..af43606 100644 (file)
@@ -61,6 +61,9 @@
     var CLOUDBAR_LOCATION = "{{ CLOUDBAR_LOC }}";
     var CLOUDBAR_COOKIE_NAME = "{{ CLOUDBAR_COOKIE_NAME }}";
     var CLOUDBAR_ACTIVE_SERVICE = '{{ CLOUDBAR_ACTIVE_SERVICE }}';
+    
+    var GET_SERVICES_URL = "{{ GET_SERVICES_URL }}";
+    var GET_MENU_URL = "{{ GET_MENU_URL }}";
 
     $(document).ready(function(){
       $.getScript(CLOUDBAR_LOCATION + 'cloudbar.js');