Pass base url as requirejs config rather than globally
Pass base url as requirejs config rather than globally

--- a/js/modules/geturl.js
+++ b/js/modules/geturl.js
@@ -9,10 +9,10 @@
  * @subpackage Javascript
  */
 
-define(
-	function() {
+define(['module'],
+	function(module) {
 		return function() {
-			return GitPHP.BaseUrl;
+			return module.config().baseurl;
 		}
 	}
 );

--- a/templates/jsconst.tpl
+++ b/templates/jsconst.tpl
@@ -19,7 +19,6 @@
 	NoMatchesFound: '{t escape=no}No matches found for "%1"{/t}'
 {rdelim};
 
-GitPHP.BaseUrl = '{$baseurl}/';
 {if $project}
 GitPHP.Project = '{$project->GetProject()}';
 {/if}

--- a/templates/main.tpl
+++ b/templates/main.tpl
@@ -38,7 +38,7 @@
     {include file='jsconst.tpl'}
     <script type="text/javascript">
     var require = {ldelim}
-    	baseUrl: GitPHP.BaseUrl + 'js',
+    	baseUrl: '{$baseurl}/js',
 	paths: {ldelim}
 		jquery: [
 			{if $googlejs}
@@ -52,6 +52,9 @@
 	config: {ldelim}
 		'modules/snapshotformats': {ldelim}
 			formats: {ldelim}{foreach from=$snapshotformats key=format item=extension name=formats}"{$format}": "{$extension}"{if !$smarty.foreach.formats.last},{/if}{/foreach}{rdelim}
+		{rdelim},
+		'modules/geturl': {ldelim}
+			baseurl: '{$baseurl}/'
 		{rdelim}
 	{rdelim}
     {rdelim};

comments