Unify opml template
Unify opml template

<?php <?php
/* /*
* display.git_opml.php * display.git_opml.php
* gitphp: A PHP git repository browser * gitphp: A PHP git repository browser
* Component: Display - OPML feed * Component: Display - OPML feed
* *
* Copyright (C) 2008 Christopher Han <xiphux@gmail.com> * Copyright (C) 2008 Christopher Han <xiphux@gmail.com>
*/ */
   
require_once('util.script_url.php'); require_once('util.script_url.php');
require_once('gitutil.git_read_projects.php'); require_once('gitutil.git_read_projects.php');
require_once('gitutil.git_read_head.php');  
require_once('gitutil.git_read_commit.php');  
   
function git_opml($projectroot,$projectlist) function git_opml($projectroot,$projectlist)
{ {
global $tpl,$gitphp_conf; global $tpl,$gitphp_conf;
$projlist = git_read_projects($projectroot,$projectlist); $projlist = git_read_projects($projectroot,$projectlist);
header("Content-type: text/xml; charset=UTF-8"); header("Content-type: text/xml; charset=UTF-8");
$tpl->clear_all_assign(); $tpl->clear_all_assign();
$tpl->assign("title",$gitphp_conf['title']); $tpl->assign("title",$gitphp_conf['title']);
$tpl->display("opml_header.tpl"); $tpl->assign("self",script_url());
echo "\n"; $opmllist = array();
foreach ($projlist as $cat => $plist) { foreach ($projlist as $cat => $plist) {
if (is_array($plist)) { if (is_array($plist)) {
foreach ($plist as $i => $proj) { foreach ($plist as $i => $proj) {
$head = git_read_head($projectroot . $proj); $opmllist[] = $proj;
$co = git_read_commit($projectroot . $proj, $head);  
$tpl->clear_all_assign();  
$tpl->assign("proj",$proj);  
$tpl->assign("self",script_url());  
$tpl->display("opml_item.tpl");  
echo "\n";  
} }
} else { } else {
$head = git_read_head($projectroot . $plist); $opmllist[] = $plist;
$co = git_read_commit($projectroot . $plist, $head);  
$tpl->clear_all_assign();  
$tpl->assign("proj",$plist);  
$tpl->assign("self",script_url());  
$tpl->display("opml_item.tpl");  
echo "\n";  
} }
} }
  $tpl->assign("opmllist",$opmllist);
$tpl->clear_all_assign(); $tpl->display("opml.tpl");
$tpl->display("opml_footer.tpl");  
} }
   
?> ?>
   
file:a/index.php -> file:b/index.php
<?php <?php
/* /*
* 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>
*/ */
ob_start(); ob_start();
   
/* /*
* Version * Version
*/ */
include_once('include/version.php'); include_once('include/version.php');
   
/* /*
* Constants * Constants
*/ */
require_once('include/defs.constants.php'); require_once('include/defs.constants.php');
   
/* /*
* Configuration * Configuration
*/ */
require_once('config/gitphp.conf.php'); require_once('config/gitphp.conf.php');
   
/* /*
* Instantiate Smarty * Instantiate Smarty
*/ */
require_once($gitphp_conf['smarty_prefix'] . "Smarty.class.php"); require_once($gitphp_conf['smarty_prefix'] . "Smarty.class.php");
$tpl =& new Smarty; $tpl =& new Smarty;
if (isset($_GET['a']) && if (isset($_GET['a']) &&
($_GET['a'] != "commitdiff_plain") && ($_GET['a'] != "commitdiff_plain") &&
($_GET['a'] != "blob_plain") && ($_GET['a'] != "blob_plain") &&
($_GET['a'] != "blobdiff_plain")) { ($_GET['a'] != "blobdiff_plain") &&
  ($_GET['a'] != "opml")) {
$tpl->load_filter('output','trimwhitespace'); $tpl->load_filter('output','trimwhitespace');
} }
   
   
$rss_link = FALSE; $rss_link = FALSE;
$suppress_headers = FALSE; $suppress_headers = FALSE;
   
