Access static resources with absolute paths
Access static resources with absolute paths

--- a/include/controller/ControllerBase.class.php
+++ b/include/controller/ControllerBase.class.php
@@ -510,6 +510,13 @@
 		$this->tpl->assign('scripturl', $scripturl);
 		$this->tpl->assign('fullscripturl', $fullscripturl);
 
+		$baseurl = $scripturl;
+		if (substr_compare($baseurl, '.php', -4) === 0) {
+			$baseurl = dirname($baseurl);
+		}
+		$baseurl = rtrim($baseurl, "\\");
+		$this->tpl->assign('baseurl', $baseurl);
+		
 		if ($this->config->GetValue('abbreviateurl')) {
 			$this->tpl->assign('abbreviateurl', true);
 		}

--- a/js/modules/geturl.js
+++ b/js/modules/geturl.js
@@ -12,8 +12,7 @@
 define(
 	function() {
 		return function() {
-			var url = window.location.href.match(/^([^\?]+\/)/);
-			return url ? url[1] : null;
+			return GitPHP.BaseUrl;
 		}
 	}
 );

--- a/locale/gitphp.pot
+++ b/locale/gitphp.pot
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: GitPHP 0.2.7\n"
 "Report-Msgid-Bugs-To: xiphux@gmail.com\n"
-"POT-Creation-Date: 2012-07-01 11:07-0500\n"
+"POT-Creation-Date: 2012-07-29 00:24-0500\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -26,7 +26,7 @@
 #: templates/treelist.tpl
 #: templates/searchfiles.tpl
 #: templates/history.tpl
-#: include/controller/Controller_Blob.class.php:44
+#: include/controller/Controller_Blob.class.php:55
 msgid "blob"
 msgstr ""
 
@@ -35,7 +35,7 @@
 #: templates/treelist.tpl
 #: templates/searchfiles.tpl
 #: templates/blob.tpl
-#: include/controller/Controller_History.class.php:42
+#: include/controller/Controller_History.class.php:53
 msgid "history"
 msgstr ""
 
@@ -49,7 +49,7 @@
 #: templates/log.tpl
 #: templates/projectlist.tpl
 #: templates/shortloglist.tpl
-#: include/controller/Controller_Tree.class.php:45
+#: include/controller/Controller_Tree.class.php:61
 msgid "tree"
 msgstr ""
 
@@ -61,7 +61,7 @@
 #: templates/treelist.tpl
 #: templates/projectlist.tpl
 #: templates/shortloglist.tpl
-#: include/controller/Controller_Snapshot.class.php:76
+#: include/controller/Controller_Snapshot.class.php:110
 msgid "snapshot"
 msgstr ""
 
@@ -80,7 +80,7 @@
 #: templates/history.tpl
 #: templates/shortloglist.tpl
 #: templates/projectbase.tpl
-#: include/controller/Controller_Commit.class.php:45
+#: include/controller/Controller_Commit.class.php:59
 msgid "commit"
 msgstr ""
 
@@ -88,7 +88,7 @@
 #: templates/tag.tpl
 #: templates/tagtip.tpl
 #: templates/taglist.tpl
-#: include/controller/Controller_Tag.class.php:45
+#: include/controller/Controller_Tag.class.php:56
 msgid "tag"
 msgstr ""
 
@@ -273,7 +273,7 @@
 #: templates/taglist.tpl
 #: templates/title.tpl
 #: templates/projectlist.tpl
-#: include/controller/Controller_Log.class.php:46
+#: include/controller/Controller_Log.class.php:60
 msgid "shortlog"
 msgstr ""
 
@@ -282,7 +282,7 @@
 #: templates/nav.tpl
 #: templates/taglist.tpl
 #: templates/projectlist.tpl
-#: include/controller/Controller_Log.class.php:51
+#: include/controller/Controller_Log.class.php:65
 msgid "log"
 msgstr ""
 
@@ -296,8 +296,8 @@
 # Link back to the list of projects
 #: templates/main.tpl
 #: templates/projectbase.tpl
