Unify commit template
Unify commit template

--- a/include/display.git_commit.php
+++ b/include/display.git_commit.php
@@ -34,7 +34,6 @@
 	$tpl->assign("tree",$co['tree']);
 	if (isset($co['parent']))
 		$tpl->assign("parent",$co['parent']);
-	$tpl->display("commit_nav.tpl");
 	$tpl->assign("title",$co['title']);
 	$refs = read_info_ref($projectroot . $project);
 	if (isset($refs[$co['id']]))
@@ -53,32 +52,25 @@
 	$tpl->assign("parents",$co['parents']);
 	$tpl->assign("comment",$co['comment']);
 	$tpl->assign("difftreesize",count($difftree)+1);
-	$tpl->display("commit_data.tpl");
-	$alternate = FALSE;
+	$difftreelines = array();
 	foreach ($difftree as $i => $line) {
-		$tpl->clear_all_assign();
 		if (ereg("^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)([0-9]{0,3})\t(.*)$",$line,$regs)) {
-			if ($alternate)
-				$tpl->assign("class","dark");
-			else
-				$tpl->assign("class","light");
-			$alternate = !$alternate;
-			$tpl->assign("project",$project);
-			$tpl->assign("hash",$hash);
-			$tpl->assign("from_mode",$regs[1]);
-			$tpl->assign("to_mode",$regs[2]);
-			$tpl->assign("from_mode_cut",substr($regs[1],-4));
-			$tpl->assign("to_mode_cut",substr($regs[2],-4));
-			$tpl->assign("from_id",$regs[3]);
-			$tpl->assign("to_id",$regs[4]);
-			$tpl->assign("status",$regs[5]);
-			$tpl->assign("similarity",$regs[6]);
-			$tpl->assign("file",$regs[7]);
-			$tpl->assign("from_file",strtok($regs[7],"\t"));
-			$tpl->assign("to_file",strtok("\t"));
-			$tpl->assign("to_filetype",file_type($regs[2]));
+			$difftreeline = array();
+			$difftreeline["from_mode"] = $regs[1];
+			$difftreeline["to_mode"] = $regs[2];
+			$difftreeline["from_mode_cut"] = substr($regs[1],-4);
+			$difftreeline["to_mode_cut"] = substr($regs[2],-4);
+			$difftreeline["from_id"] = $regs[3];
+			$difftreeline["to_id"] = $regs[4];
+			$difftreeline["status"] = $regs[5];
+			$difftreeline["similarity"] = ltrim($regs[6],"0");
+			$difftreeline["file"] = $regs[7];
+			$difftreeline["from_file"] = strtok($regs[7],"\t");
+			$difftreeline["from_filetype"] = file_type($regs[1]);
+			$difftreeline["to_file"] = strtok("\t");
+			$difftreeline["to_filetype"] = file_type($regs[2]);
 			if ((octdec($regs[2]) & 0x8000) == 0x8000)
-				$tpl->assign("isreg",TRUE);
+				$difftreeline["isreg"] = TRUE;
 			$modestr = "";
 			if ((octdec($regs[1]) & 0x17000) != (octdec($regs[2]) & 0x17000))
 				$modestr .= " from " . file_type($regs[1]) . " to " . file_type($regs[2]);
@@ -88,17 +80,16 @@
 				else if (octdec($regs[2]) & 0x8000)
 					$modestr .= " mode: " . (octdec($regs[2]) & 0777);
 			}
-			$tpl->assign("modechange",$modestr);
+			$difftreeline["modechange"] = $modestr;
 			$simmodechg = "";
 			if ($regs[1] != $regs[2])
 				$simmodechg .= ", mode: " . (octdec($regs[2]) & 0777);
-			$tpl->assign("simmodechg",$simmodechg);
-
-			$tpl->display("commit_item.tpl");
+			$difftreeline["simmodechg"] = $simmodechg;
+			$difftreelines[] = $difftreeline;
 		}
 	}
-	$tpl->clear_all_assign();
-	$tpl->display("commit_footer.tpl");
+	$tpl->assign("difftreelines",$difftreelines);
+	$tpl->display("commit.tpl");
 }
 
 ?>