ob_start(); ob_start();
if (isset($_GET['a']) && $_GET['a'] == "opml") { if (isset($_GET['a']) && $_GET['a'] == "opml") {
$suppress_headers = TRUE; $suppress_headers = TRUE;
require_once('include/display.git_opml.php'); require_once('include/display.git_opml.php');
git_opml($gitphp_conf['projectroot'],$git_projects); git_opml($gitphp_conf['projectroot'],$git_projects);
} else if (isset($_GET['a']) && $_GET['a'] == "project_index") { } else if (isset($_GET['a']) && $_GET['a'] == "project_index") {
$suppress_headers = TRUE; $suppress_headers = TRUE;
require_once('include/display.git_project_index.php'); require_once('include/display.git_project_index.php');
git_project_index($gitphp_conf['projectroot'],$git_projects); git_project_index($gitphp_conf['projectroot'],$git_projects);
} else if (isset($_GET['p'])) { } else 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'])) {
require_once('include/display.git_summary.php'); require_once('include/display.git_summary.php');
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":
require_once('include/display.git_summary.php'); require_once('include/display.git_summary.php');
git_summary($gitphp_conf['projectroot'],$_GET['p']); git_summary($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "tree": case "tree":
require_once('include/display.git_tree.php'); require_once('include/display.git_tree.php');
git_tree($gitphp_conf['projectroot'], $_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['f']) ? $_GET['f'] : NULL), (isset($_GET['hb']) ? $_GET['hb'] : NULL)); git_tree($gitphp_conf['projectroot'], $_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['f']) ? $_GET['f'] : NULL), (isset($_GET['hb']) ? $_GET['hb'] : NULL));
break; break;
case "shortlog": case "shortlog":
require_once('include/display.git_shortlog.php'); require_once('include/display.git_shortlog.php');
git_shortlog($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['pg']) ? $_GET['pg'] : NULL)); git_shortlog($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['pg']) ? $_GET['pg'] : NULL));
break; break;
case "log": case "log":
require_once('include/display.git_log.php'); require_once('include/display.git_log.php');
git_log($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['pg']) ? $_GET['pg'] : NULL)); git_log($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['pg']) ? $_GET['pg'] : NULL));
break; break;
case "commit": case "commit":
require_once('include/display.git_commit.php'); require_once('include/display.git_commit.php');
git_commit($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']); git_commit($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']);
break; break;
case "commitdiff": case "commitdiff":
require_once('include/display.git_commitdiff.php'); require_once('include/display.git_commitdiff.php');
git_commitdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'], (isset($_GET['hp']) ? $_GET['hp'] : NULL)); git_commitdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'], (isset($_GET['hp']) ? $_GET['hp'] : NULL));
break; break;
case "commitdiff_plain": case "commitdiff_plain":
$suppress_headers = TRUE; $suppress_headers = TRUE;
require_once('include/display.git_commitdiff_plain.php'); require_once('include/display.git_commitdiff_plain.php');
git_commitdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],(isset($_GET['hp']) ? $_GET['hp'] : NULL)); git_commitdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],(isset($_GET['hp']) ? $_GET['hp'] : NULL));
break; break;
case "heads": case "heads":
require_once('include/display.git_heads.php'); require_once('include/display.git_heads.php');
git_heads($gitphp_conf['projectroot'],$_GET['p']); git_heads($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "tags": case "tags":
require_once('include/display.git_tags.php'); require_once('include/display.git_tags.php');
git_tags($gitphp_conf['projectroot'],$_GET['p']); git_tags($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "rss": case "rss":
$suppress_headers = TRUE; $suppress_headers = TRUE;
require_once('include/display.git_rss.php'); require_once('include/display.git_rss.php');
git_rss($gitphp_conf['projectroot'],$_GET['p']); git_rss($gitphp_conf['projectroot'],$_GET['p']);
break; break;
case "blob": case "blob":
require_once('include/display.git_blob.php'); require_once('include/display.git_blob.php');
git_blob($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['f']) ? $_GET['f'] : NULL), (isset($_GET['hb']) ? $_GET['hb'] : NULL)); git_blob($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL), (isset($_GET['f']) ? $_GET['f'] : NULL), (isset($_GET['hb']) ? $_GET['hb'] : NULL));
break; break;
case "blob_plain": case "blob_plain":
$suppress_headers = TRUE; $suppress_headers = TRUE;
require_once('include/display.git_blob_plain.php'); require_once('include/display.git_blob_plain.php');
git_blob_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],(isset($_GET['f']) ? $_GET['f'] : NULL)); git_blob_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],(isset($_GET['f']) ? $_GET['f'] : NULL));
break; break;
case "blobdiff": case "blobdiff":
require_once('include/display.git_blobdiff.php'); require_once('include/display.git_blobdiff.php');
git_blobdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'],(isset($_GET['f']) ? $_GET['f'] : NULL)); git_blobdiff($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'],(isset($_GET['f']) ? $_GET['f'] : NULL));
break; break;
case "blobdiff_plain": case "blobdiff_plain":
$suppress_headers = TRUE; $suppress_headers = TRUE;
require_once('include/display.git_blobdiff_plain.php'); require_once('include/display.git_blobdiff_plain.php');
git_blobdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'], (isset($_GET['f']) ? $_GET['f'] : NULL)); git_blobdiff_plain($gitphp_conf['projectroot'],$_GET['p'],$_GET['h'],$_GET['hb'],$_GET['hp'], (isset($_GET['f']) ? $_GET['f'] : NULL));
break; break;
case "snapshot": case "snapshot":
$suppress_headers = TRUE; $suppress_headers = TRUE;
require_once('include/display.git_snapshot.php'); require_once('include/display.git_snapshot.php');
git_snapshot($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL)); git_snapshot($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL));
break; break;
case "history": case "history":
require_once('include/display.git_history.php'); require_once('include/display.git_history.php');
git_history($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL),$_GET['f']); git_history($gitphp_conf['projectroot'],$_GET['p'], (isset($_GET['h']) ? $_GET['h'] : NULL),$_GET['f']);
break; break;
case "search": case "search":
if (isset($_GET['st']) && ($_GET['st'] == 'file')) { if (isset($_GET['st']) && ($_GET['st'] == 'file')) {
require_once('include/display.git_search_files.php'); require_once('include/display.git_search_files.php');
git_search_files($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL),(isset($_GET['s']) ? $_GET['s'] : NULL),(isset($_GET['pg']) ? $_GET['pg'] : 0)); git_search_files($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL),(isset($_GET['s']) ? $_GET['s'] : NULL),(isset($_GET['pg']) ? $_GET['pg'] : 0));
} else { } else {
require_once('include/display.git_search.php'); require_once('include/display.git_search.php');
git_search($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL),(isset($_GET['s']) ? $_GET['s'] : NULL),(isset($_GET['st']) ? $_GET['st'] : "commit"),(isset($_GET['pg']) ? $_GET['pg'] : 0)); git_search($gitphp_conf['projectroot'],$_GET['p'],(isset($_GET['h']) ? $_GET['h'] : NULL),(isset($_GET['s']) ? $_GET['s'] : NULL),(isset($_GET['st']) ? $_GET['st'] : "commit"),(isset($_GET['pg']) ? $_GET['pg'] : 0));
} }
break; break;
case "tag": case "tag":
require_once('include/display.git_tag.php'); require_once('include/display.git_tag.php');
git_tag($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']); git_tag($gitphp_conf['projectroot'],$_GET['p'],$_GET['h']);
break; break;
default: default:
echo "Unknown action"; echo "Unknown action";
break; break;
} }
} }
} }
} else { } else {
$tpl->display("hometext.tpl"); $tpl->display("hometext.tpl");
require_once('include/display.git_project_list.php'); require_once('include/display.git_project_list.php');
git_project_list($gitphp_conf['projectroot'],$git_projects,(isset($_GET['o']) ? $_GET['o'] : "project")); git_project_list($gitphp_conf['projectroot'],$git_projects,(isset($_GET['o']) ? $_GET['o'] : "project"));
} }
$main = ob_get_contents(); $main = ob_get_contents();
ob_end_clean(); ob_end_clean();
   