-#: include/controller/ControllerBase.class.php:446
-#: include/controller/Controller_ProjectList.class.php:72
+#: include/controller/ControllerBase.class.php:467
+#: include/controller/Controller_ProjectList.class.php:76
 msgid "projects"
 msgstr ""
 
@@ -309,7 +309,7 @@
 
 # Used as title for search page, and also is the label for the search box
 #: templates/projectbase.tpl
-#: include/controller/Controller_Search.class.php:85
+#: include/controller/Controller_Search.class.php:108
 msgid "search"
 msgstr ""
 
@@ -421,12 +421,12 @@
 
 # Used as link to and title for page displaying blame info (who last touched what line) in a file
 #: templates/blob.tpl
-#: include/controller/Controller_Blame.class.php:45
+#: include/controller/Controller_Blame.class.php:59
 msgid "blame"
 msgstr ""
 
 # Error message when user tries to do an action that requires a project but a project isn't specified
-#: include/controller/Controller_Message.class.php:155
+#: include/controller/Controller_Message.class.php:140
 msgid "Project is required"
 msgstr ""
 
@@ -443,35 +443,35 @@
 
 # Error message when user tries to access a project that doesn't exist
 # %1$s: the project the user tried to access
-#: include/controller/Controller_Message.class.php:149
+#: include/controller/Controller_Message.class.php:134
 #, php-format
 msgid "Invalid project %1$s"
 msgstr ""
 
 # Used as the title for the opml controller
 # OPML is a standard XML outline format
-#: include/controller/Controller_ProjectList.class.php:62
+#: include/controller/Controller_ProjectList.class.php:66
 msgid "opml"
 msgstr ""
 
 # Used as the title of the project index controller
-#: include/controller/Controller_ProjectList.class.php:67
+#: include/controller/Controller_ProjectList.class.php:71
 msgid "project index"
 msgstr ""
 
 # Error message when a user tries to search but searching has been disabled in the config
-#: include/controller/Controller_Message.class.php:166
+#: include/controller/Controller_Message.class.php:151
 msgid "Search has been disabled"
 msgstr ""
 
 # Error message when a user tries to do a file search but searching files has been disabled in the config
-#: include/controller/Controller_Message.class.php:162
+#: include/controller/Controller_Message.class.php:147
 msgid "File search has been disabled"
 msgstr ""
 
 # Error message when a user's search query is too short
 # %1$d: the minimum number of characters
-#: include/controller/Controller_Message.class.php:179
+#: include/controller/Controller_Message.class.php:164
 #, php-format
 msgid "You must enter search text of at least %1$d character"
 msgid_plural "You must enter search text of at least %1$d characters"
@@ -479,7 +479,7 @@
 msgstr[1] ""
 
 # Error message when the user enters an unsupported search type
-#: include/controller/Controller_Message.class.php:173
+#: include/controller/Controller_Message.class.php:158
 msgid "Invalid search type"
 msgstr ""
 
@@ -508,49 +508,49 @@
 
 # Error message when user specifies a path for a project root or project, but the path given isn't a directory
 # %1$s: the path the user specified
-#: include/controller/Controller_Message.class.php:209
+#: include/controller/Controller_Message.class.php:194
 #, php-format
 msgid "%1$s is not a directory"
 msgstr ""
 
 # Error message when a path specified in the config is not a git repository
 # %1$s: the specified path
-#: include/controller/Controller_Message.class.php:221
+#: include/controller/Controller_Message.class.php:206
 #, php-format
 msgid "%1$s is not a git repository"
 msgstr ""
 
 # Error message when a path specified is using '..' to break out of the project root (a hack attempt)
 # %1$s: The specified path
-#: include/controller/Controller_Message.class.php:233
+#: include/controller/Controller_Message.class.php:218
 #, php-format
 msgid "%1$s is attempting directory traversal"
 msgstr ""
 
 # Error message when a path specified is outside of the project root
 # %1$s: The specified path
