Use blob as template variable for blob objects, rather than hash
Use blob as template variable for blob objects, rather than hash

--- a/include/controller/Controller_Blame.class.php
+++ b/include/controller/Controller_Blame.class.php
@@ -100,16 +100,16 @@
 			$this->params['hash'] = $commit->PathToHash($this->params['file']);
 		}
 		
-		$hash = $this->project->GetBlob($this->params['hash']);
+		$blob = $this->project->GetBlob($this->params['hash']);
 		if ($this->params['file'])
-			$hash->SetName($this->params['file']);
-		$hash->SetCommit($commit);
-		$this->tpl->assign('hash', $hash);
+			$blob->SetName($this->params['file']);
+		$blob->SetCommit($commit);
+		$this->tpl->assign('blob', $blob);
 
 		$this->tpl->assign('tree', $commit->GetTree());
 
-		$blame = $hash->GetBlame();
-		$this->tpl->assign('blame', $hash->GetBlame());
+		$blame = $blob->GetBlame();
+		$this->tpl->assign('blame', $blob->GetBlame());
 	}
 
 }

--- a/include/controller/Controller_Blob.class.php
+++ b/include/controller/Controller_Blob.class.php
@@ -140,14 +140,13 @@
 			$this->params['hash'] = $commit->PathToHash($this->params['file']);
 		}
 
-		$hash = $this->project->GetBlob($this->params['hash']);
+		$blob = $this->project->GetBlob($this->params['hash']);
 		if ($this->params['file'])
-			$hash->SetName($this->params['file']);
-		$hash->SetCommit($commit);
-		$this->tpl->assign('hash', $hash);
+			$blob->SetName($this->params['file']);
+		$blob->SetCommit($commit);
+		$this->tpl->assign('blob', $blob);
 
 		if ($this->params['plain']) {
-			$this->tpl->assign('blob', $hash->GetData());
 			return;
 		}
 
@@ -157,7 +156,7 @@
 		$this->tpl->assign('tree', $commit->GetTree());
 
 		if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true)) {
-			$mime = $hash->FileMime();
+			$mime = $blob->FileMime();
 			if ($mime)
 				$mimetype = strtok($mime, '/');
 		}
@@ -165,7 +164,7 @@
 		if ($mime && (strtok($mime, '/') == 'image')) {
 			$this->tpl->assign('datatag', true);
 			$this->tpl->assign('mime', $mime);
-			$this->tpl->assign('data', base64_encode($hash->GetData()));
+			$this->tpl->assign('data', base64_encode($blob->GetData()));
 			return;
 		}
 
@@ -174,11 +173,11 @@
 			if (class_exists('GeSHi')) {
 				$geshi = new GeSHi("",'php');
 				if ($geshi) {
-					$lang = $geshi->get_language_name_from_extension(substr(strrchr($hash->GetPath(),'.'),1));
+					$lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetPath(),'.'),1));
 					if (!empty($lang)) {
 						$geshi->enable_classes();
 						$geshi->enable_strict_mode(GESHI_MAYBE);
-						$geshi->set_source($hash->GetData());
+						$geshi->set_source($blob->GetData());
 						$geshi->set_language($lang);
 						$geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
 						$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
@@ -191,7 +190,7 @@
 			}
 		}
 
-		$this->tpl->assign('bloblines', $hash->GetData(true));
+		$this->tpl->assign('bloblines', $blob->GetData(true));
 	}
 
 }

--- a/include/controller/Controller_Blobdiff.class.php
+++ b/include/controller/Controller_Blobdiff.class.php
@@ -119,12 +119,12 @@
 		$commit = $this->project->GetCommit($this->params['hashbase']);
 		$this->tpl->assign('commit', $commit);
 
-		$hashparent = $this->project->GetBlob($this->params['hashparent']);
-		$hashparent->SetCommit($commit);
-		$this->tpl->assign('hashparent', $hashparent);
+		$blobparent = $this->project->GetBlob($this->params['hashparent']);
+		$blobparent->SetCommit($commit);
+		$this->tpl->assign('blobparent', $blobparent);
 
-		$hash = $this->project->GetBlob($this->params['hash']);
-		$this->tpl->assign('hash', $hash);
+		$blob = $this->project->GetBlob($this->params['hash']);
+		$this->tpl->assign('blob', $blob);
 
 		$tree = $commit->GetTree();
 		$this->tpl->assign('tree', $tree);

--- a/templates/blame.tpl
+++ b/templates/blame.tpl
@@ -10,9 +10,9 @@
 
  <div class="page_nav">
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=log">log</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$commit->GetHash()}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$commit->GetHash()}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">tree</a><br />
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blob_plain&h={$hash->GetHash()}&f={$hash->GetPath()}">plain</a> | 
+   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blob_plain&h={$blob->GetHash()}&f={$blob->GetPath()}">plain</a> | 
    {if $commit->GetHash() != $head->GetHash()}
