Merge header and footer templates and use block inheritance
Merge header and footer templates and use block inheritance

--- a/templates/blame.tpl
+++ b/templates/blame.tpl
@@ -5,7 +5,9 @@
  *
  * Copyright (C) 2010 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  <div class="page_nav">
    {include file='nav.tpl' treecommit=$commit}
@@ -58,5 +60,5 @@
   {/if}
  </div>
 
- {include file='footer.tpl'}
+{/block}
 

--- a/templates/blob.tpl
+++ b/templates/blob.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  <div class="page_nav">
    {include file='nav.tpl' treecommit=$commit}
@@ -60,5 +62,5 @@
    {/if}
  </div>
 
- {include file='footer.tpl'}
+{/block}
 

--- a/templates/blobdiff.tpl
+++ b/templates/blobdiff.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  <div class="page_nav">
    {include file='nav.tpl' treecommit=$commit}
@@ -37,6 +39,5 @@
    {/if}
  </div>
 
- {include file='footer.tpl'}
+{/block}
 
-

--- a/templates/commit.tpl
+++ b/templates/commit.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  <div class="page_nav">
    {include file='nav.tpl' logcommit=$commit treecommit=$commit current='commit'}
@@ -222,6 +224,5 @@
    {/foreach}
  </table>
 
- {include file='footer.tpl'}
-
-
+{/block}
+

--- a/templates/commitdiff.tpl
+++ b/templates/commitdiff.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  {* Nav *}
  <div class="page_nav">
@@ -116,6 +118,5 @@
 
  </div>
 
- {include file='footer.tpl'}
+{/block}
 
-