-#: include/controller/Controller_Message.class.php:239
+#: include/controller/Controller_Message.class.php:224
 #, php-format
 msgid "%1$s is outside of the projectroot"
 msgstr ""
 
 # Error message when user tries to specify a file with a list of the projects, but it isn't a file
 # %1$s: the path the user specified
-#: include/controller/Controller_Message.class.php:215
+#: include/controller/Controller_Message.class.php:200
 #, php-format
 msgid "%1$s is not a file"
 msgstr ""
 
 # Error message when user tries to specify a file with a list of the projects, but the system can't read the file
 # %1$s: the file the user specified
-#: include/controller/Controller_Message.class.php:227
+#: include/controller/Controller_Message.class.php:212
 #, php-format
 msgid "Failed to open project list file %1$s"
 msgstr ""
 
 # Error message when a hash specified in a URL isn't a valid git hash
 # %1$s: the hash entered
-#: include/controller/Controller_Message.class.php:185
+#: include/controller/Controller_Message.class.php:170
 #, php-format
 msgid "Invalid hash %1$s"
 msgstr ""
@@ -625,7 +625,7 @@
 
 # Error message when user hasn't defined a project root in the config
 # "projectroot" refers to a root directory where the user's git projects are stored
-#: include/controller/Controller_Message.class.php:197
+#: include/controller/Controller_Message.class.php:182
 msgid "A projectroot must be set in the config"
 msgstr ""
 
@@ -707,7 +707,7 @@
 
 # Used as an error message when memcache is turned
 # on without the appropriate PHP extension installed
-#: include/controller/Controller_Message.class.php:203
+#: include/controller/Controller_Message.class.php:188
 msgid ""
 "The Memcached or Memcache PHP extension is required for Memcache support"
 msgstr ""
@@ -727,7 +727,7 @@
 # Error message displayed when the git executable isn't found or doesn't work
 # %1$s: the git executable the system is trying to run
 # %2$s: the config value the user needs to set to specify the correct path
-#: include/controller/Controller_Message.class.php:191
+#: include/controller/Controller_Message.class.php:176
 #, php-format
 msgid ""
 "Could not run the git executable \"%1$s\".  You may need to set the \"%2$s\" "
@@ -768,8 +768,32 @@
 
 # Message when the config file failed to load
 # %1$s: the config file that we tried to load
-#: include/controller/Controller_Message.class.php:245
+#: include/controller/Controller_Message.class.php:230
 #, php-format
 msgid "Could not load config file %1$s"
 msgstr ""
 
+# Used as a link to and title of the graph page
+#: templates/nav.tpl
+#: include/controller/Controller_Graph.class.php:56
+msgid "graph"
+msgstr ""
+
+# Name of the commit activity graph
+#: templates/graph.tpl
+msgid "commit activity"
+msgstr ""
+
+# Name of the language distribution graph
+#: templates/graph.tpl
+msgid "language distribution"
+msgstr ""
+
+# Message displayed when an abbreviated hash is given
+# but it is ambiguous because there are multiple hashes
+# in the system with this abbreviation
+#: include/controller/Controller_Message.class.php:236
+#, php-format
+msgid "Ambiguous abbreviated hash %1$s"
+msgstr ""
+

--- a/templates/jsconst.tpl
+++ b/templates/jsconst.tpl
@@ -22,6 +22,8 @@
 GitPHP.Snapshot = {ldelim}
 	Formats: {ldelim}{foreach from=$snapshotformats key=format item=extension name=formats}"{$format}": "{$extension}"{if !$smarty.foreach.formats.last},{/if}{/foreach}{rdelim}
 {rdelim}
+
+GitPHP.BaseUrl = '{$baseurl}/';
 		
 </script>
 

--- a/templates/main.tpl
+++ b/templates/main.tpl
@@ -21,21 +21,21 @@
     {block name=feeds}
     {/block}
     {if file_exists('css/gitphp.min.css')}
-    <link rel="stylesheet" href="css/gitphp.min.css" type="text/css" />
+    <link rel="stylesheet" href="{$baseurl}/css/gitphp.min.css" type="text/css" />
     {else}