if (!$suppress_headers) { if (!$suppress_headers) {
$tpl->clear_all_assign(); $tpl->clear_all_assign();
$tpl->assign("stylesheet",$gitphp_conf['stylesheet']); $tpl->assign("stylesheet",$gitphp_conf['stylesheet']);
$tpl->assign("version",$gitphp_version); $tpl->assign("version",$gitphp_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);
if (isset($_GET['st'])) if (isset($_GET['st']))
$tpl->assign("searchtype",$_GET['st']); $tpl->assign("searchtype",$_GET['st']);
else else
$tpl->assign("searchtype","commit"); $tpl->assign("searchtype","commit");
if (isset($_GET['s'])) if (isset($_GET['s']))
$tpl->assign("search",$_GET['s']); $tpl->assign("search",$_GET['s']);
if (isset($_GET['hb'])) if (isset($_GET['hb']))
$tpl->assign("hash",$_GET['hb']); $tpl->assign("hash",$_GET['hb']);
else if (isset($_GET['h'])) else if (isset($_GET['h']))
$tpl->assign("hash",$_GET['h']); $tpl->assign("hash",$_GET['h']);
if ($gitphp_conf['search']) if ($gitphp_conf['search'])
$tpl->assign("enablesearch",TRUE); $tpl->assign("enablesearch",TRUE);
if ($gitphp_conf['filesearch']) if ($gitphp_conf['filesearch'])
$tpl->assign("filesearch",TRUE); $tpl->assign("filesearch",TRUE);
$tpl->display("header.tpl"); $tpl->display("header.tpl");
} }
   
