Use global assigns for headers/footers and to avoid duplication
Use global assigns for headers/footers and to avoid duplication

--- a/config/gitphp.conf.php.example
+++ b/config/gitphp.conf.php.example
@@ -169,6 +169,13 @@
 $gitphp_conf['filesearch'] = TRUE;
 
 /*
+ * debug
+ * Turns on extra warning messages and benchmarking.
+ * Not recommended for production systems
+ */
+$gitphp_conf['debug'] = FALSE;
+
+/*
  * git_projects
  * Two-dimensional array list of projects
  * First array index is the name of the category the projects

--- a/include/display.git_blob.php
+++ b/include/display.git_blob.php
@@ -23,9 +23,7 @@
 	if (!isset($hash) && isset($file))
 		$hash = git_get_hash_by_path($projectroot . $project, $hashbase,$file,"blob");
 	$catout = git_cat_file($projectroot . $project, $hash);
-	$tpl->clear_all_assign();
 	$tpl->assign("hash",$hash);
-	$tpl->assign("project",$project);
 	$tpl->assign("hashbase",$hashbase);
 	if ($co = git_read_commit($projectroot . $project, $hashbase)) {
 		$tpl->assign("fullnav",TRUE);

--- a/include/display.git_blobdiff.php
+++ b/include/display.git_blobdiff.php
@@ -21,11 +21,9 @@
 		echo $ret;
 		return;
 	}
-	$tpl->clear_all_assign();
 	$tpl->assign("hash",$hash);
 	$tpl->assign("hashparent",$hashparent);
 	$tpl->assign("hashbase",$hashbase);
-	$tpl->assign("project",$project);
 	if (isset($file))
 		$tpl->assign("file",$file);
 	if ($co = git_read_commit($projectroot . $project, $hashbase)) {

--- a/include/display.git_commit.php
+++ b/include/display.git_commit.php
@@ -28,8 +28,6 @@
 	}
 	$diffout = git_diff_tree($projectroot . $project, $root . " " . $parent . " " . $hash, TRUE);
 	$difftree = explode("\n",$diffout);
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
 	$tpl->assign("hash",$hash);
 	$tpl->assign("tree",$co['tree']);
 	if (isset($co['parent']))

--- a/include/display.git_commitdiff.php
+++ b/include/display.git_commitdiff.php
@@ -28,8 +28,6 @@
 	$diffout = git_diff_tree($projectroot . $project, $hash_parent . " " . $hash);
 	$difftree = explode("\n",$diffout);
 	$refs = read_info_ref($projectroot . $project);
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
 	$tpl->assign("hash",$hash);
 	$tpl->assign("tree",$co['tree']);
 	$tpl->assign("hashparent",$hash_parent);

--- a/include/display.git_commitdiff_plain.php
+++ b/include/display.git_commitdiff_plain.php
@@ -42,7 +42,6 @@
 	header("Content-type: text/plain; charset=UTF-8");
 	header("Content-disposition: inline; filename=\"git-" . $hash . ".patch\"");
 	$ad = date_str($co['author_epoch'],$co['author_tz']);
-	$tpl->clear_all_assign();
 	$tpl->assign("from",$co['author']);
 	$tpl->assign("date",$ad['rfc2822']);
 	$tpl->assign("subject",$co['title']);

--- a/include/display.git_heads.php
+++ b/include/display.git_heads.php
@@ -14,8 +14,6 @@
 {
 	global $tpl;
 	$head = git_read_head($projectroot . $project);
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
 	$tpl->assign("head",$head);
 	$headlist = git_read_refs($projectroot, $project, "refs/heads");
 	$tpl->assign("headlist",$headlist);

--- a/include/display.git_history.php
+++ b/include/display.git_history.php
@@ -21,8 +21,6 @@
 		$hash = git_read_head($projectroot . $project);
 	$co = git_read_commit($projectroot . $project, $hash);
 	$refs = read_info_ref($projectroot . $project);
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
 	$tpl->assign("hash",$hash);
 	if (isset($refs[$hash]))
 		$tpl->assign("hashbaseref",$refs[$hash]);

--- a/include/display.git_log.php
+++ b/include/display.git_log.php
@@ -22,8 +22,6 @@
 	if (!isset($page))
 		$page = 0;
 	$refs = read_info_ref($projectroot . $project);
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
 	$tpl->assign("hash",$hash);
 	$tpl->assign("head",$head);
 

--- /dev/null
+++ b/include/display.git_message.php
@@ -1,1 +1,20 @@
+<?php
+/*
+ *  display.git_message.php
+ *  gitphp: A PHP git repository browser
+ *  Component: Display - message
+ *
+ *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
+ */
 