-    <link rel="stylesheet" href="css/gitphp.css" type="text/css" />
+    <link rel="stylesheet" href="{$baseurl}/css/gitphp.css" type="text/css" />
     {/if}
     {if file_exists("css/$stylesheet.min.css")}
-    <link rel="stylesheet" href="css/{$stylesheet}.min.css" type="text/css" />
+    <link rel="stylesheet" href="{$baseurl}/css/{$stylesheet}.min.css" type="text/css" />
     {else}
-    <link rel="stylesheet" href="css/{$stylesheet}.css" type="text/css" />
+    <link rel="stylesheet" href="{$baseurl}/css/{$stylesheet}.css" type="text/css" />
     {/if}
-    <link rel="stylesheet" href="css/ext/jquery.qtip.css" type="text/css" />
+    <link rel="stylesheet" href="{$baseurl}/css/ext/jquery.qtip.css" type="text/css" />
     {block name=css}
     {/block}
     {if $javascript}
     {block name=javascript}
-    <script src="js/ext/require.js"></script>
+    <script src="{$baseurl}/js/ext/require.js"></script>
     {include file='jsconst.tpl'}
     <script type="text/javascript">
     var GitPHPJSPaths = {ldelim}
@@ -57,7 +57,7 @@
     {/block}
 
     require({ldelim}
-    	baseUrl: 'js',
+    	baseUrl: '{$baseurl}/js',
 	paths: GitPHPJSPaths,
 	priority: ['jquery']
     {rdelim}, GitPHPJSModules);
@@ -68,7 +68,7 @@
   <body>
     <div class="page_header">
       <a href="http://git-scm.com" title="git homepage" rel="nofollow">
-        <img src="images/git-logo.png" width="72" height="27" alt="git" class="logo" />
+        <img src="{$baseurl}/images/git-logo.png" width="72" height="27" alt="git" class="logo" />
       </a>
       {if $supportedlocales}
       <div class="lang_select">
@@ -91,7 +91,7 @@
       </div>
       {/if}
       {block name=header}
-      <a href="index.php">{if $homelink}{$homelink}{else}{t}projects{/t}{/if}</a> /
+      <a href="{geturl}">{if $homelink}{$homelink}{else}{t}projects{/t}{/if}</a> /
       {/block}
     </div>
 {block name=main}

--- a/templates/projectbase.tpl
+++ b/templates/projectbase.tpl
@@ -26,7 +26,7 @@
      / {$actionlocal}
   {/if}
   {if $enablesearch}
-    <form method="get" action="index.php" enctype="application/x-www-form-urlencoded">
+    <form method="get" action="{geturl}" enctype="application/x-www-form-urlencoded">
       <div class="search">
         <input type="hidden" name="p" value="{$project->GetProject()}" />
         <input type="hidden" name="a" value="search" />

--- a/templates/projectlist.tpl
+++ b/templates/projectlist.tpl
@@ -30,8 +30,8 @@
 </div>
 
 <div class="projectSearch">
-<form method="get" action="index.php" id="projectSearchForm" enctype="application/x-www-form-urlencoded">
-{t}Search projects{/t}: <input type="text" name="s" class="projectSearchBox" {if $search}value="{$search}"{/if} /> <a href="index.php" class="clearSearch" {if !$search}style="display: none;"{/if}>X</a> {if $javascript}<img src="images/search-loader.gif" class="searchSpinner" style="display: none;" alt="{t}Loading…{/t}" />{/if}
+<form method="get" action="{geturl}" id="projectSearchForm" enctype="application/x-www-form-urlencoded">
+{t}Search projects{/t}: <input type="text" name="s" class="projectSearchBox" {if $search}value="{$search}"{/if} /> <a href="{geturl}" class="clearSearch" {if !$search}style="display: none;"{/if}>X</a> {if $javascript}<img src="images/search-loader.gif" class="searchSpinner" style="display: none;" alt="{t}Loading…{/t}" />{/if}
 </form>
 </div>
 

comments