Also fix displayed commit for renamed files
Also fix displayed commit for renamed files

--- a/config/projects.conf.php.example
+++ b/config/projects.conf.php.example
@@ -93,6 +93,8 @@
  *	     Compatibility mode relies more on the git executable for loading
  *	     data, at the expense of performance.  Use if you are having
  *	     trouble loading data for this project.
+ *
+ * 'website': the website url for the project.
  */
 //$git_projects_settings['php/gitphp.git'] = array(
 //	'category' => 'PHP',
@@ -102,7 +104,8 @@
 //	'pushurl' => '',
 //	'bugpattern' => '/#([0-9]+)/',
 //	'bugurl' => 'http://mantis.xiphux.com/view.php?id=${1}',
-//	'compat' => false
+//	'compat' => false,
+//	'website' => 'http://xiphux.com/programming/gitphp/'
 //);
 //$git_projects_settings['gentoo.git'] = array(
 //	'description' => 'Gentoo portage overlay',

--- a/css/gitphpskin.css
+++ b/css/gitphpskin.css
@@ -117,6 +117,16 @@
 	float: left; 
 	color: #555555;
 	font-style: italic; 
+}
+
+div.page_footer_text a {
+	color: #555555;
+	font-style: italic;
+	text-decoration: none;
+}
+
+div.page_footer_text a:hover {
+	text-decoration: underline;
 }
 
 

--- a/include/controller/Controller_Blob.class.php
+++ b/include/controller/Controller_Blob.class.php
@@ -168,7 +168,7 @@
 		}
 
 		$blob = $this->project->GetBlob($this->params['hash']);
-		if ($this->params['file'])
+		if (!empty($this->params['file']))
 			$blob->SetPath($this->params['file']);
 		$blob->SetCommit($commit);
 		$this->tpl->assign('blob', $blob);