echo $main; echo $main;
   
if (!$suppress_headers) { if (!$suppress_headers) {
if ($rss_link) { if ($rss_link) {
$tpl->assign("project",$_GET['p']); $tpl->assign("project",$_GET['p']);
require_once('include/gitutil.git_project_descr.php'); require_once('include/gitutil.git_project_descr.php');
$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();
   
?> ?>
   
  {*
  * opml.tpl
  * gitphp: A PHP git repository browser
  * Component: OPML template
  *
  * Copyright (C) 2009 Christopher Han <xiphux@gmail.com>
  *}
  <?xml version="1.0" encoding="utf-8"?>
  <opml version="1.0">
  <head>
  <title>{$title} OPML Export</title>
  </head>
  <body>
  <outline text="git RSS feeds">
 
  {foreach from=$opmllist item=proj}
  <outline type="rss" text="{$proj}" title="{$proj}" xmlUrl="{$self}?p={$proj}&amp;a=rss" htmlUrl="{$self}?p={$proj}&amp;a=summary" />
 
  {/foreach}
  </outline>
  </body>
  </opml>
 
{*  
* opml_footer.tpl  
* gitphp: A PHP git repository browser  
* Component: OPML footer template  
*  
* Copyright (C) 2006 Christopher Han <xiphux@gmail.com>  
*}  
</outline>  
</body>  
</opml>  
 
{*  
* opml_header.tpl  
* gitphp: A PHP git repository browser  
* Component: OPML header template  
*  
* Copyright (C) 2006 Christopher Han <xiphux@gmail.com>  
*}  
<?xml version="1.0" encoding="utf-8"?>  
<opml version="1.0">  
<head>  
<title>{$title} OPML Export</title>  
</head>  
<body>  
<outline text="git RSS feeds">  
 
 
file:a/templates/opml_item.tpl (deleted)
{*  
* opml_item.tpl  
* gitphp: A PHP git repository browser  
* Component: OPML item template  
*  
* Copyright (C) 2006 Christopher Han <xiphux@gmail.com>  
*}  
<outline type="rss" text="{$proj}" title="{$proj}" xmlUrl="{$self}?p={$proj}&amp;a=rss" htmlUrl="{$self}?p={$proj}&amp;a=summary"/>  
 
comments