+function git_message($message, $error = FALSE)
+{
+	global $tpl;
+	$tpl->assign("message",$message);
+	if ($error)
+		$tpl->assign("error", TRUE);
+	$tpl->display("message.tpl");
+}
+
+?>
+

--- a/include/display.git_opml.php
+++ b/include/display.git_opml.php
@@ -15,7 +15,6 @@
 	global $tpl,$gitphp_conf;
 	$projlist = git_read_projects($projectroot,$projectlist);
 	header("Content-type: text/xml; charset=UTF-8");
-	$tpl->clear_all_assign();
 	$tpl->assign("title",$gitphp_conf['title']);
 	$tpl->assign("self",script_url());
 	$opmllist = array();

--- a/include/display.git_project_list.php
+++ b/include/display.git_project_list.php
@@ -19,7 +19,6 @@
 	$projects = git_read_projects($projectroot,$projectlist, TRUE);
 	if (is_array($projects)) {
 		if (count($projects) > 0) {
-			$tpl->clear_all_assign();
 			if ($order)
 				$tpl->assign("order",$order);
 			if (!isset($git_projects)) {
@@ -57,10 +56,14 @@
 				}
 				$tpl->assign("categorizedprojects",$projects);
 			}
-		} else
-			$tpl->assign("errmsg","No projects found");
-	} else
-		$tpl->assign("errmsg",$projects);
+		} else {
+			$tpl->assign("message","No projects found");
+			$tpl->assign("error",TRUE);
+		}
+	} else {
+		$tpl->assign("message",$projects);
+		$tpl->assign("error",TRUE);
+	}
 	$tpl->display("projectlist.tpl");
 }
 

--- a/include/display.git_rss.php
+++ b/include/display.git_rss.php
@@ -21,9 +21,7 @@
 	$head = git_read_head($projectroot . $project);
 	$revlist = git_read_revlist($projectroot . $project, $head, GITPHP_RSS_ITEMS);
 	header("Content-type: text/xml; charset=UTF-8");
-	$tpl->clear_all_assign();
 	$tpl->assign("self",script_url());
