Unify log template
Unify log template

--- a/include/display.git_log.php
+++ b/include/display.git_log.php
@@ -25,50 +25,44 @@
 	$tpl->clear_all_assign();
 	$tpl->assign("project",$project);
 	$tpl->assign("hash",$hash);
-	$tpl->display("log_nav.tpl");
+	$tpl->assign("head",$head);
+
+	if ($page)
+		$tpl->assign("page",$page);
 
 	$revlist = git_read_revlist($projectroot . $project, $hash, 101, ($page * 100));
 
-	if (($hash != $head) || $page)
-		$tpl->assign("headlink",TRUE);
-	if ($page > 0) {
-		$tpl->assign("prevlink",TRUE);
-		$tpl->assign("prevpage",$page-1);
-	}
-	if (count($revlist) > 100) {
-		$tpl->assign("nextlink",TRUE);
-		$tpl->assign("nextpage",$page+1);
-	}
-	$tpl->display("log_pagenav.tpl");
+	$revlistcount = count($revlist);
+	$tpl->assign("revlistcount",$revlistcount);
 
 	if (!$revlist) {
-		$tpl->clear_all_assign();
-		$tpl->assign("project",$project);
+		$tpl->assign("norevlist",TRUE);
 		$co = git_read_commit($hash);
-		$tpl->assign("age_string",$co['age_string']);
-		$tpl->display("log_info.tpl");
+		$tpl->assign("lastchange",$co['age_string']);
 	}
-	$commitcount = min(100,count($revlist));
+
+	$commitlines = array();
+	$commitcount = min(100,$revlistcount);
 	for ($i = 0; $i < $commitcount; $i++) {
 		$commit = $revlist[$i];
 		if (isset($commit) && strlen($commit) > 1) {
-			$tpl->clear_all_assign();
+			$commitline = array();
 			$co = git_read_commit($projectroot . $project, $commit);
 			$ad = date_str($co['author_epoch']);
-			$tpl->assign("project",$project);
-			$tpl->assign("commit",$commit);
+			$commitline["project"] = $project;
+			$commitline["commit"] = $commit;
 			if (isset($refs[$commit]))
-				$tpl->assign("commitref",$refs[$commit]);
-			$tpl->assign("agestring",$co['age_string']);
-			$tpl->assign("title",$co['title']);
-			$tpl->assign("authorname",$co['author_name']);
-			$tpl->assign("rfc2822",$ad['rfc2822']);
-			$tpl->assign("comment",$co['comment']);
-			if (count($co['comment']) > 0)
-				$tpl->assign("notempty",TRUE);
-			$tpl->display("log_item.tpl");
+				$commitline["commitref"] = $refs[$commit];
+			$commitline["agestring"] = $co['age_string'];
+			$commitline["title"] = $co['title'];
+			$commitline["authorname"] = $co['author_name'];
+			$commitline["rfc2822"] = $ad['rfc2822'];
+			$commitline["comment"] = $co['comment'];
+			$commitlines[] = $commitline;
 		}
 	}
+	$tpl->assign("commitlines",$commitlines);
+	$tpl->display("log.tpl");
 }
 
 ?>

file:b/templates/log.tpl (new)
--- /dev/null
+++ b/templates/log.tpl
@@ -1,1 +1,63 @@
+{*
+ *  log.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Log view template
+ *
+ *  Copyright (C) 2009 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&h={$hash}">shortlog</a> | log | <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={$hash}&hb={$hash}">tree</a>
+   <br />
+   {if ($hash != $head) || $page}
+     <a href="{$SCRIPT_NAME}?p={$project}&a=log">HEAD</a>
+   {else}
+     HEAD
+   {/if}
+   &sdot; 
+   {if $page > 0}
+     <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}&pg={$page-1}" accesskey="p" title="Alt-p">prev</a>
+   {else}
+     prev
+   {/if}
+   &sdot; 
+   {if $revlistcount > 100}
+     <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}&pg={$page+1}" accesskey="n" title="Alt-n">next</a>
+   {else}
+     next
+   {/if}
+   <br />
+ </div>
+ {if $norevlist}
+   <div>
+     <a href="{$SCRIPT_NAME}?p={$project}&a=summary" class="title">&nbsp</a>
+   </div>
+   <div class="page_body">
+     Last change {$lastchange}.
+     <br /><br />
+   </div>
+ {/if}
+ {section name=log loop=$commitlines}
+   <div>
+     <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$commitlines[log].commit}" class="title"><span class="age">{$commitlines[log].agestring}</span>{$commitlines[log].title}
+       {if $commitlines[log].commitref}
+         <span class="tag">{$commitlines[log].commitref}</span>
+       {/if}
+     </a>
+   </div>
+   <div class="title_text">
+     <div class="log_link">
+       <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$commitlines[log].commit}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$commitlines[log].commit}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$commitlines[log].commit}&hb={$commitlines[log].commit}">tree</a>
+       <br />
+     </div>
+     <i>{$commitlines[log].authorname} [{$commitlines[log].rfc2822}]</i><br />
+   </div>
+   <div class="log_body">
+     {foreach from=$commitlines[log].comment item=line}
+       {$line}<br />
+     {/foreach}
+     {if count($commitlines[log].comment) > 0}
+       <br />
+     {/if}
+   </div>
+ {/section}
 

file:a/templates/log_info.tpl (deleted)
--- a/templates/log_info.tpl
+++ /dev/null
@@ -1,13 +1,1 @@
-{*
- *  log_info.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Log view info template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div>
- <a href="{$SCRIPT_NAME}?p={$project}&a=summary" class="title">&nbsp</a>
- </div>
- <div class="page_body"> Last change {$agestring}.<br /><br />
- </div>
 

file:a/templates/log_item.tpl (deleted)
--- a/templates/log_item.tpl
+++ /dev/null
@@ -1,30 +1,1 @@
-{*
- *  log_item.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Log view item template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div>
- <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$commit}" class="title"><span class="age">{$agestring}</span>{$title}
- {if $commitref}
-  <span class="tag">{$commitref}</span>
- {/if}
- </a>
- </div>
- <div class="title_text">
- <div class="log_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=tree&h={$commit}&hb={$commit}">tree</a>
- <br />
- </div>
- <i>{$authorname} [{$rfc2822}]</i><br />
- </div>
- <div class="log_body">
- {foreach from=$comment item=line}
- {$line}<br />
- {/foreach}
- {if $notempty}
- <br />
- {/if}
- </div>
 

file:a/templates/log_nav.tpl (deleted)
--- a/templates/log_nav.tpl
+++ /dev/null
@@ -1,11 +1,1 @@
-{*
- *  log_nav.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Log 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&h={$hash}">shortlog</a> | log | <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={$hash}&hb={$hash}">tree</a>
- <br />
 

--- a/templates/log_pagenav.tpl
+++ /dev/null
@@ -1,11 +1,1 @@
-{*
- *  log_pagenav.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Log view page nav template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- {if $headlink}<a href="{$SCRIPT_NAME}?p={$project}&a=log">{/if}HEAD{if $headlink}</a>{/if} &sdot; {if $prevlink}<a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}&pg={$prevpage}" accesskey="p" title="Alt-p">{/if}prev{if $prevlink}</a>{/if} &sdot; {if $nextlink}<a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}&pg={$nextpage}" accesskey="n" title="Alt-n">{/if}next{if $nextlink}</a>{/if}
- <br />
- </div>
 

comments