Unify project summary template
Unify project summary template

--- a/include/display.git_summary.php
+++ b/include/display.git_summary.php
@@ -28,106 +28,46 @@
 	$tpl->clear_all_assign();
 	$tpl->assign("project",$project);
 	$tpl->assign("head",$head);
-	$tpl->display("project_nav.tpl");
-	$tpl->clear_all_assign();
 	$tpl->assign("description",$descr);
 	$tpl->assign("owner",$owner);
 	$tpl->assign("lastchange",$commitdate['rfc2822']);
-	$tpl->display("project_brief.tpl");
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
-	$tpl->display("project_revlist_header.tpl");
 	$revlist = git_read_revlist($projectroot . $project, $head, 17);
-	$alternate = FALSE;
 	foreach ($revlist as $i => $rev) {
-		$tpl->clear_all_assign();
+		$revdata = array();
 		$revco = git_read_commit($projectroot . $project, $rev);
 		$authordate = date_str($revco['author_epoch']);
-		if ($alternate)
-			$tpl->assign("class","dark");
-		else
-			$tpl->assign("class","light");
-		$alternate = !$alternate;
-		$tpl->assign("project",$project);
-		if ($i <= 16) {
-			$tpl->assign("commit",$rev);
-			if (isset($refs[$rev]))
-				$tpl->assign("commitref",$refs[$rev]);
-			$tpl->assign("commitage",$revco['age_string']);
-			$tpl->assign("commitauthor",$revco['author_name']);
-			if (strlen($revco['title_short']) < strlen($revco['title'])) {
-				$tpl->assign("title",$revco['title']);
-				$tpl->assign("title_short",$revco['title_short']);
-			} else
-				$tpl->assign("title_short",$revco['title']);
-		} else {
-			$tpl->assign("truncate",TRUE);
-		}
-		$tpl->display("project_revlist_item.tpl");
+		$revdata["commit"] = $rev;
+		if (isset($refs[$rev]))
+			$revdata["commitref"] = $refs[$rev];
+		$revdata["commitage"] = $revco['age_string'];
+		$revdata["commitauthor"] = $revco['author_name'];
+		if (strlen($revco['title_short']) < strlen($revco['title'])) {
+			$revdata["title"] = $revco['title'];
+			$revdata["title_short"] = $revco['title_short'];
+		} else
+			$revdata["title_short"] = $revco['title'];
+		$revlist[$i] = $revdata;
 	}
-	$tpl->clear_all_assign();
-	$tpl->display("project_revlist_footer.tpl");
+	$tpl->assign("revlist",$revlist);
 
 	$taglist = git_read_refs($projectroot,$project,"refs/tags");
 	if (isset($taglist) && (count($taglist) > 0)) {
-		$tpl->clear_all_assign();
-		$tpl->assign("project",$project);
-		$tpl->display("project_taglist_header.tpl");
-		$alternate = FALSE;
 		foreach ($taglist as $i => $tag) {
-			$tpl->clear_all_assign();
-			$tpl->assign("project",$project);
-			if ($alternate)
-				$tpl->assign("class","dark");
-			else
-				$tpl->assign("class","light");
-			$alternate = !$alternate;
-			if ($i < 16) {
-				$tpl->assign("tagage",$tag['age']);
-				$tpl->assign("tagname",$tag['name']);
-				$tpl->assign("tagid",$tag['id']);
-				$tpl->assign("tagtype",$tag['type']);
-				$tpl->assign("refid",$tag['refid']);
-				$tpl->assign("reftype",$tag['reftype']);
-				if (isset($tag['comment'])) {
-					$com = trim($tag['comment'][0]);
-					if (strlen($com) > GITPHP_TRIM_LENGTH)
-						$com = substr($trimmed,0,GITPHP_TRIM_LENGTH) . "...";
-					$tpl->assign("comment",$com);
-				}
-			} else
-				$tpl->assign("truncate",TRUE);
-			$tpl->display("project_taglist_item.tpl");
+			if (isset($tag['comment'])) {
+				$com = trim($tag['comment'][0]);
+				if (strlen($com) > GITPHP_TRIM_LENGTH)
+					$com = substr($trimmed,0,GITPHP_TRIM_LENGTH) . "...";
+				$taglist[$i]['comment'] = $com;
+			}
 		}
-		$tpl->clear_all_assign();
-		$tpl->display("project_taglist_footer.tpl");
+		$tpl->assign("taglist",$taglist);
 	}
 
 	$headlist = git_read_refs($projectroot,$project,"refs/heads");
 	if (isset($headlist) && (count($headlist) > 0)) {
-		$tpl->clear_all_assign();
-		$tpl->assign("project",$project);
-		$tpl->display("project_headlist_header.tpl");
-		$alternate = FALSE;
-		foreach ($headlist as $i => $head) {
-			$tpl->clear_all_assign();
-			$tpl->assign("project",$project);
-			if ($alternate)
-				$tpl->assign("class","dark");
-			else
-				$tpl->assign("class","light");
-			$alternate = !$alternate;
-			if ($i < 16) {
-				$tpl->assign("headage",$head['age']);
-				$tpl->assign("headname",$head['name']);
-			} else
-				$tpl->assign("truncate",TRUE);
-			$tpl->display("project_headlist_item.tpl");
-		}
-
-		$tpl->clear_all_assign();
-		$tpl->display("project_headlist_footer.tpl");
+		$tpl->assign("headlist",$headlist);
 	}