-	$tpl->assign("project",$project);
 
 	$commitlines = array();
 	for ($i = 0; $i <= count($revlist); $i++) {

--- a/include/display.git_search.php
+++ b/include/display.git_search.php
@@ -16,7 +16,6 @@
 {
 	global $tpl,$gitphp_conf;
 
-	$tpl->clear_all_assign();
 	if (!$gitphp_conf['search']) {
 		$tpl->assign("message","Search has been disabled");
 		$tpl->display("message.tpl");
@@ -43,7 +42,6 @@
 		return;
 	}
 
-	$tpl->assign("project",$project);
 	$tpl->assign("hash",$hash);
 	$tpl->assign("treehash",$co['tree']);
 

--- a/include/display.git_search_files.php
+++ b/include/display.git_search_files.php
@@ -16,7 +16,6 @@
 {
 	global $tpl,$gitphp_conf;
 
-	$tpl->clear_all_assign();
 	if (!($gitphp_conf['search'] && $gitphp_conf['filesearch'])) {
 		$tpl->assign("message","File search has been disabled");
 		$tpl->display("message.tpl");
@@ -44,7 +43,6 @@
 		return;
 	}
 
-	$tpl->assign("project",$project);
 	$tpl->assign("hash",$hash);
 	$tpl->assign("treehash",$co['tree']);
 

--- a/include/display.git_shortlog.php
+++ b/include/display.git_shortlog.php
@@ -22,8 +22,6 @@
 	if (!isset($page))
 		$page = 0;
 	$refs = read_info_ref($projectroot . $project);
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
 	$tpl->assign("hash",$hash);
 	$tpl->assign("head",$head);
 

--- a/include/display.git_summary.php
+++ b/include/display.git_summary.php
@@ -25,8 +25,6 @@
 	$commitdate = date_str($commit['committer_epoch'],$commit['committer_tz']);
 	$owner = git_project_owner($projectroot,$project);
 	$refs = read_info_ref($projectroot . $project);
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
 	$tpl->assign("head",$head);
 	$tpl->assign("description",$descr);
 	$tpl->assign("owner",$owner);

--- a/include/display.git_tag.php
+++ b/include/display.git_tag.php
@@ -16,29 +16,17 @@
 	global $tpl;
 
 	$head = git_read_head($projectroot . $project);
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
 	$tpl->assign("head",$head);
-	$tpl->display("tag_nav.tpl");
+	$tpl->assign("hash", $hash);
 
 	$tag = git_read_tag($projectroot . $project, $hash);
 
-	$tpl->clear_all_assign();
-	$tpl->assign("project", $project);
-	$tpl->assign("hash", $hash);
-	$tpl->assign("title",$tag['name']);
-	$tpl->assign("type",$tag['type']);
-	$tpl->assign("object",$tag['object']);
+	$tpl->assign("tag",$tag);
 	if (isset($tag['author'])) {
-		$tpl->assign("author",$tag['author']);
 		$ad = date_str($tag['epoch'],$tag['tz']);
-		$tpl->assign("adrfc2822",$ad['rfc2822']);
-		$tpl->assign("adhourlocal",$ad['hour_local']);
-		$tpl->assign("adminutelocal",$ad['minute_local']);
-		$tpl->assign("adtzlocal",$ad['tz_local']);
+		$tpl->assign("datedata",$ad);
 	}
-	$tpl->assign("comment",$tag['comment']);
-	$tpl->display("tag_data.tpl");
+	$tpl->display("tag.tpl");
 }
 
 ?>

--- a/include/display.git_tags.php
+++ b/include/display.git_tags.php
@@ -14,35 +14,12 @@
 {
 	global $tpl;
 	$head = git_read_head($projectroot . $project);
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
 	$tpl->assign("head",$head);
-	$tpl->display("tags_nav.tpl");
-	$tpl->display("tags_header.tpl");
 	$taglist = git_read_refs($projectroot, $project, "refs/tags");
 	if (isset($taglist) && (count($taglist) > 0)) {
-		$alternate = FALSE;
-		foreach ($taglist as $i => $entry) {
-			$tpl->clear_all_assign();
-			if ($alternate)
-				$tpl->assign("class","dark");
-			else
-				$tpl->assign("class","light");
-			$alternate = !$alternate;
-			$tpl->assign("project",$project);
-			$tpl->assign("age",$entry['age']);
-			$tpl->assign("name",$entry['name']);
-			$tpl->assign("reftype",$entry['reftype']);
-			$tpl->assign("refid",$entry['refid']);
-			$tpl->assign("id",$entry['id']);
-			$tpl->assign("type",$entry['type']);
-			if (isset($entry['comment']) && isset($entry['comment'][0]))
-				$tpl->assign("comment",$entry['comment'][0]);
-			$tpl->display("tags_item.tpl");
-		}
+		$tpl->assign("taglist",$taglist);
 	}
-	$tpl->clear_all_assign();
-	$tpl->display("tags_footer.tpl");
+	$tpl->display("tags.tpl");
 }
 
 ?>

--- a/include/display.git_tree.php
+++ b/include/display.git_tree.php
@@ -27,52 +27,37 @@
 	}
 	$lsout = git_ls_tree($projectroot . $project, $hash, TRUE);
 	$refs = read_info_ref($projectroot . $project);
-	$tpl->clear_all_assign();
+	$tpl->assign("hash",$hash);
+	if (isset($hashbase))
+		$tpl->assign("hashbase",$hashbase);
 	if (isset($hashbase) && ($co = git_read_commit($projectroot . $project, $hashbase))) {
 		$basekey = $hashbase;
-		$tpl->assign("hashbase",$hashbase);
-		$tpl->assign("project",$project);
+		$tpl->assign("fullnav",TRUE);
 		$tpl->assign("title",$co['title']);
 		if (isset($refs[$hashbase]))
 			$tpl->assign("hashbaseref",$refs[$hashbase]);
-		$tpl->display("tree_nav.tpl");
-	} else {
-		$tpl->assign("hash",$hash);
-		$tpl->display("tree_emptynav.tpl");
 	}
-	$tpl->clear_all_assign();
-	$tpl->assign("project",$project);
-	$tpl->assign("hashbase",$hashbase);
 	$paths = git_path_trees($projectroot . $project, $hashbase, $file);
 	$tpl->assign("paths",$paths);
-	$tpl->display("tree_filelist_header.tpl");
 
+	if (isset($file))
+		$tpl->assign("base",$file . "/");
+
+	$treelines = array();
 	$tok = strtok($lsout,"\0");
-	$alternate = FALSE;
 	while ($tok !== false) {
 		if (ereg("^([0-9]+) (.+) ([0-9a-fA-F]{40})\t(.+)$",$tok,$regs)) {
-			$tpl->clear_all_assign();
-			if ($alternate)
-				$tpl->assign("class","dark");
-			else
-				$tpl->assign("class","light");
-			$alternate = !$alternate;
-			$tpl->assign("filemode",mode_str($regs[1]));
-			$tpl->assign("type",$regs[2]);
-			$tpl->assign("hash",$regs[3]);
-			$tpl->assign("name",$regs[4]);
-			$tpl->assign("project",$project);
-			if (isset($file))
-				$tpl->assign("base",$file . "/");
-			if (isset($basekey))
-				$tpl->assign("hashbase",$basekey);
-			$tpl->display("tree_filelist_item.tpl");
+			$treeline = array();
+			$treeline["filemode"] = mode_str($regs[1]);
+			$treeline["type"] = $regs[2];
+			$treeline["hash"] = $regs[3];
+			$treeline["name"] = $regs[4];
+			$treelines[] = $treeline;
 		}
 		$tok = strtok("\0");
 	}
-
-	$tpl->clear_all_assign();
-	$tpl->display("tree_filelist_footer.tpl");
+	$tpl->assign("treelines",$treelines);
+	$tpl->display("tree.tpl");
 }
 
 ?>

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -24,6 +24,14 @@
  require_once('config/gitphp.conf.php');
 
  /*
+  * Debug
+  */
+ if ($gitphp_conf['debug']) {
+ 	define('GITPHP_START_TIME', microtime(true));
+	error_reporting(E_ALL|E_STRICT);
+ }
+
+ /*
   * Instantiate Smarty
   */
  require_once($gitphp_conf['smarty_prefix'] . "Smarty.class.php");
