determine paths at runtime instead of at compile time tmp-paths-runtime
authorhamidouk
Mon, 30 Jan 2012 12:30:11 +0100
branchtmp-paths-runtime
changeset 742 c0adb6674be0
parent 741 9925bc81b8a8
child 746 a8ab8b74f774
determine paths at runtime instead of at compile time
src/js/site.js.templ
--- a/src/js/site.js.templ	Fri Jan 27 17:27:48 2012 +0100
+++ b/src/js/site.js.templ	Mon Jan 30 12:30:11 2012 +0100
@@ -1,8 +1,44 @@
-/* site.js - all our site-dependent config : player chrome, cdn locations, etc...*/
+/* site.js - all our site-dependent config : player chrome, cdn locations, etc...
+   to implement the metadataplayer on your website, you'll have to define a couple
+   global variables :
+   
+   IriSP__libdir is the directory containing our js libs.
+   IriSP__platform url is the url of teh platform
+   IriSP__player_imgs url from which the player can get the images defined in the css
+   IriSP__jwplayer_swf_path the path to the jwplayer swf.
+   
+   We have to do it this way because it's no longer feasible
+   to configure the mdp at compile-time and then overwrite the
+   defaults.
+*/
+
+if (IriSP.null_or_undefined(IriSP__libdir)) {
+  IriSP.libdir = function() { return "/mdp/src/js/libs/" };
+} else {
+  IriSP.libdir = function() { return IriSP__libdir };
+}
 
-IriSP.libdir = "/mdp/src/js/libs/";
-IriSP.jwplayer_swf_path = "/mdp/test/libs/player.swf";
-IriSP.platform_url = "http://localhost/pf";
+if (IriSP.null_or_undefined(IriSP__platform_url)) {
+  IriSP.platform_url = function() { return "http://localhost/pf"; };
+} else {
+  IriSP.platform_url = function() { return IriSP__platform_url };
+}
+
+if (IriSP.null_or_undefined(IriSP__jwplayer_swf_path)) {
+  IriSP._jwplayer_swf_path = function() { return "/mdp/test/libs/player.swf"; };
+} else {
+  IriSP._jwplayer_swf_path = function() { return IriSP__jwplayer_swf_path };
+}
+
+// the rest of the code doesn't need to know that the path is computed at
+// run time.
+IriSP.jwplayer_swf_path = IriSP._jwplayer_swf_path();
+
+if (IriSP.null_or_undefined(IriSP__player_imgs)) {
+  IriSP._player_imgs = function() { return "/mdp/src/css/imgs"; };
+} else {
+  IriSP._player_imgs = function() { return IriSP__player_imgs };
+}
 
 IriSP.lib = { 
 		jQuery : "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js",
@@ -10,15 +46,15 @@
 		jQueryToolTip : "http://cdn.jquerytools.org/1.2.4/all/jquery.tools.min.js",
 		swfObject : "http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
 		cssjQueryUI : "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/base/jquery-ui.css",
-    popcorn : IriSP.libdir + "popcorn.js",
-    jwplayer : IriSP.libdir + "jwplayer.js",
-    popcornReplacement: IriSP.libdir + "pop.js",
-    raphael: IriSP.libdir + "raphael.js",
-    jquery_sparkline: IriSP.libdir + "jquery.sparkline.js",
-    "popcorn.mediafragment" : IriSP.libdir + "popcorn.mediafragment.js",
-    "popcorn.code" : IriSP.libdir + "popcorn.code.js",
-    "popcorn.jwplayer": IriSP.libdir + "popcorn.jwplayer.js",
-    "popcorn.youtube": IriSP.libdir + "popcorn.youtube.js"    
+    popcorn : IriSP.libdir() + "popcorn.js",
+    jwplayer : IriSP.libdir() + "jwplayer.js",
+    popcornReplacement: IriSP.libdir() + "pop.js",
+    raphael: IriSP.libdir() + "raphael.js",
+    jquery_sparkline: IriSP.libdir() + "jquery.sparkline.js",
+    "popcorn.mediafragment" : IriSP.libdir() + "popcorn.mediafragment.js",
+    "popcorn.code" : IriSP.libdir() + "popcorn.code.js",
+    "popcorn.jwplayer": IriSP.libdir() + "popcorn.jwplayer.js",
+    "popcorn.youtube": IriSP.libdir() + "popcorn.youtube.js"    
 };
 
 //Configuration for the player and utility functions.
@@ -49,11 +85,7 @@
   "createAnnotationWidget" : {
       keywords: ["#faux-raccord", "#mot-clef"],
       polemic_mode: true, /* enable polemics ? */
-      /* polemics - the corresponding class names defined in the css should be for instance :
-         Ldt-createAnnotation-polemic-plusplus for plusplus
-         Ldt-createAnnotation-polemic-equalequal for equalequal, etc.
-      */
-      polemics: {"++" : "positive", "--" : "negative", "==" : "reference", "??" : "question"}, 
+      polemics: {"++" : "positive", "--" : "negative", "==" : "reference", "??" : "question"},  
       cinecast_version: true /* put to false to enable the platform version, true for the festival cinecast one. */
   },
   "SparklineWidget" : {
@@ -66,15 +98,15 @@
       ajax_mode: true, /* use ajax to get information about the annotations.
                          if set to false, only search in the annotations for the
                          current project. */
-      ajax_url: IriSP.platform_url + "ldtplatform/api/ldt/segments/", /* partial
+      ajax_url: IriSP.platform_url() + "ldtplatform/api/ldt/segments/", /* partial
                                                                          url of 
                                                                          where to
                                                                          get the 
                                                                          ajax */
       ajax_granularity: 10000, /* how much ms should we look before and after the
                                  current timecode */
-      
-      project_url: IriSP.platform_url + "/ldtplatform/ldt/front/player/" /* the beginning 
+
+      project_url: IriSP.platform_url() + "/ldtplatform/ldt/front/player/" /* the beginning 
                                                                             of a link to the
                                                                             new front */
   }, 
@@ -82,7 +114,7 @@
 
 IriSP.paths = {
 //  "imgs": "/tweetlive/res/metadataplayer/src/css/imgs"
-  "imgs": "/mdp/src/css/imgs"
+  "imgs": IriSP._player_imgs;
 };
 IriSP.default_templates_vars = {
   "img_dir" : IriSP.paths.imgs