+	$tpl->display("project.tpl");
 }
 
 ?>

--- /dev/null
+++ b/templates/project.tpl
@@ -1,1 +1,89 @@
+{*
+ *  project.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Project template
+ *
+ *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
+ *}
+ <div class="page_nav">
+   summary | <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={$head}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$head}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree">tree</a>
+   <br /><br />
+ </div>
+ <div class="title">&nbsp;</div>
+ <table cellspacing="0">
+   <tr><td>description</td><td>{$description}</td></tr>
+   <tr><td>owner</td><td>{$owner}</td></tr>
+   <tr><td>last change</td><td>{$lastchange}</td></tr>
+ </table>
+ <div>
+   <a class="title" href="{$SCRIPT_NAME}?p={$project}&a=shortlog">shortlog</a>
+ </div>
+ <table cellspacing="0">
+   {section name=rev max=17 loop=$revlist}
+     {if $smarty.section.rev.index == 16}
+       <tr class="light">
+         <td><a href="{$SCRIPT_NAME}?p={$project}&a=shortlog">...</a></td>
+       </tr>
+     {else}
+         <tr class="{cycle name=revs values="light,dark"}">
+         <td><i>{$revlist[rev].commitage}</i></td>
+         <td><i>{$revlist[rev].commitauthor}</i></td>
+         <td>
+           <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$revlist[rev].commit}" class="list" {if $revlist[rev].title}title="{$revlist[rev].title}"{/if}><b>{$revlist[rev].title_short}
+             {if $revlist[rev].commitref}
+               <span class="tag">{$revlist[rev].commitref}</span>
+             {/if}
+           </b>
+         </td>
+         <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$revlist[rev].commit}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$revlist[rev].commit}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$revlist[rev].commit}&hb={$revlist[rev].commit}">tree</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=snapshot&h={$revlist[rev].commit}">snapshot</a></td>
+       </tr>
+     {/if}
+   {/section}
+ </table>
+ {if $taglist}
+   <div>
+     <a href="{$SCRIPT_NAME}?p={$project}&a=tags" class="title">tags</a>
+   </div>
+   <table cellspacing="0">
+     {section name=tag max=17 loop=$taglist}
+       <tr class="{cycle name=tags values="light,dark"}">
+         {if $smarty.section.tag.index == 16}
+           <td><a href="{$SCRIPT_NAME}?p={$project}&a=tags">...</a></td>
+         {else}
+           <td><i>{$taglist[tag].age}</i></td>
+           <td><a href="{$SCRIPT_NAME}?p={$project}&a={$taglist[tag].reftype}&h={$taglist[tag].refid}" class="list"><b>{$taglist[tag].name}</b></a></td>
+           <td>
+             {if $taglist[tag].comment}
+               <a class="list" href="{$SCRIPT_NAME}?p={$project}&a=tag&h={$taglist[tag].id}">{$taglist[tag].comment}</a>
+             {/if}
+           </td>
+           <td class="link">
+             {if $taglist[tag].type == "tag"}
+   	       <a href="{$SCRIPT_NAME}?p={$project}&a=tag&h={$taglist[tag].id}">tag</a> | 
+             {/if}
+             <a href="{$SCRIPT_NAME}?p={$project}&a={$taglist[tag].reftype}&h={$taglist[tag].refid}">{$taglist[tag].reftype}</a>{if $taglist[tag].reftype == "commit"} | <a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h=refs/tags/{$taglist[tag].name}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h=refs/tags/{$taglist[tag].name}">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=snapshot&h={$taglist[tag].refid}">snapshot</a>{/if}
+           </td>
+         {/if}
+       </tr>
+     {/section}
+   </table>
+ {/if}
+ {if $headlist}
+   <div>
+     <a href="{$SCRIPT_NAME}?p={$project}&a=heads" class="title">heads</a>
+   </div>
+   <table cellspacing="0">
+     {section name=head max=17 loop=$headlist}
+       <tr class="{cycle name=heads values="light,dark"}">
+         {if $smarty.section.head.index == 16}
+           <td><a href="{$SCRIPT_NAME}?p={$project}&a=heads">...</a></td>
+         {else}
+           <td><i>{$headlist[head].age}</i></td>
+           <td><a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h=refs/heads/{$headlist[head].name}" class="list"><b>{$headlist[head].name}</b></td>
+           <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h=refs/heads/{$headlist[head].name}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h=refs/heads/{$headlist[head].name}">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h=refs/heads/{$headlist[head].name}&hb={$headlist[head].name}">tree</a></td>
+         {/if}
+       </tr>
+     {/section}
+   </table>
+ {/if}
 