@@ -32,12 +40,40 @@
      ($_GET['a'] != "commitdiff_plain") &&
      ($_GET['a'] != "blob_plain") &&
      ($_GET['a'] != "blobdiff_plain") &&
+     ($_GET['a'] != "rss") &&
      ($_GET['a'] != "opml")) {
 	$tpl->load_filter('output','trimwhitespace');
 }
 
-
- $rss_link = FALSE;
+/*
+ * Setup global assigns used everywhere (such as header/footer)
+ */
+ $tpl->assign("stylesheet",$gitphp_conf['stylesheet']);
+ $tpl->assign("version",$gitphp_version);
+ $tpl->assign("pagetitle",$gitphp_conf['title']);
+ if (isset($_GET['p'])) {
+	$tpl->assign("validproject",TRUE);
+	$tpl->assign("project",$_GET['p']);
+	require_once('include/gitutil.git_project_descr.php');
+	$tpl->assign("projectdescription",git_project_descr($gitphp_conf['projectroot'],$_GET['p']));
+	if (isset($_GET['a']))
+		$tpl->assign("action",$_GET['a']);
+ }
+ if (isset($_GET['st']))
+ 	$tpl->assign("currentsearchtype",$_GET['st']);
+ else
+	$tpl->assign("currentsearchtype","commit");
+if (isset($_GET['s']))
+	$tpl->assign("currentsearch",$_GET['s']);
+if (isset($_GET['hb']))
+	$tpl->assign("currentsearchhash",$_GET['hb']);
+else if (isset($_GET['h']))
+	$tpl->assign("currentsearchhash",$_GET['h']);
+if ($gitphp_conf['search'])
+	$tpl->assign("enablesearch",TRUE);
+if ($gitphp_conf['filesearch'])
+	$tpl->assign("filesearch",TRUE);
+
  $suppress_headers = FALSE;
 
  ob_start();