file:a/templates/footer.tpl (deleted)
--- a/templates/footer.tpl
+++ /dev/null
@@ -1,29 +1,1 @@
-{*
- *  footer.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Page footer template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
-    <div class="page_footer">
-      {if $project}
-        <div class="page_footer_text">
-	{if $project->GetWebsite()}
-	<a href="{$project->GetWebsite()}">{$project->GetDescription()}</a>
-	{else}
-	{$project->GetDescription()}
-	{/if}
-	</div>
-        <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=rss" class="rss_logo">{t}RSS{/t}</a>
-        <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=atom" class="rss_logo">{t}Atom{/t}</a>
-      {else}
-        <a href="{$SCRIPT_NAME}?a=opml" class="rss_logo">{t}OPML{/t}</a>
-        <a href="{$SCRIPT_NAME}?a=project_index" class="rss_logo">{t}TXT{/t}</a>
-      {/if}
-    </div>
-    <div class="attr_footer">
-    	<a href="http://xiphux.com/programming/gitphp/" target="_blank">GitPHP by Chris Han</a>
-    </div>
-  </body>
-</html>
 

file:a/templates/header.tpl (deleted)
--- a/templates/header.tpl
+++ /dev/null
@@ -1,118 +1,1 @@
-{*
- *  header.tpl
- *  gitphp: A PHP git repository browser
- *  Component: Page header template
- *
- *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
- *}
-{'<?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-2011 Christopher Han <xiphux@gmail.com> -->
-  <head>
-    <title>{$pagetitle}{if $project} :: {$project->GetProject()}{if $actionlocal}/{$actionlocal}{/if}{/if}</title>
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-    {if $project}
-      <link rel="alternate" title="{$project->GetProject()} log (Atom)" href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=atom" type="application/atom+xml" />
-      <link rel="alternate" title="{$project->GetProject()} log (RSS)" href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=rss" type="application/rss+xml" />
-    {/if}
-    {if file_exists('css/gitphp.min.css')}
-    <link rel="stylesheet" href="css/gitphp.min.css" type="text/css" />
-    {else}
-    <link rel="stylesheet" href="css/gitphp.css" type="text/css" />
-    {/if}
-    {if file_exists("css/$stylesheet.min.css")}
-    <link rel="stylesheet" href="css/{$stylesheet}.min.css" type="text/css" />
-    {else}
-    <link rel="stylesheet" href="css/{$stylesheet}.css" type="text/css" />
-    {/if}
-    <link rel="stylesheet" href="css/ext/jquery.qtip.css" type="text/css" />
-    {if $extracss}
-    <style type="text/css">
-    {$extracss}
-    </style>
-    {/if}
-    {if $javascript}
-    <script src="js/ext/require.js"></script>
-    {include file='jsconst.tpl'}
-    <script type="text/javascript">
-    require({ldelim}
-    	baseUrl: 'js',
-	paths: {ldelim}
-	{if $extrascripts}
-	  {if file_exists("js/$extrascripts.min.js")}
-	  	{$extrascripts}: "{$extrascripts}.min",
-	  {/if}
-	{else}
-	  {if file_exists('js/common.min.js')}
-	  	common: "common.min",
-	  {/if}
-	{/if}
-	{if $googlejs}
-		jquery: 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min'
-	{else}
-		jquery: 'ext/jquery-1.7.1.min'
-	{/if}
-	{rdelim},
-	priority: ['jquery']
-    {rdelim}, [
-    	{if $extrascripts}
-	  '{$extrascripts}'
-	{else}
-	  'common'
-	{/if}
-      ]);
-    </script>
-    {/if}
-  </head>
-  <body>
-    <div class="page_header">
-      <a href="http://git-scm.com" title="git homepage">
-        <img src="images/git-logo.png" width="72" height="27" alt="git" class="logo" />
-      </a>
-      {if $supportedlocales}
-      <div class="lang_select">
-        <form action="{$SCRIPT_NAME}" method="get" id="frmLangSelect">
-         <div>
-	{foreach from=$requestvars key=var item=val}
-	{if $var != "l"}
-	<input type="hidden" name="{$var}" value="{$val}" />
-	{/if}
-	{/foreach}
-	<label for="selLang">{t}language:{/t}</label>
-	<select name="l" id="selLang">
-	  {foreach from=$supportedlocales key=locale item=language}
-	    <option {if $locale == $currentlocale}selected="selected"{/if} value="{$locale}">{if $language}{$language} ({$locale}){else}{$locale}{/if}</option>
-	  {/foreach}
-	</select>
-	<input type="submit" value="{t}set{/t}" id="btnLangSet" />
-         </div>
-	</form>
-      </div>
-      {/if}
-      <a href="index.php">{if $homelink}{$homelink}{else}{t}projects{/t}{/if}</a> / 
-      {if $project}
-        <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=summary">{$project->GetProject()}</a>
-        {if $actionlocal}
-           / {$actionlocal}
-        {/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->GetProject()}" />
-              <input type="hidden" name="a" value="search" />
-              <input type ="hidden" name="h" value="{if $commit}{$commit->GetHash()}{else}HEAD{/if}" />
-              <select name="st">
-                <option {if $searchtype == 'commit'}selected="selected"{/if} value="commit">{t}commit{/t}</option>
-                <option {if $searchtype == 'author'}selected="selected"{/if} value="author">{t}author{/t}</option>
-                <option {if $searchtype == 'committer'}selected="selected"{/if} value="committer">{t}committer{/t}</option>
-                {if $filesearch}
-                  <option {if $searchtype == 'file'}selected="selected"{/if} value="file">{t}file{/t}</option>
-                {/if}
-              </select> {t}search{/t}: <input type="text" name="s" {if $search}value="{$search}"{/if} />
-            </div>
-          </form>
-        {/if}
-      {/if}
-    </div>
 

--- a/templates/heads.tpl
+++ b/templates/heads.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  {* Nav *}
  <div class="page_nav">
@@ -16,7 +18,6 @@
  {include file='title.tpl' target='summary'}
 
  {include file='headlist.tpl'}
- 
- {include file='footer.tpl'}
 
+{/block}
 

--- a/templates/history.tpl
+++ b/templates/history.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  {* Page header *}
  <div class="page_nav">
@@ -33,6 +35,5 @@
    {/foreach}
  </table>
 
- {include file='footer.tpl'}
+{/block}
 
-

--- a/templates/log.tpl
+++ b/templates/log.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  {* Nav *}
  <div class="page_nav">
@@ -97,6 +99,5 @@
    </div>
  {/foreach}
 
- {include file='footer.tpl'}
+{/block}
 
-

--- /dev/null
+++ b/templates/main.tpl
@@ -1,1 +1,145 @@
+{*
+ * Main
+ *
+ * Main page template
+ *
+ * @author Christopher Han <xiphux@gmail.com>
+ * @copyright Copyright (c) 2011 Christopher Han
+ * @packge GitPHP
+ * @subpackage Template
+ *}
+{'<?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-2011 Christopher Han <xiphux@gmail.com> -->
+  <head>
+    <title>{$pagetitle}{if $project} :: {$project->GetProject()}{if $actionlocal}/{$actionlocal}{/if}{/if}</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    {if $project}
+      <link rel="alternate" title="{$project->GetProject()} log (Atom)" href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=atom" type="application/atom+xml" />
+      <link rel="alternate" title="{$project->GetProject()} log (RSS)" href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=rss" type="application/rss+xml" />
+    {/if}
+    {if file_exists('css/gitphp.min.css')}
+    <link rel="stylesheet" href="css/gitphp.min.css" type="text/css" />
+    {else}
+    <link rel="stylesheet" href="css/gitphp.css" type="text/css" />
+    {/if}
+    {if file_exists("css/$stylesheet.min.css")}
+    <link rel="stylesheet" href="css/{$stylesheet}.min.css" type="text/css" />
+    {else}
+    <link rel="stylesheet" href="css/{$stylesheet}.css" type="text/css" />
+    {/if}
+    <link rel="stylesheet" href="css/ext/jquery.qtip.css" type="text/css" />
+    {if $extracss}
+    <style type="text/css">
+    {$extracss}
+    </style>
+    {/if}
+    {if $javascript}
+    <script src="js/ext/require.js"></script>
+    {include file='jsconst.tpl'}
+    <script type="text/javascript">
+    require({ldelim}
+    	baseUrl: 'js',
+	paths: {ldelim}
+	{if $extrascripts}
+	  {if file_exists("js/$extrascripts.min.js")}
+	  	{$extrascripts}: "{$extrascripts}.min",
+	  {/if}
+	{else}
+	  {if file_exists('js/common.min.js')}
+	  	common: "common.min",
+	  {/if}
+	{/if}
+	{if $googlejs}
+		jquery: 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min'
+	{else}
+		jquery: 'ext/jquery-1.7.1.min'
+	{/if}
+	{rdelim},
+	priority: ['jquery']
+    {rdelim}, [
+    	{if $extrascripts}
+	  '{$extrascripts}'
+	{else}
+	  'common'
+	{/if}
+      ]);
+    </script>
+    {/if}
+  </head>
+  <body>
+    <div class="page_header">
+      <a href="http://git-scm.com" title="git homepage">
+        <img src="images/git-logo.png" width="72" height="27" alt="git" class="logo" />
+      </a>
+      {if $supportedlocales}
+      <div class="lang_select">
+        <form action="{$SCRIPT_NAME}" method="get" id="frmLangSelect">
+         <div>
+	{foreach from=$requestvars key=var item=val}
+	{if $var != "l"}
+	<input type="hidden" name="{$var}" value="{$val}" />
+	{/if}
+	{/foreach}
+	<label for="selLang">{t}language:{/t}</label>
+	<select name="l" id="selLang">
+	  {foreach from=$supportedlocales key=locale item=language}
+	    <option {if $locale == $currentlocale}selected="selected"{/if} value="{$locale}">{if $language}{$language} ({$locale}){else}{$locale}{/if}</option>
+	  {/foreach}
+	</select>
+	<input type="submit" value="{t}set{/t}" id="btnLangSet" />
+         </div>
+	</form>
+      </div>
+      {/if}
+      <a href="index.php">{if $homelink}{$homelink}{else}{t}projects{/t}{/if}</a> / 
+      {if $project}
+        <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=summary">{$project->GetProject()}</a>
+        {if $actionlocal}
+           / {$actionlocal}
+        {/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->GetProject()}" />
+              <input type="hidden" name="a" value="search" />
+              <input type ="hidden" name="h" value="{if $commit}{$commit->GetHash()}{else}HEAD{/if}" />
+              <select name="st">
+                <option {if $searchtype == 'commit'}selected="selected"{/if} value="commit">{t}commit{/t}</option>
+                <option {if $searchtype == 'author'}selected="selected"{/if} value="author">{t}author{/t}</option>
+                <option {if $searchtype == 'committer'}selected="selected"{/if} value="committer">{t}committer{/t}</option>
+                {if $filesearch}
+                  <option {if $searchtype == 'file'}selected="selected"{/if} value="file">{t}file{/t}</option>
+                {/if}
+              </select> {t}search{/t}: <input type="text" name="s" {if $search}value="{$search}"{/if} />
+            </div>
+          </form>
+        {/if}
+      {/if}
+    </div>
+{block name=main}
 
+{/block}
+    <div class="page_footer">
+      {if $project}
+        <div class="page_footer_text">
+	{if $project->GetWebsite()}
+	<a href="{$project->GetWebsite()}">{$project->GetDescription()}</a>
+	{else}
+	{$project->GetDescription()}
+	{/if}
+	</div>
+        <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=rss" class="rss_logo">{t}RSS{/t}</a>
+        <a href="{$SCRIPT_NAME}?p={$project->GetProject()|urlencode}&amp;a=atom" class="rss_logo">{t}Atom{/t}</a>
+      {else}
+        <a href="{$SCRIPT_NAME}?a=opml" class="rss_logo">{t}OPML{/t}</a>
+        <a href="{$SCRIPT_NAME}?a=project_index" class="rss_logo">{t}TXT{/t}</a>
+      {/if}
+    </div>
+    <div class="attr_footer">
+    	<a href="http://xiphux.com/programming/gitphp/" target="_blank">GitPHP by Chris Han</a>
+    </div>
+  </body>
+</html>
+

--- a/templates/message.tpl
+++ b/templates/message.tpl
@@ -5,9 +5,11 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
 <div class="message {if $error}error{/if}">{$message}</div>
 
-{include file='footer.tpl'}
+{/block}
 

--- a/templates/project.tpl
+++ b/templates/project.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  <div class="page_nav">
  {include file='nav.tpl' commit=$head current='summary'}
@@ -56,6 +58,5 @@
 
  {/if}
 
- {include file='footer.tpl'}
+{/block}
 
-

--- a/templates/projectlist.tpl
+++ b/templates/projectlist.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
 <div class="index_header">
 {if file_exists('templates/hometext.tpl') }
@@ -107,6 +109,6 @@
 
 </table>
 
-{include file='footer.tpl'}
+{/block}
 
 

--- a/templates/search.tpl
+++ b/templates/search.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
 {* Nav *}
 <div class="page_nav">
@@ -69,6 +71,5 @@
   {/if}
 </table>
 
-{include file='footer.tpl'}
+{/block}
 
-

--- a/templates/searchfiles.tpl
+++ b/templates/searchfiles.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
 {* Nav *}
 <div class="page_nav">
@@ -66,6 +68,5 @@
   {/if}
 </table>
 
-{include file='footer.tpl'}
+{/block}
 
-

--- a/templates/shortlog.tpl
+++ b/templates/shortlog.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  {* Nav *}
  <div class="page_nav">
@@ -42,6 +44,5 @@
 
  {include file='shortloglist.tpl' source='shortlog'}
 
- {include file='footer.tpl'}
+{/block}
 
-

--- a/templates/tag.tpl
+++ b/templates/tag.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  {* Nav *}
  <div class="page_nav">
@@ -70,6 +72,5 @@
    {/foreach}
  </div>
 
- {include file='footer.tpl'}
+{/block}
 
-

--- a/templates/tags.tpl
+++ b/templates/tags.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  {* Nav *}
  <div class="page_nav">
@@ -19,6 +21,5 @@
 
  {include file='taglist.tpl'}
 
- {include file='footer.tpl'}
+{/block}
 
-

--- a/templates/tree.tpl
+++ b/templates/tree.tpl
@@ -5,7 +5,9 @@
  *
  *  Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
-{include file='header.tpl'}
+{extends file='main.tpl'}
+
+{block name=main}
 
  {* Nav *}
    <div class="page_nav">
@@ -24,6 +26,5 @@
 </table>
  </div>
 
- {include file='footer.tpl'}
+{/block}
 
-

comments