Extend otherProperties with branding settings
authorKostas Papadimitriou <kpap@grnet.gr>
Wed, 22 May 2013 10:26:38 +0000 (13:26 +0300)
committerKostas Papadimitriou <kpap@grnet.gr>
Wed, 22 May 2013 10:30:24 +0000 (13:30 +0300)
otherProperties object defined in the index.html is used from within the GWT
app to access deployment specific configuration options. A new placeholder added
in index.html. The placeholder gets replaced with django template code which
populates otherProperties with all branding settings available during the
python package build.

snf-pithos-webclient/pithos_webclient/views.py
snf-pithos-webclient/setup.py
src/gr/grnet/pithos/web/public/index.html

index be6f349..6b97c5f 100644 (file)
@@ -35,16 +35,23 @@ from django.views.generic.simple import direct_to_template
 
 from pithos_webclient import settings
 from pithos_webclient.version import  __version__
+
 from django.conf import settings as django_settings
 
+from synnefo_branding.utils import get_branding_dict
+
 MEDIA_URL = getattr(settings, "PITHOS_WEB_CLIENT_MEDIA_URL", \
         getattr(django_settings, "MEDIA_URL", "/static/"))
 
+
 def index(request):
+    branding_settings = get_branding_dict("")
     return direct_to_template(request, 'pithos_webclient/index.html', \
             {'settings': settings,
              'MEDIA_URL': MEDIA_URL,
              'CLIENT_VERSION': __version__,
-             'PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE': settings.CLOUDBAR_ACTIVE_SERVICE
+             'PITHOS_UI_CLOUDBAR_ACTIVE_SERVICE':
+                 settings.CLOUDBAR_ACTIVE_SERVICE,
+             'branding_settings': branding_settings
             })
 
index 46eafc1..d6fbb4c 100644 (file)
@@ -250,6 +250,12 @@ def build_gwt(root="../", public_dir="bin/www/gr.grnet.pithos.web.Pithos/"):
             </script>
     """)
 
+    index_data = index_data.replace("{{ EXTEND_OTHER_PROPERTIES }}", """
+        {% for key, value in branding_settings.items %}
+            otherProperties.{{ key }} = "{{ value }}";
+        {% endfor %}
+    """)
+
     ifile = file(index, "w+")
     ifile.write(index_data)
     ifile.close()
index 19836a6..6dbe606 100644 (file)
@@ -63,7 +63,8 @@
                                feedbackUrl: "/feedback",
                                authCookie: "_pithos2_a",
                                version: ""
-                       }
+            };
+            {{ EXTEND_OTHER_PROPERTIES }}
                </script>
     </head>
        <body>