@@ -50,12 +86,15 @@
 	require_once('include/display.git_project_index.php');
 	git_project_index($gitphp_conf['projectroot'],$git_projects);
  } else if (isset($_GET['p'])) {
- 	if (!is_dir($gitphp_conf['projectroot'] . $_GET['p']))
-		echo "No such directory";
-	else if (!is_file($gitphp_conf['projectroot'] . $_GET['p'] . "/HEAD"))
-		echo "No such project";
-	else {
-		$rss_link = TRUE;
+ 	if (!is_dir($gitphp_conf['projectroot'] . $_GET['p'])) {
+		$tpl->assign("validproject",FALSE);
+		require_once('include/display.git_message.php');
+		git_message("No such directory",TRUE);
+	} else if (!is_file($gitphp_conf['projectroot'] . $_GET['p'] . "/HEAD")) {
+		$tpl->assign("validproject",FALSE);
+		require_once('include/display.git_message.php');
+		git_message("No such project",TRUE);
+	} else {
 		if (!isset($_GET['a'])) {
 			require_once('include/display.git_summary.php');
 			git_summary($gitphp_conf['projectroot'],$_GET['p']);
@@ -144,7 +183,8 @@
 					git_tag($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']);
 					break;
 				default:
-					echo "Unknown action";
+					require_once('include/display.git_message.php');
+					git_message("Unknown action", TRUE);
 					break;
 			}
 		}
@@ -158,48 +198,18 @@
  ob_end_clean();
 
  if (!$suppress_headers) {
-	 $tpl->clear_all_assign();
-	 $tpl->assign("stylesheet",$gitphp_conf['stylesheet']);
-	 $tpl->assign("version",$gitphp_version);
-	 $title = $gitphp_conf['title'];
-	 if ($rss_link) {
-		$tpl->assign("rss_link",TRUE);
-		$tpl->assign("project",$_GET['p']);
-		$title .= " :: " . $_GET['p'];
-		if (isset($_GET['a'])) {
-			$tpl->assign("action",$_GET['a']);
-			$title .= "/" . $_GET['a'];
-		}
-	 }
-	 $tpl->assign("title",$title);
-	 if (isset($_GET['st']))
-	 	$tpl->assign("searchtype",$_GET['st']);
-	else
-		$tpl->assign("searchtype","commit");
-	if (isset($_GET['s']))
-		$tpl->assign("search",$_GET['s']);
-	if (isset($_GET['hb']))
-		$tpl->assign("hash",$_GET['hb']);
-	else if (isset($_GET['h']))
-		$tpl->assign("hash",$_GET['h']);
-	if ($gitphp_conf['search'])
-		$tpl->assign("enablesearch",TRUE);
-	if ($gitphp_conf['filesearch'])
-		$tpl->assign("filesearch",TRUE);
 	 $tpl->display("header.tpl");
  }
 
  echo $main;
 
  if (!$suppress_headers) {
-	 if ($rss_link) {
-		$tpl->assign("project",$_GET['p']);
-		require_once('include/gitutil.git_project_descr.php');
-		$tpl->assign("descr",git_project_descr($gitphp_conf['projectroot'],$_GET['p']));
-	 }
 	 $tpl->display("footer.tpl");
  }
 
+ if ($gitphp_conf['debug'])
+ 	echo "Execution time: " . round(microtime(true) - GITPHP_START_TIME, 8) . " sec";
+
  ob_end_flush();
 
 ?>

--- a/templates/footer.tpl
+++ b/templates/footer.tpl
@@ -5,17 +5,19 @@
  *
  *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
  *}
-<div class="page_footer">
-{if $project}
-  {if $descr}
-    <div class="page_footer_text">{$descr}</div>
-  {/if}
-  <a href="{$SCRIPT_NAME}?p={$project}&a=rss" class="rss_logo">RSS</a>
-{else}
-  <a href="{$SCRIPT_NAME}?a=opml" class="rss_logo">OPML</a>
-  <a href="{$SCRIPT_NAME}?a=project_index" class="rss_logo">TXT</a>
-{/if}
-</div>
-</body>
+    <div class="page_footer">
+      {if $project}
+        {if $projectdescription}
+          <div class="page_footer_text">{$projectdescription}</div>
+        {/if}
+	{if $validproject}
+          <a href="{$SCRIPT_NAME}?p={$project}&a=rss" class="rss_logo">RSS</a>
+	{/if}
+      {else}
+        <a href="{$SCRIPT_NAME}?a=opml" class="rss_logo">OPML</a>
+        <a href="{$SCRIPT_NAME}?a=project_index" class="rss_logo">TXT</a>
+      {/if}
+    </div>
+  </body>
 </html>
 

--- a/templates/header.tpl
+++ b/templates/header.tpl
@@ -10,43 +10,43 @@
 <?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-<!-- gitphp web interface {$version}, (C) 2006 Christopher Han <xiphux@gmail.com> -->
-<head>
-<title>{$title}</title>
-{if $rss_link}
-<link rel="alternate" title="{$project} log" href="{$SCRIPT_NAME}?p={$project}&a=rss" type="application/rss+xml" />
-{/if}
-<link rel="stylesheet" href="{$stylesheet}" type="text/css" />
-{$smarty.capture.header}
-</head>
-<body>
-<div class="page_header">
-<a href="http://www.kernel.org/pub/software/scm/git/docs/" title="git documentation">
-<img src="git-logo.png" width="72" height="27" alt="git" class="logo" />
-</a>
-<a href="index.php">projects</a> / 
-{if $project}
-  <a href="{$SCRIPT_NAME}?p={$project}&a=summary">{$project}</a>
-  {if $action}
-    / {$action}
-  {/if}
-  {if $enablesearch}
-<form method="get" action="index.php" enctype="application/x-www-form-urlencoded">
-<div class="search">
-<input type="hidden" name="p" value="{$project}" />
-<input type="hidden" name="a" value="search" />
-<input type="hidden" name="h" value="{if $hash}{$hash}{else}HEAD{/if}" />
-<select name="st">
-<option {if $searchtype == 'commit'}selected="selected"{/if} value="commit">commit</option>
-<option {if $searchtype == 'author'}selected="selected"{/if} value="author">author</option>
-<option {if $searchtype == 'committer'}selected="selected"{/if} value="committer">committer</option>
-{if $filesearch}
-<option {if $searchtype == 'file'}selected="selected"{/if} value="file">file</option>
-{/if}
-</select> search: <input type="text" name="s" {if $search}value="{$search}"{/if} />
-</div>
-</form>
-  {/if}
-{/if}
-</div>
+  <!-- gitphp web interface {$version}, (C) 2006 Christopher Han <xiphux@gmail.com> -->
+  <head>
+    <title>{$pagetitle}{if $project && $validproject} :: {$project}{if $action}/{$action}{/if}{/if}</title>
+    {if $validproject}
+      <link rel="alternate" title="{$project} log" href="{$SCRIPT_NAME}?p={$project}&a=rss" type="application/rss+xml" />
+    {/if}
+    <link rel="stylesheet" href="{$stylesheet}" type="text/css" />
+    {$smarty.capture.header}
+  </head>
+  <body>
+    <div class="page_header">
+      <a href="http://www.kernel.org/pub/software/scm/git/docs/" title="git documentation">
+        <img src="git-logo.png" width="72" height="27" alt="git" class="logo" />
+      </a>
+      <a href="index.php">projects</a> / 
+      {if $project && $validproject}
+        <a href="{$SCRIPT_NAME}?p={$project}&a=summary">{$project}</a>
+        {if $action}
+           / {$action}
+        {/if}
+        {if $enablesearch}
+          <form method="get" action="index.php" enctype="application/x-www-form-urlencoded">
+            <div class="search">
+              <input type="hidden" name="p" value="{$project}" />
+              <input type="hidden" name="a" value="search" />
+              <input type ="hidden" name="h" value="{if $currentsearchhash}{$currentsearchhash}{else}HEAD{/if}" />
+              <select name="st">
+                <option {if $currentsearchtype == 'commit'}selected="selected"{/if} value="commit">commit</option>
+                <option {if $currentsearchtype == 'author'}selected="selected"{/if} value="author">author</option>
+                <option {if $currentsearchtype == 'committer'}selected="selected"{/if} value="committer">committer</option>
+                {if $filesearch}
+                  <option {if $currentsearchtype == 'file'}selected="selected"{/if} value="file">file</option>
+                {/if}
+              </select> search: <input type="text" name="s" {if $currentsearch}value="{$currentsearch}"{/if} />
+            </div>
+          </form>
+        {/if}
+      {/if}
+    </div>
 

--- a/templates/message.tpl
+++ b/templates/message.tpl
@@ -1,7 +1,7 @@
 {*
- *  error.tpl
+ *  message.tpl
  *  gitphp: A PHP git repository browser
- *  Component: Error message template
+ *  Component: Warning/error message template
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}

--- a/templates/project.tpl
+++ b/templates/project.tpl
@@ -1,15 +1,17 @@
 {*
  *  project.tpl
  *  gitphp: A PHP git repository browser
- *  Component: Project template
+ *  Component: Project summary template
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
+ {* Nav *}
  <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>
+ {* Project brief *}
  <table cellspacing="0">
    <tr><td>description</td><td>{$description}</td></tr>
    <tr><td>owner</td><td>{$owner}</td></tr>
@@ -19,6 +21,7 @@
    <a class="title" href="{$SCRIPT_NAME}?p={$project}&a=shortlog">shortlog</a>
  </div>
  <table cellspacing="0">
+   {* Recent revisions *}
    {section name=rev max=17 loop=$revlist}
      {if $smarty.section.rev.index == 16}
        <tr class="light">
@@ -41,6 +44,7 @@
    {/section}
  </table>
  {if $taglist}
+   {* Tags *}
    <div>
      <a href="{$SCRIPT_NAME}?p={$project}&a=tags" class="title">tags</a>
    </div>
@@ -69,6 +73,7 @@
    </table>
  {/if}
  {if $headlist}
+   {* Heads *}
    <div>
      <a href="{$SCRIPT_NAME}?p={$project}&a=heads" class="title">heads</a>
    </div>

--- a/templates/projectlist.tpl
+++ b/templates/projectlist.tpl
@@ -5,9 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{if $errmsg}
+{if $message}
   {* Something is wrong; display an error message instead of trying to list *}
-  {$errmsg}
+  {include file='message.tpl'}
 {else}
   <table cellspacing="0">
     {* Header *}

--- a/templates/shortlog.tpl
+++ b/templates/shortlog.tpl
@@ -5,6 +5,7 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
+ {* Nav *}
  <div class="page_nav">
    <a href="{$SCRIPT_NAME}?p={$project}&a=summary">summary</a> | shortlog | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}">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={$hash}&hb={$hash}">tree</a>
    <br />
@@ -31,6 +32,7 @@
    <a href="{$SCRIPT_NAME}?p={$project}&a=summary" class="title">&nbsp;</a>
  </div>
  <table cellspacing="0">
+   {* Display each log entry *}
    {section name=log loop=$commitlines}
      <tr class="{cycle values="light,dark"}">
        <td title="{$commitlines[log].agestringage}"><i>{$commitlines[log].agestringdate}</i></td>

file:b/templates/tag.tpl (new)
--- /dev/null
+++ b/templates/tag.tpl
@@ -1,1 +1,42 @@
+{*
+ *  tag.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Tag view template
+ *
+ *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
+ *}
+ {* Nav *}
+ <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={$head}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$head}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$head}">tree</a>
+   <br /><br />
+ </div>
+ {* Tag data *}
+ <div>
+   <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hash}" class="title">{$tag.name}</a>
+ </div>
+ <div class="title_text">
+   <table cellspacing="0">
+     <tr>
+       <td>object</td>
+       <td class="monospace"><a href="{$SCRIPT_NAME}?p={$project}&a={$tag.type}&h={$tag.object}" class="list">{$tag.object}</a></td>
+       <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a={$tag.type}&h={$tag.object}">{$tag.type}</a></td>
+     </tr>
+     {if $tag.author}
+       <tr>
+         <td>author</td>
+	 <td>{$tag.author}</td>
+       </tr>
+       <tr>
+         <td></td>
+	 <td> {$datedata.rfc2822} ({if $datedata.hour_local < 6}<span class="latenight">{/if}{$datedata.hour_local}:{$datedata.minute_local}{if $datedata.hour_local < 6}</span>{/if} {$datedata.tz_local})
+         </td>
+       </tr>
+     {/if}
+   </table>
+ </div>
+ <div class="page_body">
+   {foreach from=$tag.comment item=line}
+     {$line}<br />
+   {/foreach}
+ </div>
 