--- /dev/null
+++ b/templates/commit.tpl
@@ -1,1 +1,105 @@
+{*
+ *  commit.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Commit view template
+ *
+ *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
+ *}
+ <div class="page_nav">
+   {* Nav *}
+   <a href="{$SCRIPT_NAME}?p={$project}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h={$hash}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}">log</a> | commit | {if $parent}<a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hash}">commitdiff</a> | {/if}<a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}">tree</a>
+   <br /><br />
+ </div>
+ <div>
+   {* Commit header *}
+   {if $parent}
+     <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hash}" class="title">{$title}
+     {if $commitref}
+       <span class="tag">{$commitref}</span>
+     {/if}
+     </a>
+   {else}
+     <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}" class="title">{$title}</a>
+   {/if}
+ </div>
+ <div class="title_text">
+   {* Commit data *}
+   <table cellspacing="0">
+     <tr>
+       <td>author</td>
+       <td>{$author}</td>
+     </tr>
+     <tr>
+       <td></td>
+       <td> {$adrfc2822} ({if $adhourlocal < 6}<span class="latenight">{/if}{$adhourlocal}:{$adminutelocal}{if $adhourlocal < 6}</span>{/if} {$adtzlocal})</td>
+     </tr>
+     <tr>
+       <td>committer</td>
+       <td>{$committer}</td>
+     </tr>
+     <tr>
+       <td></td>
+       <td> {$cdrfc2822} ({$cdhourlocal}:{$cdminutelocal} {$cdtzlocal})</td>
+     </tr>
+     <tr>
+       <td>commit</td>
+       <td class="monospace">{$id}</td>
+     <tr>
+     <tr>
+       <td>tree</td>
+       <td class="monospace"><a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}" class="list">{$tree}</a></td>
+       <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}">tree</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=snapshot&h={$hash}">snapshot</a></td>
+     </tr>
+     {foreach from=$parents item=par}
+       <tr>
+         <td>parent</td>
+	 <td class="monospace"><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$par}" class="list">{$par}</a></td>
+         <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$par}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hash}&hp={$par}">commitdiff</a></td>
+       </tr>
+     {/foreach}
+   </table>
+ </div>
+ <div class="page_body">
+   {foreach from=$comment item=line}
+     {$line}<br />
+   {/foreach}
+ </div>
+ <div class="list_head">
+   {if $difftreesize > 11}
+     {$difftreesize} files changed:
+   {/if}
+ </div>
+ <table cellspacing="0">
+   {* Loop and show files changed *}
+   {section name=difftree loop=$difftreelines}
+     <tr class="{cycle values="light,dark"}">
+	 
+	 {if $difftreelines[difftree].status == "A"}
+	  <td><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].to_id}&hb={$hash}&f={$difftreelines[difftree].file}" class="list">{$difftreelines[difftree].file}</a></td>
+	  <td><span class="newfile">[new {$difftreelines[difftree].to_filetype}{if $difftreelines[difftree].isreg} with mode: {$difftreelines[difftree].to_mode_cut}{/if}]</span></td>
+	  <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].to_id}&hb={$hash}&f={$difftreelines[difftree].file}">blob</a></td>
+	 {elseif $difftreelines[difftree].status == "D"}
+	  <td><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].from_id}&hb={$hash}&f={$difftreelines[difftree].file}" class="list">{$difftreelines[difftree].file}</a></td>
+	  <td><span class="deletedfile">[deleted {$difftreelines[difftree].from_filetype}]</span></td>
+	  <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].from_id}&hb={$hash}&f={$difftreelines[difftree].file}">blob</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=history&h={$hash}&f={$difftreelines[difftree].file}">history</a></td>
+	 {elseif $difftreelines[difftree].status == "M" || $difftreelines[difftree].status == "T"}
+	  <td>
+	  {if $difftreelines[difftree].to_id != $difftreelines[difftree].from_id}
+	    <a href="{$SCRIPT_NAME}?p={$project}&a=blobdiff&h={$difftreelines[difftree].to_id}&hp={$difftreelines[difftree].from_id}&hb={$hash}&f={$difftreelines[difftree].file}" class="list">{$difftreelines[difftree].file}</a>
+	  {else}
+	    <a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].to_id}&hb={$hash}&f={$difftreelines[difftree].file}" class="list">{$difftreelines[difftree].file}</a>
+	  {/if}
+	  </td>
+	  <td>{if $difftreelines[difftree].from_mode != $difftreelines[difftree].to_mode} <span class="changedfile">[changed{$difftreelines[difftree].modechange}]</span>{/if}</td>
+	  <td class="link">
+	  <a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].to_id}&hb={$hash}&f={$difftreelines[difftree].file}">blob</a>{if $difftreelines[difftree].to_id != $difftreelines[difftree].from_id} | <a href="{$SCRIPT_NAME}?p={$project}&a=blobdiff&h={$difftreelines[difftree].to_id}&hp={$difftreelines[difftree].from_id}&hb={$hash}&f={$difftreelines[difftree].file}">diff</a>{/if} | <a href="{$SCRIPT_NAME}?p={$project}&a=history&h={$hash}&f={$difftreelines[difftree].file}">history</a></td>
+	 {elseif $difftreelines[difftree].status == "R"}
+	  <td><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].to_id}&hb={$hash}&f={$difftreelines[difftree].to_file}" class="list">{$difftreelines[difftree].to_file}</a></td>
+	  <td><span class="movedfile">[moved from <a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].from_id}&hb={$hash}&f={$difftreelines[difftree].from_file}" class="list">{$difftreelines[difftree].from_file}</a> with {$difftreelines[difftree].similarity}% similarity{$difftreelines[difftree].simmodechg}]</span></td>
+	  <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$difftreelines[difftree].to_id}&hb={$hash}&f={$difftreelines[difftree].to_file}">blob</a>{if $difftreelines[difftree].to_id != $difftreelines[difftree].from_id} | <a href="{$SCRIPT_NAME}?p={$project}&a=blobdiff&h={$difftreelines[difftree].to_id}&hp={$difftreelines[difftree].from_id}&hb={$hash}&f={$difftreelines[difftree].to_file}">diff</a>{/if}</td>
+	 {/if}
 
