Blobdiff and side by side diff templates are pretty much identical now - merge them
Blobdiff and side by side diff templates are pretty much identical now - merge them

--- a/include/controller/Controller_Blobdiff.class.php
+++ b/include/controller/Controller_Blobdiff.class.php
@@ -48,9 +48,6 @@
 		if (isset($this->params['plain']) && ($this->params['plain'] === true)) {
 			return 'blobdiffplain.tpl';
 		}
-		if (isset($this->params['sidebyside']) && ($this->params['sidebyside'] === true)) {
-			return 'sidebyside.tpl';
-		}
 		return 'blobdiff.tpl';
 	}
 
@@ -64,7 +61,7 @@
 	 */
 	protected function GetCacheKey()
 	{
-		return (isset($this->params['hashbase']) ? $this->params['hashbase'] : '') . '|' . (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['hashparent']) ? $this->params['hashparent'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : '');
+		return (isset($this->params['hashbase']) ? $this->params['hashbase'] : '') . '|' . (isset($this->params['hash']) ? $this->params['hash'] : '') . '|' . (isset($this->params['hashparent']) ? $this->params['hashparent'] : '') . '|' . (isset($this->params['file']) ? sha1($this->params['file']) : '') . '|' . (isset($this->params['sidebyside']) && ($this->params['sidebyside'] === true) ? '1' : '');
 	}
 
 	/**
@@ -143,6 +140,10 @@
 			return;
 		}
 
+		if (isset($this->params['sidebyside']) && ($this->params['sidebyside'] === true)) {
+			$this->tpl->assign('sidebyside', true);
+		}
+
 		$commit = $this->project->GetCommit($this->params['hashbase']);
 		$this->tpl->assign('commit', $commit);
 

--- a/templates/blobdiff.tpl
+++ b/templates/blobdiff.tpl
@@ -10,7 +10,12 @@
  <div class="page_nav">
    {include file='nav.tpl' treecommit=$commit}
    <br />
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff&amp;h={$blob->GetHash()}&amp;hp={$blobparent->GetHash()}&amp;hb={$commit->GetHash()}&amp;f={$file}&amp;o=sidebyside">{t}side by side{/t}</a> |
+   {if $sidebyside}
+   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff&amp;h={$blob->GetHash()}&amp;hp={$blobparent->GetHash()}&amp;hb={$commit->GetHash()}&amp;f={$file}&amp;o=unified">{t}unified{/t}</a>
+   {else}
+   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff&amp;h={$blob->GetHash()}&amp;hp={$blobparent->GetHash()}&amp;hb={$commit->GetHash()}&amp;f={$file}&amp;o=sidebyside">{t}side by side{/t}</a>
+   {/if}
+    |
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff_plain&amp;h={$blob->GetHash()}&amp;hp={$blobparent->GetHash()}&amp;f={$file}">{t}plain{/t}</a>
  </div>
 
@@ -23,8 +28,13 @@
      {* Display the from -> to diff header *}
      {t}blob{/t}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob&amp;h={$blobparent->GetHash()}&amp;hb={$commit->GetHash()}&amp;f={$file}">{if $file}a/{$file}{else}{$blobparent->GetHash()}{/if}</a> -&gt; {t}blob{/t}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob&amp;h={$blob->GetHash()}&amp;hb={$commit->GetHash()}&amp;f={$file}">{if $file}b/{$file}{else}{$blob->GetHash()}{/if}</a>
    </div>
+   {if $sidebyside}
+   {* Display the sidebysidediff *}
+   {include file='filediffsidebyside.tpl' diffsplit=$filediff->GetDiffSplit()}
+   {else}
    {* Display the diff *}
    {include file='filediff.tpl' diff=$filediff->GetDiff($file, false, true)}
+   {/if}
  </div>
 
  {include file='footer.tpl'}

--- a/templates/sidebyside.tpl
+++ /dev/null
@@ -1,31 +1,1 @@
-{*
- *  blobdiff.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Blobdiff view template
- *
- *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
- *}
-{include file='header.tpl'}
 
- <div class="page_nav">
-   {include file='nav.tpl' treecommit=$commit}
-   <br />
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff&amp;h={$blob->GetHash()}&amp;hp={$blobparent->GetHash()}&amp;hb={$commit->GetHash()}&amp;f={$file}&amp;o=unified">{t}unified{/t}</a> |
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blobdiff_plain&amp;h={$blob->GetHash()}&amp;hp={$blobparent->GetHash()}&amp;f={$file}">{t}plain{/t}</a>
- </div>
-
- {include file='title.tpl' titlecommit=$commit}
-
- {include file='path.tpl' pathobject=$blobparent target='blob'}
-
- <div class="page_body">
-   <div class="diff_info">
-     {* Display the from -> to diff header *}
-     {t}blob{/t}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob&amp;h={$blobparent->GetHash()}&amp;hb={$commit->GetHash()}&amp;f={$file}">{if $file}a/{$file}{else}{$blobparent->GetHash()}{/if}</a> -&gt; {t}blob{/t}:<a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=blob&amp;h={$blob->GetHash()}&amp;hb={$commit->GetHash()}&amp;f={$file}">{if $file}b/{$file}{else}{$blob->GetHash()}{/if}</a>
-   </div>
-   {* Display the sidebysidediff *}
-   {include file='filediffsidebyside.tpl' diffsplit=$filediff->GetDiffSplit()}
- </div>
-
- {include file='footer.tpl'}
-

comments