Add heads/tags support
Add heads/tags support

--- a/gitphp.lib.php
+++ b/gitphp.lib.php
@@ -968,5 +968,68 @@
 	$tpl->display("commitdiff_footer.tpl");
 }
 
+function git_heads($projectroot,$project)
+{
+	global $tpl;
+	$head = git_read_head($projectroot . $project);
+	$tpl->clear_all_assign();
+	$tpl->assign("project",$project);
+	$tpl->assign("head",$head);
+	$tpl->display("heads_nav.tpl");
+	$tpl->display("heads_header.tpl");
+	$taglist = git_read_refs($projectroot, $project, "refs/heads");
+	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->display("heads_item.tpl");
+		}
+	}
+	$tpl->clear_all_assign();
+	$tpl->display("heads_footer.tpl");
+}
+
+function git_tags($projectroot,$project)
+{
+	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");
+	$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->clear_all_assign();
+	$tpl->display("tags_footer.tpl");
+}
+
 ?>
 

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -78,6 +78,12 @@
 					$suppress_headers = TRUE;
 					git_commitdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hp']);
 					break;
+				case "heads":
+					git_heads($gitphp_conf['projectroot'],$_GET['p']);
+					break;
+				case "tags":
+					git_tags($gitphp_conf['projectroot'],$_GET['p']);
+					break;
 				default:
 					echo "Unknown action";
 					break;

--- /dev/null
+++ b/templates/heads_footer.tpl
@@ -1,1 +1,23 @@
+{*
+ *  heads_footer.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Head view footer template
+ *
+ *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *}
+ </table>
 

--- /dev/null
+++ b/templates/heads_header.tpl
@@ -1,1 +1,24 @@
+{*
+ *  heads_header.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Head view header template
+ *
+ *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *}
+ <div><a href="{$SCRIPT_NAME}?p={$project}&a=summary" class="title">&nbsp;</a></div>
+ <table cellspacing="0">
 

--- /dev/null
+++ b/templates/heads_item.tpl
@@ -1,1 +1,27 @@
+{*
+ *  heads_item.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Head view item template
+ *
+ *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *}
+ <tr class="{$class}">
+ <td><i>{$age}</i></td>
+ <td><a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h={$name}" class="list"><b>{$name}</b></a></td>
+ <td class="link"><a href="{$SCRIPT_NAME}?p={$project}&a=shortlog&h={$name}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$name}">log</a></td>
+ </tr>
 

--- /dev/null
+++ b/templates/heads_nav.tpl
@@ -1,1 +1,26 @@
+{*
+ *  heads_nav.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Head view nav template
+ *
+ *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *}
+ <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_footer.tpl
@@ -1,1 +1,23 @@
+{*
+ *  tags_footer.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Tag view footer template
+ *
+ *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *}
+ </table>
 

--- /dev/null
+++ b/templates/tags_header.tpl
@@ -1,1 +1,24 @@
+{*
+ *  tags_header.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Tag view header template
+ *
+ *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *}
+ <div><a href="{$SCRIPT_NAME}?p={$project}&a=summary" class="title">&nbsp;</a></div>
+ <table cellspacing="0">
 

--- /dev/null
+++ b/templates/tags_item.tpl
@@ -1,1 +1,34 @@
+{*
+ *  tags_item.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Tag view item template
+ *
+ *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *}
+ <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={$name}">shortlog</a> | <a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$refid}">log</a>{/if}
+ </td>
+ </tr>
 

--- /dev/null
+++ b/templates/tags_nav.tpl
@@ -1,1 +1,26 @@
+{*
+ *  tags_nav.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Tag view nav template
+ *
+ *  Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *}
+ <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>
 

comments