--- a/include/git/Commit.class.php
+++ b/include/git/Commit.class.php
@@ -658,8 +658,10 @@
 		$projectRefs = $this->GetProject()->GetRefs('tags');
 
 		foreach ($projectRefs as $ref) {
-			if ($ref->GetCommit()->GetHash() === $this->hash) {
-				$tags[] = $ref;
+			if (($ref->GetType() == 'tag') || ($ref->GetType() == 'commit')) {
+				if ($ref->GetCommit()->GetHash() === $this->hash) {
+					$tags[] = $ref;
+				}
 			}
 		}
 

--- a/include/git/Project.class.php
+++ b/include/git/Project.class.php
@@ -219,6 +219,15 @@
 /*}}}2*/
 
 	/**
+	 * website
+	 *
+	 * Stores the website url internally
+	 *
+	 * @access protected
+	 */
+	protected $website = null;
+
+	/**
 	 * commitCache
 	 *
 	 * Caches fetched commit objects in case of
@@ -724,6 +733,36 @@
 	public function SetBugPattern($bPat)
 	{
 		$this->bugPattern = $bPat;
+	}
+
+/*}}}2*/
+
+/* website accessors {{{2*/
+
+	/**
+	 * GetWebsite
+	 *
+	 * Gets the website for this repository, if specified
+	 *
+	 * @access public
+	 * @return string website
+	 */
+	public function GetWebsite()
+	{
+		return $this->website;
+	}
+
+	/**
+	 * SetWebsite
+	 *
+	 * Sets the website for this repository
+	 *
+	 * @access public
+	 * @param string $site website
+	 */
+	public function SetWebsite($site)
+	{
+		$this->website = $site;
 	}
 
 /*}}}2*/

--- a/include/git/ProjectListBase.class.php
+++ b/include/git/ProjectListBase.class.php
@@ -298,6 +298,9 @@
 		if (isset($projData['compat'])) {
 			$projectObj->SetCompat($projData['compat']);
 		}
+		if (isset($projData['website']) && is_string($projData['website'])) {
+			$projectObj->SetWebsite($projData['website']);
+		}
 	}
 
 	/**

--- a/include/git/ProjectListDirectory.class.php
+++ b/include/git/ProjectListDirectory.class.php
@@ -91,7 +91,7 @@
 	 */
 	private function RecurseDir($dir)
 	{
-		if (!is_dir($dir))
+		if (!(is_dir($dir) && is_readable($dir)))
 			return;
 
 		GitPHP_Log::GetInstance()->Log(sprintf('Searching directory %1$s', $dir));

--- a/include/git/Tag.class.php
+++ b/include/git/Tag.class.php
@@ -279,6 +279,22 @@
 			$this->ReadData();
 
 		return $this->taggerTimezone;
+	}
+
+	/**
+	 * GetAge
+	 *
+	 * Gets the tag age
+	 *
+	 * @access public
+	 * @return string age
+	 */
+	public function GetAge()
+	{
+		if (!$this->dataRead)
+			$this->ReadData();
+
+		return time() - $this->taggerEpoch;
 	}
 
 	/**
@@ -431,6 +447,9 @@
 					}
 				}
 				break;
+			case 'blob':
+				$this->object = $this->GetProject()->GetBlob($objectHash);
+				break;
 		}
 	}
 
@@ -509,6 +528,9 @@
 					}
 				}
 				break;
+			case 'blob':
+				$this->object = $this->GetProject()->GetBlob($objectHash);
+				break;
 		}
 	}
 
@@ -560,6 +582,8 @@
 			$this->object = $this->object->GetHash();
 		} else if ($this->type == 'tag') {
 			$this->object = $this->object->GetName();
+		} else if ($this->type == 'blob') {
+			$this->object = $this->object->GetHash();
 		}
 
 		$this->objectReferenced = true;
@@ -584,6 +608,8 @@
 			$this->object = $this->GetProject()->GetCommit($this->object);
 		} else if ($this->type == 'tag') {
 			$this->object = $this->GetProject()->GetTag($this->object);
+		} else if ($this->type == 'blob') {
+			$this->object = $this->GetProject()->GetBlob($this->object);
 		}
 
 		$this->objectReferenced = false;

--- a/locale/gitphp.pot
+++ b/locale/gitphp.pot
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: GitPHP 0.2.4\n"
 "Report-Msgid-Bugs-To: xiphux@gmail.com\n"
-"POT-Creation-Date: 2011-07-22 23:42-0500\n"
+"POT-Creation-Date: 2011-08-25 20:54-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"
@@ -19,8 +19,10 @@
 "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
 
 # Used as link to and title for page displaying a blob, which is what git calls a single file
+#: templates/tag.tpl
 #: templates/blobdiff.tpl
 #: templates/commit.tpl
+#: templates/taglist.tpl
 #: templates/treelist.tpl
 #: templates/searchfiles.tpl
 #: templates/history.tpl
@@ -59,7 +61,7 @@
 #: templates/treelist.tpl
 #: templates/projectlist.tpl
 #: templates/shortloglist.tpl
-#: include/controller/Controller_Snapshot.class.php:85
+#: include/controller/Controller_Snapshot.class.php:92
 msgid "snapshot"
 msgstr ""
 
@@ -428,7 +430,7 @@
 #: include/controller/Controller_Commit.class.php:34
 #: include/controller/Controller_Log.class.php:34
 #: include/controller/Controller_Blame.class.php:34
-#: include/controller/Controller_Snapshot.class.php:43
+#: include/controller/Controller_Snapshot.class.php:49
 #: include/controller/Controller_Blob.class.php:34
 #: include/controller/Controller_Tag.class.php:34
 #: include/controller/Controller_Tags.class.php:34
@@ -454,6 +456,7 @@
 
 # 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_Snapshot.class.php:44
 #: include/controller/ControllerBase.class.php:93
 #, php-format
 msgid "Invalid project %1$s"
@@ -519,28 +522,28 @@
 # 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/git/ProjectListDirectory.class.php:47
-#: include/git/Project.class.php:250
+#: include/git/Project.class.php:326
 #, 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/git/Project.class.php:254
+#: include/git/Project.class.php:330
 #, 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/git/Project.class.php:258
+#: include/git/Project.class.php:334
 #, 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/git/Project.class.php:264
+#: include/git/Project.class.php:340
 #, php-format
 msgid "%1$s is outside of the projectroot"
 msgstr ""
@@ -573,6 +576,7 @@
 
 # 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/git/ProjectListScmManager.class.php:37
 #: include/git/ProjectListFile.class.php:38
 #, php-format
 msgid "%1$s is not a file"
@@ -662,7 +666,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
-#: index.php:123
+#: index.php:125
 msgid "A projectroot must be set in the config"
 msgstr ""
 
@@ -763,7 +767,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
-#: index.php:131
+#: index.php:133
 #, php-format
 msgid ""
 "Could not run the git executable \"%1$s\".  You may need to set the \"%2$s\" "
@@ -773,7 +777,7 @@
 # Error message displayed when the diff executable isn't found or doesn't work
 # %1$s: the diff executable the system is trying to run
 # %2$s: the config value the user needs to set to specify the correct path
-#: index.php:136
+#: index.php:138
 #, php-format
 msgid ""
 "Could not run the diff executable \"%1$s\".  You may need to set the \"%2$s"
@@ -795,3 +799,8 @@
 msgid "Binary files %1$s and %2$s differ"
 msgstr ""
 
+# Used to label the url of the website of the project
+#: templates/project.tpl
+msgid "website"
+msgstr ""
+

--- a/templates/blob.tpl
+++ b/templates/blob.tpl
@@ -16,8 +16,10 @@
    {else}
      {t}HEAD{/t}
    {/if}
+   {if $blob->GetPath()}
     | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=history&amp;h={$commit->GetHash()}&amp;f={$blob->GetPath()}">{t}history{/t}</a>
    {if !$datatag} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blame&amp;h={$blob->GetHash()}&amp;f={$blob->GetPath()}&amp;hb={$commit->GetHash()}" id="blameLink">{t}blame{/t}</a>{/if}
+   {/if}
    <br />
  </div>
 

--- a/templates/commit.tpl
+++ b/templates/commit.tpl
@@ -125,7 +125,7 @@
        {elseif $diffline->GetStatus() == "M" || $diffline->GetStatus() == "T"}
          <td>
            {if $diffline->GetToHash() != $diffline->GetFromHash()}
-             <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff&amp;h={$diffline->GetToHash()}&amp;hp={$diffline->GetFromHash()}&amp;hb={$par->GetHash()}&amp;f={$diffline->GetToFile()}" class="list">
+             <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff&amp;h={$diffline->GetToHash()}&amp;hp={$diffline->GetFromHash()}&amp;hb={$commit->GetHash()}&amp;f={$diffline->GetToFile()}" class="list">
 	       {$diffline->GetToFile()}
 	     </a>
            {else}
@@ -178,7 +178,7 @@
          <td class="link">
            <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob&amp;h={$diffline->GetToHash()}&amp;hb={$commit->GetHash()}&amp;f={$diffline->GetToFile()}">{t}blob{/t}</a>
 	   {if $diffline->GetToHash() != $diffline->GetFromHash()}
-	     | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff&amp;h={$diffline->GetToHash()}&amp;hp={$diffline->GetFromHash()}&amp;hb={$par->GetHash()}&amp;f={$diffline->GetToFile()}">{t}diff{/t}</a>
+	     | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff&amp;h={$diffline->GetToHash()}&amp;hp={$diffline->GetFromHash()}&amp;hb={$commit->GetHash()}&amp;f={$diffline->GetToFile()}">{t}diff{/t}</a>
 	   {/if}
 	     | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=history&amp;h={$commit->GetHash()}&amp;f={$diffline->GetFromFile()}">{t}history{/t}</a>
              | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob_plain&amp;h={$diffline->GetToHash()}&amp;f={$diffline->GetToFile()}">{t}plain{/t}</a>
@@ -207,7 +207,7 @@
          <td class="link">
 	   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob&amp;h={$diffline->GetToHash()}&amp;hb={$commit->GetHash()}&amp;f={$diffline->GetToFile()}">{t}blob{/t}</a>
 	   {if $diffline->GetToHash() != $diffline->GetFromHash()}
-	     | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff&amp;h={$diffline->GetToHash()}&amp;hp={$diffline->GetFromHash()}&amp;hb={$par->GetHash()}&amp;f={$diffline->GetToFile()}">{t}diff{/t}</a>
+	     | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff&amp;h={$diffline->GetToHash()}&amp;hp={$diffline->GetFromHash()}&amp;hb={$commit->GetHash()}&amp;f={$diffline->GetToFile()}">{t}diff{/t}</a>
 	   {/if}
 	    | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob_plain&amp;h={$diffline->GetToHash()}&amp;f={$diffline->GetToFile()}">{t}plain{/t}</a>
 	 </td>

--- a/templates/footer.tpl
+++ b/templates/footer.tpl
@@ -7,7 +7,13 @@
  *}
     <div class="page_footer">
       {if $project}
-        <div class="page_footer_text">{$project->GetDescription()}</div>
+        <div class="page_footer_text">
+	{if $project->GetWebsite()}
+	<a href="{$project->GetWebsite()}">{$project->GetDescription()}</a>
+	{else}
+	{$project->GetDescription()}
+	{/if}
+	</div>
         <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=rss" class="rss_logo">{t}RSS{/t}</a>
         <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=atom" class="rss_logo">{t}Atom{/t}</a>
       {else}

--- a/templates/project.tpl
+++ b/templates/project.tpl
@@ -26,6 +26,9 @@
    {/if}
    {if $project->GetPushUrl()}
      <tr><td>{t}push url{/t}</td><td><a href="{$project->GetPushUrl()}">{$project->GetPushUrl()}</a></td></tr>
+   {/if}
+   {if $project->GetWebsite()}
+     <tr><td>{t}website{/t}</td><td><a href="{$project->GetWebsite()}">{$project->GetWebsite()}</a></td></tr>
    {/if}
  </table>
 

--- a/templates/tag.tpl
+++ b/templates/tag.tpl
@@ -16,7 +16,11 @@
  {assign var=object value=$tag->GetObject()}
  {assign var=objtype value=$tag->GetType()}
  <div class="title">
+   {if $objtype == 'blob'}
+   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob&amp;h={$object->GetHash()}" class="title">{$tag->GetName()}</a>
+   {else}
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=commit&amp;h={$object->GetHash()}" class="title">{$tag->GetName()}</a>
+   {/if}
  </div>
  <div class="title_text">
    <table cellspacing="0">
@@ -28,6 +32,9 @@
        {elseif $objtype == 'tag'}
          <td class="monospace"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=tag&amp;h={$object->GetName()}" class="list">{$object->GetHash()}</a></td>
          <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=tag&amp;h={$object->GetName()}">{t}tag{/t}</a></td>
+       {elseif $objtype == 'blob'}
+         <td class="monospace"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob&amp;h={$object->GetHash()}" class="list">{$object->GetHash()}</a></td>
+         <td class="link"><a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob&amp;h={$object->GetHash()}">{t}blob{/t}</a></td>
        {/if}
      </tr>
      {if $tag->GetTagger()}

--- a/templates/taglist.tpl
+++ b/templates/taglist.tpl
@@ -15,11 +15,13 @@
 	   {assign var=object value=$tag->GetObject()}
 	   {assign var=tagcommit value=$tag->GetCommit()}
 	   {assign var=objtype value=$tag->GetType()}
-           <td><em>{$tagcommit->GetAge()|agestring}</em></td>
+           <td><em>{if $tagcommit}{$tagcommit->GetAge()|agestring}{else}{$tag->GetAge()|agestring}{/if}</em></td>
            <td>
 	   {if $objtype == 'commit'}
 		   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=commit&amp;h={$object->GetHash()}" class="list"><strong>{$tag->GetName()}</strong></a>
 	   {elseif $objtype == 'tag'}
+		   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=tag&amp;h={$tag->GetName()}" class="list"><strong>{$tag->GetName()}</strong></a>
+	   {elseif $objtype == 'blob'}
 		   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=tag&amp;h={$tag->GetName()}" class="list"><strong>{$tag->GetName()}</strong></a>
 	   {/if}
 	   </td>
@@ -33,8 +35,12 @@
              {if !$tag->LightTag()}
    	       <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=tag&amp;h={$tag->GetName()}">{t}tag{/t}</a> | 
              {/if}
+	     {if $objtype == 'blob'}
+		<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob&amp;h={$object->GetHash()}">{t}blob{/t}</a>
+	     {else}
              <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=commit&amp;h={$tagcommit->GetHash()}">{t}commit{/t}</a>
 	      | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=shortlog&amp;h={$tagcommit->GetHash()}">{t}shortlog{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=log&amp;h={$tagcommit->GetHash()}">{t}log{/t}</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=snapshot&amp;h={$tagcommit->GetHash()}" class="snapshotTip">{t}snapshot{/t}</a>
+	      {/if}
            </td>
        </tr>
      {/foreach}

comments