file:a/templates/tag_data.tpl (deleted)
--- a/templates/tag_data.tpl
+++ /dev/null
@@ -1,26 +1,1 @@
-{*
- *  tag_data.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Tag view data template
- *
- *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
- *}
- <div>
-   <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hash}" class="title">{$title}</a>
- </div>
- <div class="title_text">
- <table cellspacing="0">
- <tr><td>object</td><td class="monospace"><a href="{$SCRIPT_NAME}?p={$project}&a={$type}&h={$object}" class="list">{$object}</a></td><td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a={$type}&h={$object}">{$type}</a></td></tr>
- {if $author}
- <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>
- {/if}
- </table>
- </div>
- <div class="page_body">
- {foreach from=$comment item=line}
- {$line}<br />
- {/foreach}
- </div>
 

file:a/templates/tag_nav.tpl (deleted)
--- a/templates/tag_nav.tpl
+++ /dev/null
@@ -1,12 +1,1 @@
-{*
- *  tag_nav.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Tag navbar 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">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&hb={$head}">tree</a>
- <br /><br />
- </div>
 

--- /dev/null
+++ b/templates/tags.tpl
@@ -1,1 +1,39 @@
+{*
+ *  tags.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Tag view template
+ *
+ *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
+ *}
+ {* Nav *}
+ <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={$head}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$head}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$head}">tree</a>
+   <br /><br />
+ </div>
+ <div>
+   <a href="{$SCRIPT_NAME}?p={$project}&a=summary" class="title">&nbsp;</a>
+ </div>
+ {* Display tags *}
+ <table cellspacing="0">
+   {section name=tag loop=$taglist}
+     <tr class="{cycle values="light,dark"}">
+       <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 count($taglist[tag].comment) > 0}
+           <a href="{$SCRIPT_NAME}?p={$project}&a=tag&h={$taglist[tag].id}" class="list">{$taglist[tag].comment[0]}</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>
+     </tr>
+   {/section}
+ </table>
 

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

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