--- a/templates/project_brief.tpl
+++ /dev/null
@@ -1,14 +1,1 @@
-{*
- *  project_brief.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Project brief info template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div class="title">&nbsp;</div>
- <table cellspacing="0">
- <tr><td>description</td><td>{$description}</td></tr>
- <tr><td>owner</td><td>{$owner}</td></tr>
- <tr><td>last change</td><td>{$lastchange}</td></tr>
- </table>
 

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

--- a/templates/project_headlist_header.tpl
+++ /dev/null
@@ -1,12 +1,1 @@
-{*
- *  project_headlist_header.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Project head list header template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div>
- <a href="{$SCRIPT_NAME}?p={$project}&a=heads" class="title">heads</a>
- </div>
- <table cellspacing="0">
 

--- a/templates/project_headlist_item.tpl
+++ /dev/null
@@ -1,17 +1,1 @@
-{*
- *  project_headlist_item.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Project head list item template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <tr class="{$class}">
- {if $truncate}
-   <td><a href="{$SCRIPT_NAME}?p={$project}&a=heads">...</a></td>
- {else}
-   <td><i>{$headage}</i></td>
-   <td><a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h=refs/heads/{$headname}" class="list"><b>{$headname}</b></td>
-   <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h=refs/heads/{$headname}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h=refs/heads/{$headname}">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h=refs/heads/{$headname}&hb={$headname}">tree</a></td>
- {/if}
- </tr>
 

--- a/templates/project_nav.tpl
+++ /dev/null
@@ -1,12 +1,1 @@
-{*
- *  project_nav.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Project navbar template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div class="page_nav">
- summary | <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={$head}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$head}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree">tree</a>
- <br /><br />
- </div>
 

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

--- a/templates/project_revlist_header.tpl
+++ /dev/null
@@ -1,12 +1,1 @@
-{*
- *  project_revlist_header.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Project revision list header template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div>
- <a class="title" href="{$SCRIPT_NAME}?p={$project}&a=shortlog">shortlog</a>
- </div>
- <table cellspacing="0">
 

--- a/templates/project_revlist_item.tpl
+++ /dev/null
@@ -1,25 +1,1 @@
-{*
- *  project_revlist_item.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Project revision list item template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- {if $truncate}
- <tr class="light">
-  <td><a href="{$SCRIPT_NAME}?p={$project}&a=shortlog">...</td>
- {else}
- <tr class="{$class}">
-  <td><i>{$commitage}</i></td>
-  <td><i>{$commitauthor}</i></td>
-  <td>
-  <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$commit}" class="list" {if $title}title="{$title}"{/if}><b>{$title_short}
-  {if $commitref}
-  <span class="tag">{$commitref}</span>
-  {/if}
-  </b>
-  </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=tree&h={$commit}&hb={$commit}">tree</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=snapshot&h={$commit}">snapshot</a></td>
-  </tr>
- {/if}
 

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

--- a/templates/project_taglist_header.tpl
+++ /dev/null
@@ -1,12 +1,1 @@
-{*
- *  project_taglist_header.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Project tag list header template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div>
- <a href="{$SCRIPT_NAME}?p={$project}&a=tags" class="title">tags</a>
- </div>
- <table cellspacing="0">
 

--- a/templates/project_taglist_item.tpl
+++ /dev/null
@@ -1,27 +1,1 @@
-{*
- *  project_taglist_item.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Project tag list item template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <tr class="{$class}">
- {if $truncate}
-   <td><a href="{$SCRIPT_NAME}?p={$project}&a=tags">...</a></td>
- {else}
-   <td><i>{$tagage}</i></td>
-   <td><a href="{$SCRIPT_NAME}?p={$project}&a={$reftype}&h={$refid}" class="list"><b>{$tagname}</b></a></td>
-   <td>
-   {if $comment}
-     <a class="list" href="{$SCRIPT_NAME}?p={$project}&a=tag&h={$tagid}">{$comment}</a>
-   {/if}
-   </td>
-   <td class="link">
-   {if $tagtype == "tag"}
-   	<a href="{$SCRIPT_NAME}?p={$project}&a=tag&h={$tagid}">tag</a> | 
-   {/if}
-   <a href="{$SCRIPT_NAME}?p={$project}&a={$reftype}&h={$refid}">{$reftype}</a>{if $reftype == "commit"} | <a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h=refs/tags/{$tagname}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h=refs/tags/{$tagname}">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=snapshot&h={$refid}">snapshot</a>{/if}
-   </td>
- {/if}
- </tr>
 

comments