Add log listing
[gitphp.git] / index.php
blob:a/index.php -> blob:b/index.php
<?php <?php
ob_start(); ob_start();
$version = "v01a"; $version = "v01a";
$gitphp_appstring = "gitphp $version"; $gitphp_appstring = "gitphp $version";
/* /*
* index.php * index.php
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Index script * Component: Index script
* *
* Copyright (C) 2006 Christopher Han <xiphux@gmail.com> * Copyright (C) 2006 Christopher Han <xiphux@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details. * GNU Library General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
   
/* /*
* Configuration * Configuration
*/ */
include_once('config.inc.php'); include_once('config.inc.php');
   
/* /*
* Instantiate Smarty * Instantiate Smarty
*/ */
include_once($gitphp_conf['smarty_prefix'] . "Smarty.class.php"); include_once($gitphp_conf['smarty_prefix'] . "Smarty.class.php");
$tpl =& new Smarty; $tpl =& new Smarty;
$tpl->load_filter('output','trimwhitespace'); $tpl->load_filter('output','trimwhitespace');
   
/* /*
* Function library * Function library
*/ */
include_once('gitphp.lib.php'); include_once('gitphp.lib.php');
   
$rss_link = FALSE; $rss_link = FALSE;
   
ob_start(); ob_start();
if (isset($_GET['p'])) { if (isset($_GET['p'])) {
if (!is_dir($gitphp_conf['projectroot'] . $_GET['p'])) if (!is_dir($gitphp_conf['projectroot'] . $_GET['p']))
echo "No such directory"; echo "No such directory";
else if (!is_file($gitphp_conf['projectroot'] . $_GET['p'] . "/HEAD")) else if (!is_file($gitphp_conf['projectroot'] . $_GET['p'] . "/HEAD"))
echo "No such project"; echo "No such project";
else { else {
$rss_link = TRUE; $rss_link = TRUE;
if (!isset($_GET['a'])) if (!isset($_GET['a']))
git_summary($gitphp_conf['projectroot'],$_GET['p']); git_summary($gitphp_conf['projectroot'],$_GET['p']);
else { else {
switch ($_GET['a']) { switch ($_GET['a']) {
case "summary": case "summary":
git_summary($gitphp_conf['projectroot'],$_GET['p']); git_summary($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "tree": case "tree":
git_tree($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['f'],$_GET['hb']); git_tree($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['f'],$_GET['hb']);
break; break;
case "shortlog": case "shortlog":
git_shortlog($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['pg']); git_shortlog($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['pg']);
break; break;
  case "log":
  git_log($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['pg']);
  break;
default: default:
echo "Unknown action"; echo "Unknown action";
break; break;
} }
} }
} }
} else { } else {
$tpl->display("hometext.tpl"); $tpl->display("hometext.tpl");
git_project_list($gitphp_conf['projectroot'],$git_projects); git_project_list($gitphp_conf['projectroot'],$git_projects);
} }
$main = ob_get_contents(); $main = ob_get_contents();
ob_end_clean(); ob_end_clean();
   
$tpl->clear_all_assign(); $tpl->clear_all_assign();
$tpl->assign("stylesheet",$gitphp_conf['stylesheet']); $tpl->assign("stylesheet",$gitphp_conf['stylesheet']);
$tpl->assign("version",$version); $tpl->assign("version",$version);
$title = $gitphp_conf['title']; $title = $gitphp_conf['title'];
if ($rss_link) { if ($rss_link) {
$tpl->assign("rss_link",TRUE); $tpl->assign("rss_link",TRUE);
$tpl->assign("project",$_GET['p']); $tpl->assign("project",$_GET['p']);
$title .= " :: " . $_GET['p']; $title .= " :: " . $_GET['p'];
if (isset($_GET['a'])) { if (isset($_GET['a'])) {
$tpl->assign("action",$_GET['a']); $tpl->assign("action",$_GET['a']);
$title .= "/" . $_GET['a']; $title .= "/" . $_GET['a'];
} }
} }
$tpl->assign("title",$title); $tpl->assign("title",$title);
$tpl->display("header.tpl"); $tpl->display("header.tpl");
   
echo $main; echo $main;
   
if ($rss_link) { if ($rss_link) {
$tpl->assign("project",$_GET['p']); $tpl->assign("project",$_GET['p']);
$tpl->assign("descr",git_project_descr($gitphp_conf['projectroot'],$_GET['p'])); $tpl->assign("descr",git_project_descr($gitphp_conf['projectroot'],$_GET['p']));
} }
$tpl->display("footer.tpl"); $tpl->display("footer.tpl");
   
ob_end_flush(); ob_end_flush();
   
?> ?>
   
comments