Add log listing
Add log listing

--- a/gitphp.lib.php
+++ b/gitphp.lib.php
@@ -632,5 +632,60 @@
 	$tpl->display("shortlog_footer.tpl");
 }
 
+function git_log($projectroot,$project,$hash,$page)
+{
+	global $tpl;
+	$head = git_read_head($projectroot . $project);
+	if (!isset($hash))
+		$hash = $head;
+	if (!isset($page))
+		$page = 0;
+	$refs = read_info_ref($projectroot . $project);
+	$tpl->clear_all_assign();
+	$tpl->assign("project",$project);
+	$tpl->assign("hash",$hash);
+	$tpl->display("log_nav.tpl");
+
+	$revlist = git_read_revlist($projectroot . $project, $hash, (100 * ($page+1)));
+
+	if (($hash != $head) || $page)
+		$tpl->assign("headlink",TRUE);
+	if ($page > 0) {
+		$tpl->assign("prevlink",TRUE);
+		$tpl->assign("prevpage",$page-1);
+	}
+	if (count($revlist) >= (100 * ($page+1)-1)) {
+		$tpl->assign("nextlink",TRUE);
+		$tpl->assign("nextpage",$page+1);
+	}
+	$tpl->display("log_pagenav.tpl");
+
+	if (!$revlist) {
+		$tpl->clear_all_assign();
+		$tpl->assign("project",$project);
+		$co = git_read_commit($hash);
+		$tpl->assign("age_string",$co['age_string']);
+		$tpl->display("log_info.tpl");
+	}
+	for ($i = ($page * 100); $i <= count($revlist); $i++) {
+		$tpl->clear_all_assign();
+		$commit = $revlist[$i];
+		$co = git_read_commit($projectroot . $project, $commit);
+		$ad = date_str($co['author_epoch']);
+		$tpl->assign("project",$project);
+		$tpl->assign("commit",$commit);
+		if (isset($refs[$commit]))
+			$tpl->assign("commitref",$refs[$commit]);
+		$tpl->assign("agestring",$co['age_string']);
+		$tpl->assign("title",$co['title']);
+		$tpl->assign("authorname",$co['author_name']);
+		$tpl->assign("rfc2822",$ad['rfc2822']);
+		$tpl->assign("comment",$co['comment']);
+		if (count($co['comment']) > 0)
+			$tpl->assign("notempty",TRUE);
+		$tpl->display("log_item.tpl");
+	}
+}
+
 ?>
 

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -64,6 +64,9 @@
 				case "shortlog":
 					git_shortlog($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['pg']);
 					break;
+				case "log":
+					git_log($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['pg']);
+					break;
 				default:
 					echo "Unknown action";
 					break;

--- /dev/null
+++ b/templates/log_info.tpl
@@ -1,1 +1,27 @@
+{*
+ *  log_info.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Log view info 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>
+ <div class="page_body"> Last change {$agestring}.<br /><br />
+ </div>
 

--- /dev/null
+++ b/templates/log_item.tpl
@@ -1,1 +1,44 @@
+{*
+ *  log_item.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Log 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.
+ *}
+ <div>
+ <a href="{$SCRIPT_NAME}?p={$project}&a=commit&h={$commit}" class="title"><span class="age">{$agestring}</span>{$title}
+ {if $commitref}
+  <span class="tag">{$commitref}</span>
+ {/if}
+ </a>
+ </div>
+ <div class="title_text">
+ <div class="log_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>
+ <br />
+ </div>
+ <i>{$authorname} [{$rfc2822}]</i><br />
+ </div>
+ <div class="log_body">
+ {foreach from=$comment item=line}
+ {$line}<br />
+ {/foreach}
+ {if $notempty}
+ <br />
+ {/if}
+ </div>
 

--- /dev/null
+++ b/templates/log_nav.tpl
@@ -1,1 +1,25 @@
+{*
+ *  log_nav.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Log 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="{$SCIRPT_NAME}?p={$project}&a=shortlog&h={$hash}">shortlog</a> | log | <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 />
 

--- /dev/null
+++ b/templates/log_pagenav.tpl
@@ -1,1 +1,25 @@
+{*
+ *  log_page.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Log view page 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.
+ *}
+ {if $headlink}<a href="{$SCRIPT_NAME}?p={$project}&a=log">{/if}HEAD{if $headlink}</a>{/if} &sdot; {if $prevlink}<a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}&pg={$prevpage}" accesskey="p" title="Alt-p">{/if}prev{if $prevlink}</a>{/if} &sdot; {if $nextlink}<a href="{$SCRIPT_NAME}?p={$project}&a=log&h={$hash}&pg={$nextpage}" accesskey="n" title="Alt-n">{/if}next{if $nextlink}</a>{/if}
+ <br />
+ </div>
 

comments