+	 </tr>
+   {/section}
+ </table>
+

--- a/templates/commit_data.tpl
+++ /dev/null
@@ -1,46 +1,1 @@
-{*
- *  commit_data.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Commit view data template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div>
- {if $parent}
-   <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hash}" class="title">{$title}
-   {if $commitref}
-   <span class="tag">{$commitref}</span>
-   {/if}
-   </a>
- {else}
-   <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}" class="title">{$title}</a>
- {/if}
- </div>
- <div class="title_text">
- <table cellspacing="0">
- <tr><td>author</td><td>{$author}</td></tr>
- <tr><td></td><td> {$adrfc2822} ({if $adhourlocal < 6}<span class="latenight">{/if}{$adhourlocal}:{$adminutelocal}{if $adhourlocal < 6}</span>{/if} {$adtzlocal})
- </td></tr>
- <tr><td>committer</td><td>{$committer}</td></tr>
- <tr><td></td><td> {$cdrfc2822} ({$cdhourlocal}:{$cdminutelocal} {$cdtzlocal})</td></tr>
- <tr><td>commit</td><td class="monospace">{$id}</td><tr>
- <tr><td>tree</td><td class="monospace"><a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}" class="list">{$tree}</a></td>
- <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}">tree</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=snapshot&h={$hash}">snapshot</a></td></tr>
- {foreach from=$parents item=par}
- <tr><td>parent</td><td class="monospace"><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$par}" class="list">{$par}</a></td>
- <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$par}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hash}&hp={$par}">commitdiff</a></td></tr>
- {/foreach}
- </table>
- </div>
- <div class="page_body">
- {foreach from=$comment item=line}
- {$line}<br />
- {/foreach}
- </div>
- <div class="list_head">
- {if $difftreesize > 11}
-   {$difftreesize} files changed:
- {/if}
- </div>
- <table cellspacing="0">
 

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

--- a/templates/commit_item.tpl
+++ /dev/null
@@ -1,36 +1,1 @@
-{*
- *  commit_item.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Commit view item template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <tr class="{$class}">
- 
- {if $status == "A"}
-  <td><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$to_id}&hb={$hash}&f={$file}" class="list">{$file}</a></td>
-  <td><span class="newfile">[new {$to_filetype}{if $isreg} with mode: {$to_mode_cut}{/if}]</span></td>
-  <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$to_id}&hb={$hash}&f={$file}">blob</a></td>
- {elseif $status == "D"}
-  <td><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$from_id}&hb={$hash}&f={$file}" class="list">{$file}</a></td>
-  <td><span class="deletedfile">[deleted {$from_filetype}]</span></td>
-  <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$from_id}&hb={$hash}&f={$file}">blob</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=history&h={$hash}&f={$file}">history</a></td>
- {elseif $status == "M" || $status == "T"}
-  <td>
-  {if $to_id != $from_id}
-    <a href="{$SCRIPT_NAME}?p={$project}&a=blobdiff&h={$to_id}&hp={$from_id}&hb={$hash}&f={$file}" class="list">{$file}</a>
-  {else}
-    <a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$to_id}&hb={$hash}&f={$file}" class="list">{$file}</a>
-  {/if}
-  </td>
-  <td>{if $from_mode != $to_mode} <span class="changedfile">[changed{$modechange}]</span>{/if}</td>
-  <td class="link">
-  <a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$to_id}&hb={$hash}&f={$file}">blob</a>{if $to_id != $from_id} | <a href="{$SCRIPT_NAME}?p={$project}&a=blobdiff&h={$to_id}&hp={$from_id}&hb={$hash}&f={$file}">diff</a>{/if} | <a href="{$SCRIPT_NAME}?p={$project}&a=history&h={$hash}&f={$file}">history</a></td>
- {elseif $status == "R"}
-  <td><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$to_id}&hb={$hash}&f={$to_file}" class="list">{$to_file}</a></td>
-  <td><span class="movedfile">[moved from <a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$from_id}&hb={$hash}&f={$from_file}" class="list">{$from_file}</a> with {$similarity}% similarity{$simmodechg}]</span></td>
-  <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$to_id}&hb={$hash}&f={$to_file}">blob</a>{if $to_id != $from_id} | <a href="{$SCRIPT_NAME}?p={$project}&a=blobdiff&h={$to_id}&hp={$from_id}&hb={$hash}&f={$to_file}">diff</a>{/if}</td>
- {/if}
 
- </tr>
-

--- a/templates/commit_nav.tpl
+++ /dev/null
@@ -1,12 +1,1 @@
-{*
- *  commit_nav.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Commit 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> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}">log</a> | commit | {if $parent}<a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hash}">commitdiff</a> | {/if}<a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$tree}&hb={$hash}">tree</a>
- <br /><br />
- </div>
 

comments