Unify history template
Unify history template

--- a/include/display.git_history.php
+++ b/include/display.git_history.php
@@ -27,47 +27,38 @@
 	if (isset($refs[$hash]))
 		$tpl->assign("hashbaseref",$refs[$hash]);
 	$tpl->assign("tree",$co['tree']);
-	$tpl->display("history_nav.tpl");
 	$tpl->assign("title",$co['title']);
 	$paths = git_path_trees($projectroot . $project, $hash, $file);
 	$tpl->assign("paths",$paths);
-	$tpl->display("history_header.tpl");
 	$cmdout = git_history_list($projectroot . $project, $hash, $file);
-	$alternate = FALSE;
 	$lines = explode("\n", $cmdout);
+	$historylines = array();
 	foreach ($lines as $i => $line) {
 		if (ereg("^([0-9a-fA-F]{40})",$line,$regs))
 			$commit = $regs[1];
 		else if (ereg(":([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$",$line,$regs) && isset($commit)) {
+				$historyline = array();
 				$co = git_read_commit($projectroot . $project, $commit);
-				$tpl->clear_all_assign();
-				if ($alternate)
-					$tpl->assign("class","dark");
-				else
-					$tpl->assign("class","light");
-				$alternate = !$alternate;
-				$tpl->assign("project",$project);
-				$tpl->assign("agestringage",$co['age_string_age']);
-				$tpl->assign("agestringdate",$co['age_string_date']);
-				$tpl->assign("authorname",$co['author_name']);
-				$tpl->assign("commit",$commit);
-				$tpl->assign("file",$file);
-				$tpl->assign("title",$co['title_short']);
+				$historyline["agestringage"] = $co['age_string_age'];
+				$historyline["agestringdate"] = $co['age_string_date'];
+				$historyline["authorname"] = $co['author_name'];
+				$historyline["commit"] = $commit;
+				$historyline["file"] = $file;
+				$historyline["title"] = $co['title_short'];
 				if (isset($refs[$commit]))
-					$tpl->assign("commitref",$refs[$commit]);
+					$historyline["commitref"] = $refs[$commit];
 				$blob = git_get_hash_by_path($projectroot . $project, $hash,$file);
 				$blob_parent = git_get_hash_by_path($projectroot . $project, $commit,$file);
 				if ($blob && $blob_parent && ($blob != $blob_parent)) {
-					$tpl->assign("blob",$blob);
-					$tpl->assign("blobparent",$blob_parent);
-					$tpl->assign("difftocurrent",TRUE);
+					$historyline["blob"] = $blob;
+					$historyline["blobparent"] = $blob_parent;
 				}
-				$tpl->display("history_item.tpl");
+				$historylines[] = $historyline;
 				unset($commit);
 		}
 	}
-	$tpl->clear_all_assign();
-	$tpl->display("history_footer.tpl");
+	$tpl->assign("historylines",$historylines);
+	$tpl->display("history.tpl");
 }
 
 ?>

--- /dev/null
+++ b/templates/history.tpl
@@ -1,1 +1,44 @@
+{*
+ *  history.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: History view nav template
+ *
+ *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
+ *}
+ {* Page header *}
+ <div class="page_nav">
+   <a href="{$SCRIPT_NAME}?p={$project}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=shortlog">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hash}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hash}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}">tree</a>
+   <br /><br />
+ </div>
+ <div>
+   <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hash}" class="title">{$title}
+   {if $hashbaseref}
+     <span class="tag">{$hashbaseref}</span>
+   {/if}
+   </a>
+ </div>
+ <div class="page_path">
+   {* File path *}
+   <b>
+     <a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$hash}&h={$hash}">[{$project}]</a> / 
+     {foreach from=$paths item=path name=paths}
+       {if $smarty.foreach.paths.last}
+         <a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$path.tree}&f={$path.full}">{$path.short}</a>
+       {else}
+         <a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$hash}&h={$path.tree}&f={$path.full}">{$path.short}</a> / 
+       {/if}
+     {/foreach}
+   </b>
+ </div>
+ <table cellspacing="0">
+   {section name=history loop=$historylines}
+     <tr class="{cycle values="light,dark"}">
+       <td title="{$historylines[history].agestringage}"><i>{$historylines[history].agestringdate}</i></td>
+       <td><i>{$historylines[history].authorname}</i></td>
+       <td><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$historylines[history].commit}" class="list"><b>{$historylines[history].title}{if $historylines[history].commitref} <span class="tag">{$historylines[history].commitref}</span>{/if}</b></a></td>
+       <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$historylines[history].commit}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$historylines[history].commit}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=blob&hb={$historylines[history].commit}&f={$historylines[history].file}">blob</a>{if $historylines[history].blob && $historylines[history].blobparent} | <a href="{$SCRIPT_NAME}?p={$project}&a=blobdiff&h={$historylines[history].blob}&hp={$historylines[history].blobparent}&hb={$historylines[history].commit}&f={$historylines[history].file}">diff to current</a>{/if}
+       </td>
+     </tr>
+   {/section}
+ </table>
 

--- a/templates/history_footer.tpl
+++ /dev/null
@@ -1,9 +1,1 @@
-{*
- *  history_footer.tpl
- *  gitphp: A PHP git repository browser
- *  Component: History view footer template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- </table>
 

--- a/templates/history_header.tpl
+++ /dev/null
@@ -1,16 +1,1 @@
-{*
- *  history_header.tpl
- *  gitphp: A PHP git repository browser
- *  Component: History view header template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hash}" class="title">{$title}
- {if $hashbaseref}
- <span class="tag">{$hashbaseref}</span>
- {/if}
- </a>
- </div>
- <div class="page_path"><b><a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$hash}&h={$hash}">[{$project}]</a> / {foreach from=$paths item=path name=paths}{if $smarty.foreach.paths.last}<a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$path.tree}&f={$path.full}">{$path.short}</a>{else}<a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$hash}&h={$path.tree}&f={$path.full}">{$path.short}</a> / {/if}{/foreach}</b></div>
- <table cellspacing="0">
 

--- a/templates/history_item.tpl
+++ /dev/null
@@ -1,14 +1,1 @@
-{*
- *  history_item.tpl
- *  gitphp: A PHP git repository browser
- *  Component: History view item template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <tr class="{$class}">
- <td title="{$agestringage}"><i>{$agestringdate}</i></td>
- <td><i>{$authorname}</i></td>
- <td><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$commit}" class="list"><b>{$title}{if $commitref} <span class="tag">{$commitref}</span>{/if}</b></a></td>
- <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$commit}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$commit}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=blob&hb={$commit}&f={$file}">blob</a>{if $difftocurrent} | <a href="{$SCRIPT_NAME}?p={$project}&a=blobdiff&h={$blob}&hp={$blobparent}&hb={$commit}&f={$file}">diff to current</a>{/if}
- </td></tr>
 

--- a/templates/history_nav.tpl
+++ /dev/null
@@ -1,12 +1,1 @@
-{*
- *  history_nav.tpl
- *  gitphp: A PHP git repository browser
- *  Component: History view nav template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div class="page_nav">
- <a href="{$SCRIPT_NAME}?p={$project}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=shortlog">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hash}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hash}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}">tree</a>
- <br /><br />
- </div>
 

comments