file:a/templates/tags_item.tpl (deleted)
--- a/templates/tags_item.tpl
+++ /dev/null
@@ -1,20 +1,1 @@
-{*
- *  tags_item.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Tag view item template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <tr class="{$class}">
- <td><i>{$age}</i></td>
- <td><a href="{$SCRIPT_NAME}?p={$project}&a={$reftype}&h={$refid}" class="list"><b>{$name}</b></a></td>
- <td>
- {if $comment}
- <a href="{$SCRIPT_NAME}?p={$project}&a=tag&h={$id}" class="list">{$comment}</a>
- {/if}
- </td>
- <td class="link">
- {if $type == "tag"}<a href="{$SCRIPT_NAME}?p={$project}&a=tag&h={$id}">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/{$name}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h=refs/tags/{$name}">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=snapshot&h={$refid}">snapshot</a>{/if}
- </td>
- </tr>
 

file:a/templates/tags_nav.tpl (deleted)
--- a/templates/tags_nav.tpl
+++ /dev/null
@@ -1,12 +1,1 @@
-{*
- *  tags_nav.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Tag 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={$head}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$head}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$head}">tree</a>
- <br /><br />
- </div>
 

--- /dev/null
+++ b/templates/tree.tpl
@@ -1,1 +1,58 @@
+{*
+ *  tree.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Tree view template
+ *
+ *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
+ *}
+ {* Nav *}
+ {if $fullnav}
+   <div class="page_nav">
+     <a href="{$SCRIPT_NAME}?p={$project}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h={$hashbase}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hashbase}">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hashbase}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hashbase}">commitdiff</a> | tree<br /><br />
+   </div>
+   <div>
+     <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hashbase}" class="title">{$title}
+       {if $hashbaseref}
+         <span class="tag">{$hashbaseref}</span>
+       {/if}
+     </a>
+   </div>
+ {else}
+   <div class="page_nav"><br /><br /></div>
+   <div class="title">{$hash}</div>
+ {/if}
+ {* Path *}
+ <div class="page_path">
+   <b>
+     <a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$hashbase}&h={$hashbase}">[{$project}]</a> / 
+     {foreach from=$paths item=path}
+       <a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$hashbase}&h={$path.tree}&f={$path.full}">{$path.short}</a> / 
+     {/foreach}
+   </b>
+ </div>
+ <div class="page_body">
+   {* List files *}
+   <table cellspacing="0">
+     {section name=tree loop=$treelines}
+       <tr class="{cycle values="light,dark"}">
+         <td class="monospace">{$treelines[tree].filemode}</td>
+         {if $treelines[tree].type == "blob"}
+           <td class="list">
+             <a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$treelines[tree].hash}{if $hashbase}&hb={$hashbase}{/if}&f={if $base}{$base}{/if}{$treelines[tree].name}" class="list">{$treelines[tree].name}</a>
+	   </td>
+           <td class="link">
+	     <a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$treelines[tree].hash}{if $hashbase}&hb={$hashbase}{/if}&f={if $base}{$base}{/if}{$treelines[tree].name}">blob</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=history&h={$hashbase}&f={if $base}{$base}{/if}{$treelines[tree].name}">history</a>
+	   </td>
+         {elseif $treelines[tree].type == "tree"}
+           <td class="list">
+             <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$treelines[tree].hash}{if $hashbase}&hb={$hashbase}{/if}&f={if $base}{$base}{/if}{$treelines[tree].name}">{$treelines[tree].name}</a>
+	   </td>
+           <td class="link">
+	     <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$treelines[tree].hash}{if $hashbase}&hb={$hashbase}{/if}&f={if $base}{$base}{/if}{$treelines[tree].name}">tree</a>
+	   </td>
+         {/if}
+       </tr>
+     {/section}
+   </table>
+ </div>
 

