Move titlebar to component template
Move titlebar to component template

--- a/templates/blame.tpl
+++ b/templates/blame.tpl
@@ -19,21 +19,9 @@
     | blame
    <br />
  </div>
- <div class="title">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$hashbase->GetHash()}" class="title">{$hashbase->GetTitle()}</a>
-   <span class="refs">
-   {foreach from=$hashbase->GetHeads() item=hashhead}
-     <span class="head">
-       <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h=refs/heads/{$hashhead->GetName()}">{$hashhead->GetName()}</a>
-     </span>
-   {/foreach}
-   {foreach from=$hashbase->GetTags() item=hashtag}
-     <span class="tag">
-       <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tag&h={$hashtag->GetName()}">{$hashtag->GetName()}</a>
-     </span>
-   {/foreach}
-   </span>
- </div>
+
+ {include file='title.tpl' titlecommit=$hashbase}
+ 
  <div class="page_path">
    {* The path to the file, with directories broken into tree links *}
    <b>

--- a/templates/blob.tpl
+++ b/templates/blob.tpl
@@ -19,21 +19,9 @@
    {if !$datatag} | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blame&h={$hash->GetHash()}&f={$file}&hb={$hashbase->GetHash()}">blame</a>{/if}
    <br />
  </div>
- <div class="title">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$hashbase->GetHash()}" class="title">{$hashbase->GetTitle()}</a>
-   <span class="refs">
-   {foreach from=$hashbase->GetHeads() item=hashhead}
-     <span class="head">
-       <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h=refs/heads/{$hashhead->GetName()}">{$hashhead->GetName()}</a>
-     </span>
-   {/foreach}
-   {foreach from=$hashbase->GetTags() item=hashtag}
-     <span class="tag">
-       <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tag&h={$hashtag->GetName()}">{$hashtag->GetName()}</a>
-     </span>
-   {/foreach}
-   </span>
- </div>
+
+ {include file='title.tpl' titlecommit=$hashbase}
+ 
  <div class="page_path">
    {* The path to the file, with directories broken into tree links *}
    <b>

--- a/templates/blobdiff.tpl
+++ b/templates/blobdiff.tpl
@@ -14,21 +14,9 @@
    <br />
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=blobdiff_plain&h={$hash->GetHash()}&hp={$hashparent->GetHash()}&f={$file}">plain</a>
  </div>
- <div class="title">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$hashbase->GetHash()}" class="title">{$hashbase->GetTitle()}</a>
-   <span class="refs">
-   {foreach from=$hashbase->GetHeads() item=head}
-     <span class="head">
-       <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h=refs/heads/{$head->GetName()}">{$head->GetName()}</a>
-     </span>
-   {/foreach}
-   {foreach from=$hashbase->GetTags() item=tag}
-     <span class="tag">
-       <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tag&h={$tag->GetName()}">{$tag->GetName()}</a>
-     </span>
-   {/foreach}
-   </span>
- </div>
+
+ {include file='title.tpl' titlecommit=$hashbase}
+ 
  <div class="page_path">
    {* The path to the file, with directories broken into tree links *}
    <b>

--- a/templates/commit.tpl
+++ b/templates/commit.tpl
@@ -13,32 +13,13 @@
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h={$commit->GetHash()}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=log&h={$commit->GetHash()}">log</a> | commit | {if $commit->GetParent()}<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$commit->GetHash()}">commitdiff</a> | {/if}<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}">tree</a>
    <br /><br />
  </div>
- <div class="title">
-   {* Commit header *}
-   {if $commit->GetParent()}
-     <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$commit->GetHash()}" class="title">{$commit->GetTitle()}</a>
-     <span class="refs">
-     {assign var=heads value=$commit->GetHeads()}
-     {if count($heads) > 0}
-       {foreach name=head item=head from=$heads}
-         <span class="head">
-	   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h=refs/heads/{$head->GetName()}">{$head->GetName()}</a>
-	 </span>
-       {/foreach}
-     {/if}
-     {assign var=tags value=$commit->GetTags()}
-     {if count($tags) > 0}
-       {foreach name=tag item=tag from=$tags}
-         <span class="tag">
-           <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tag&h={$tag->GetName()}">{$tag->GetName()}</a>
-         </span>
-       {/foreach}
-     {/if}
-     </span>
-   {else}
-     <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree&h={$tree->GetHash()}&hb={$commit->GetHash()}" class="title">{$commit->GetTitle()}</a>
-   {/if}
- </div>
+
+{if $commit->GetParent()}
+ 	{include file='title.tpl' titlecommit=$commit target='commitdiff'}
+{else}
+	{include file='title.tpl' titlecommit=$commit titletree=$tree target='tree'}
+{/if}
+ 
  <div class="title_text">
    {* Commit data *}
    <table cellspacing="0">