-     <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blame&hb=HEAD&f={$hash->GetPath()}">HEAD</a>
+     <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blame&hb=HEAD&f={$blob->GetPath()}">HEAD</a>
    {else}
      HEAD
    {/if}
@@ -22,11 +22,11 @@
 
  {include file='title.tpl' titlecommit=$commit}
 
- {include file='path.tpl' pathobject=$hash target='blob'}
+ {include file='path.tpl' pathobject=$blob target='blob'}
  
  <div class="page_body">
  	<table class="code">
-	{foreach from=$hash->GetData(true) item=blobline name=blob}
+	{foreach from=$blob->GetData(true) item=blobline name=blob}
 	  {assign var=blamecommit value=$blame[$smarty.foreach.blob.iteration]}
 	  {if $blamecommit}
 	    {cycle values="light,dark" assign=rowclass}

--- a/templates/blob.tpl
+++ b/templates/blob.tpl
@@ -10,19 +10,19 @@
 
  <div class="page_nav">
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=log">log</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$commit->GetHash()}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$commit->GetHash()}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">tree</a><br />
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blob_plain&h={$hash->GetHash()}&f={$file}">plain</a> | 
+   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blob_plain&h={$blob->GetHash()}&f={$file}">plain</a> | 
    {if $commit->GetHash() != $head->GetHash()}
      <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blob&hb=HEAD&f={$file}">HEAD</a>
    {else}
      HEAD
    {/if}
-   {if !$datatag} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blame&h={$hash->GetHash()}&f={$file}&hb={$commit->GetHash()}">blame</a>{/if}
+   {if !$datatag} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blame&h={$blob->GetHash()}&f={$file}&hb={$commit->GetHash()}">blame</a>{/if}
    <br />
  </div>
 
  {include file='title.tpl' titlecommit=$commit}
 
-{include file='path.tpl' pathobject=$hash target='blobplain'}
+{include file='path.tpl' pathobject=$blob target='blobplain'}
 
  <div class="page_body">
    {if $datatag}

--- a/templates/blobdiff.tpl
+++ b/templates/blobdiff.tpl
@@ -12,17 +12,17 @@
  <div class="page_nav">
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=log">log</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$commit->GetHash()}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$commit->GetHash()}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">tree</a>
    <br />
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blobdiff_plain&h={$hash->GetHash()}&hp={$hashparent->GetHash()}&f={$file}">plain</a>
+   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blobdiff_plain&h={$blob->GetHash()}&hp={$blobparent->GetHash()}&f={$file}">plain</a>
  </div>
 
  {include file='title.tpl' titlecommit=$commit}
 
- {include file='path.tpl' pathobject=$hashparent target='blob'}
+ {include file='path.tpl' pathobject=$blobparent target='blob'}
  
  <div class="page_body">
    <div class="diff_info">
      {* Display the from -> to diff header *}
-     blob:<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blob&h={$hashparent->GetHash()}&hb={$commit->GetHash()}&f={$file}">{if $file}a/{$file}{else}{$hashparent->GetHash()}{/if}</a> -&gt; blob:<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blob&h={$hash->GetHash()}&hb={$commit->GetHash()}&f={$file}">{if $file}b/{$file}{else}{$hash->GetHash()}{/if}</a>
+     blob:<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blob&h={$blobparent->GetHash()}&hb={$commit->GetHash()}&f={$file}">{if $file}a/{$file}{else}{$blobparent->GetHash()}{/if}</a> -&gt; blob:<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blob&h={$blob->GetHash()}&hb={$commit->GetHash()}&f={$file}">{if $file}b/{$file}{else}{$blob->GetHash()}{/if}</a>
    </div>
    {* Display the diff *}
    {include file='filediff.tpl' diff=$filediff->GetDiff($file, false, true)}

--- a/templates/blobplain.tpl
+++ b/templates/blobplain.tpl
@@ -5,5 +5,5 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{$blob}
+{$blob->GetData()}
 

--- a/templates/header.tpl
+++ b/templates/header.tpl
@@ -39,7 +39,7 @@
             <div class="search">
               <input type="hidden" name="p" value="{$project->GetProject()}" />
               <input type="hidden" name="a" value="search" />
-              <input type ="hidden" name="h" value="{if $commit}{$commit->GetHash()}{elseif $hash instanceof GitPHP_Commit}{$hash->GetHash()}{elseif $hash}{$hash}{else}HEAD{/if}" />
+              <input type ="hidden" name="h" value="{if $commit}{$commit->GetHash()}{else}HEAD{/if}" />
               <select name="st">
                 <option {if $searchtype == 'commit'}selected="selected"{/if} value="commit">commit</option>
                 <option {if $searchtype == 'author'}selected="selected"{/if} value="author">author</option>

comments