--- a/templates/tree_emptynav.tpl
+++ /dev/null
@@ -1,10 +1,1 @@
-{*
- *  tree_emptynav.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Tree view emptynav template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div class="page_nav"><br /><br /></div>
- <div class="title">{$hash}</div>
 

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

--- a/templates/tree_filelist_header.tpl
+++ /dev/null
@@ -1,11 +1,1 @@
-{*
- *  tree_filelist_header.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Tree view filelist header template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <div class="page_path"><b><a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$hashbase}&h={$hashbase}">[{$project}]</a> / {foreach from=$paths item=path}<a href="{$SCRIPT_NAME}?p={$project}&a=tree&hb={$hashbase}&h={$path.tree}&f={$path.full}">{$path.short}</a> / {/foreach}</b></div>
- <div class="page_body">
- <table cellspacing="0">
 

--- a/templates/tree_filelist_item.tpl
+++ /dev/null
@@ -1,20 +1,1 @@
-{*
- *  tree_filelist_item.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Tree view filelist item template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
- <tr class="{$class}">
- <td class="monospace">{$filemode}</td>
- <td class="list">
- {if $type == "blob"}
- <a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$hash}{if $hashbase}&hb={$hashbase}{/if}&f={if $base}{$base}{/if}{$name}" class="list">{$name}</a></td>
- <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=blob&h={$hash}{if $hashbase}&hb={$hashbase}{/if}&f={if $base}{$base}{/if}{$name}">blob</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=history&h={$hashbase}&f={if $base}{$base}{/if}{$name}">history</a>
- {elseif $type == "tree"}
-   <a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$hash}{if $hashbase}&hb={$hashbase}{/if}&f={if $base}{$base}{/if}{$name}">{$name}</a></td>
-   <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=tree&h={$hash}{if $hashbase}&hb={$hashbase}{/if}&f={if $base}{$base}{/if}{$name}">tree</a>
- {/if}
- </td>
- </tr>
 

file:a/templates/tree_nav.tpl (deleted)
--- a/templates/tree_nav.tpl
+++ /dev/null
@@ -1,15 +1,1 @@
-{*
- *  tree_nav.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Tree 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={$hashbase}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hashbase}">log</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hashbase}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=commitdiff&h={$hashbase}">commitdiff</a> | tree<br /><br />
- </div>
- <div><a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$hashbase}" class="title">{$title}
- {if $hashbaseref}
- <span class="tag">{$hashbaseref}</span>
- {/if}
- </a></div>
 

comments