--- a/templates/commitdiff.tpl
+++ b/templates/commitdiff.tpl
@@ -13,24 +13,9 @@
    {assign var=tree value=$hash->GetTree()}
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h={$hash->GetHash()}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=log&h={$hash->GetHash()}">log</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$hash->GetHash()}">commit</a> | commitdiff | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree&h={$tree->GetHash()}&hb={$hash->GetHash()}">tree</a><br /><a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff_plain&h={$hash->GetHash()}{if $hashparent}&hp={$hashparent}{/if}">plain</a>
  </div>
- <div>
-   <br /><br />
- </div>
- <div class="title">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$hash->GetHash()}" class="title">{$hash->GetTitle()}</a>
-   <span class="refs">
-   {foreach name=head item=head from=$hash->GetHeads()}
-     <span class="head">
-       <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h=refs/heads/{$head->GetName()}">{$head->GetName()}</a>
-     </span>
-   {/foreach}
-   {foreach name=tag item=tag from=$hash->GetTags()}
-     <span class="tag">
-       <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tag&h={$tag->GetName()}">{$tag->GetName()}</a>
-     </span>
-   {/foreach}
-   </span>
- </div>
+
+ {include file='title.tpl' titlecommit=$hash}
+ 
  <div class="page_body">
    {foreach from=$hash->GetComment() item=line}
      {$line}<br />

--- a/templates/heads.tpl
+++ b/templates/heads.tpl
@@ -13,9 +13,9 @@
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=log">log</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$head}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$head}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree&hb={$head}">tree</a>
    <br /><br />
  </div>
- <div class="title">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary" class="title">&nbsp;</a>
- </div>
+
+ {include file='title.tpl' target='summary'}
+ 
  <table cellspacing="0">
    {* Loop and display each head *}
    {foreach from=$headlist item=head}

--- a/templates/history.tpl
+++ b/templates/history.tpl
@@ -13,21 +13,9 @@
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=log">log</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$hash->GetHash()}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$hash->GetHash()}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree&h={$tree->GetHash()}&hb={$hash->GetHash()}">tree</a>
    <br /><br />
  </div>
- <div class="title">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$hash->GetHash()}" class="title">{$hash->GetTitle()}</a>
-   <span class="refs">
-   {foreach from=$hash->GetHeads() item=head}
-     <span class="head">
-       <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h=refs/heads/{$head->GetName()}">{$head->GetName()}</a>
-     </span>
-   {/foreach}
-   {foreach from=$hash->GetTags() item=tag}
-     <span class="tag">
-       <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tag&h={$tag->GetName()}">{$tag->GetName()}</a>
-     </span>
-   {/foreach}
-   </span>
- </div>
+
+ {include file='title.tpl' titlecommit=$hash}
+
  <div class="page_path">
    {* File path *}
    <b>

--- a/templates/project.tpl
+++ b/templates/project.tpl
@@ -13,7 +13,9 @@
    summary | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=log">log</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$head->GetHash()}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$head->GetHash()}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree">tree</a>
    <br /><br />
  </div>
- <div class="title">&nbsp;</div>
+
+ {include file='title.tpl'}
+
  {* Project brief *}
  <table cellspacing="0">
    <tr><td>description</td><td>{$project->GetDescription()}</td></tr>
@@ -26,9 +28,9 @@
      <tr><td>push url</td><td>{$project->GetPushUrl()}</td></tr>
    {/if}
  </table>
- <div class="title">
-   <a class="title" href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog">shortlog</a>
- </div>
+
+ {include file='title.tpl' target='shortlog'}
+ 
  <table cellspacing="0">
    {foreach from=$revlist item=rev}
      <tr class="{cycle name=revs values="light,dark"}">
@@ -60,9 +62,9 @@
  </table>
  {if $taglist}
    {* Tags *}
-   <div class="title">
-     <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tags" class="title">tags</a>
-   </div>
+  
+  {include file='title.tpl' target='tags'}
+   
    <table cellspacing="0">
      {section name=tag max=17 loop=$taglist}
        <tr class="{cycle name=tags values="light,dark"}">
@@ -93,9 +95,9 @@
  {/if}
  {if $headlist}
    {* Heads *}
-   <div class="title">
-     <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=heads" class="title">heads</a>
-   </div>
+
+  {include file='title.tpl' target='heads'}
+
    <table cellspacing="0">
      {section name=head max=17 loop=$headlist}
        <tr class="{cycle name=heads values="light,dark"}">

--- a/templates/search.tpl
+++ b/templates/search.tpl
@@ -31,9 +31,9 @@
   {/if}
   <br />
 </div>
-<div class="title">
-  <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$hash->GetHash()}" class="title">{$hash->GetTitle()}</a>
-</div>
+
+{include file='title.tpl' titlecommit=$hash}
+
 <table cellspacing="0">
   {* Print each match *}
   {foreach from=$results item=result}

--- a/templates/shortlog.tpl
+++ b/templates/shortlog.tpl
@@ -31,9 +31,9 @@
    {/if}
    <br />
  </div>
- <div class="title">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary" class="title">&nbsp;</a>
- </div>
+
+ {include file='title.tpl' target='summary'}
+ 
  <table cellspacing="0">
    {foreach from=$revlist item=rev}
      <tr class="{cycle values="light,dark"}">

--- a/templates/tags.tpl
+++ b/templates/tags.tpl
@@ -13,9 +13,9 @@
    <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=log">log</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$head}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$head}">commitdiff</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree&hb={$head}">tree</a>
    <br /><br />
  </div>
- <div class="title">
-   <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary" class="title">&nbsp;</a>
- </div>
+
+{include file='title.tpl' target='summary'}
+ 
  {* Display tags *}
  <table cellspacing="0">
    {foreach name=tags from=$taglist item=tag}

--- /dev/null
+++ b/templates/title.tpl
@@ -1,1 +1,47 @@
+{*
+ * Title
+ *
+ * Title template
+ *
+ * @author Christopher Han <xiphux@gmail.com>
+ * @copyright Copyright (c) 2010 Christopher Han
+ * @package GitPHP
+ * @subpackage Template
+ *}
 
+<div class="title">
+	{if $titlecommit}
+		{if $target == 'commitdiff'}
+			<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$titlecommit->GetHash()}" class="title">{$titlecommit->GetTitle()}</a>
+		{elseif $target == 'tree'}
+			<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tree&h={$titletree->GetHash()}&hb={$titlecommit->GetHash()}" class="title">{$commit->GetTitle()}</a>
+		{else}
+			<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$titlecommit->GetHash()}" class="title">{$titlecommit->GetTitle()}</a>
+		{/if}
+		<span class="refs">
+			{foreach from=$titlecommit->GetHeads() item=titlehead}
+				<span class="head">
+					<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h=refs/heads/{$titlehead->GetName()}">{$titlehead->GetName()}</a>
+				</span>
+			{/foreach}
+			{foreach from=$titlecommit->GetTags() item=titletag}
+				<span class="tag">
+					<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tag&h={$titletag->GetName()}">{$titletag->GetName()}</a>
+				</span>
+			{/foreach}
+		</span>
+	{else}
+		{if $target == 'summary'}
+			<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary" class="title">&nbsp;</a>
+		{elseif $target == 'shortlog'}
+			<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog" class="title">shortlog</a>
+		{elseif $target == 'tags'}
+			<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tags" class="title">tags</a>
+		{elseif $target == 'heads'}
+			<a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=heads" class="title">heads</a>
+		{else}
+			&nbsp;
+		{/if}
+	{/if}
+</div>
+

--- a/templates/tree.tpl
+++ b/templates/tree.tpl
@@ -12,23 +12,9 @@
    <div class="page_nav">
      <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=summary">summary</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h={$hashbase->GetHash()}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=log&h={$hashbase->GetHash()}">log</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$hashbase->GetHash()}">commit</a> | <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commitdiff&h={$hashbase->GetHash()}">commitdiff</a> | tree<br /><br />
    </div>
-   <div class="title">
-     <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=commit&h={$hashbase->GetHash()}" class="title">{$hashbase->GetTitle()}</a>
-     <span class="refs">
-     {assign var=heads value=$hashbase->GetHeads()}
-     {foreach name=head item=head from=$heads}
-       <span class="head">
-         <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=shortlog&h=refs/heads/{$head->GetName()}">{$head->GetName()}</a>
-       </span>
-     {/foreach}
-     {assign var=tags value=$hashbase->GetTags()}
-     {foreach name=tag item=tag from=$tags}
-       <span class="tag">
-         <a href="{$SCRIPT_NAME}?p={$project->GetProject()}&a=tag&h={$tag->GetName()}">{$tag->GetName()}</a>
-       </span>
-     {/foreach}
-     </span>
-   </div>
+
+ {include file='title.tpl' titlecommit=$hashbase}
+ 
  {* Path *}
  <div class="page_path">
    <b>

comments