Start on OPML, make plaintext contextdiff into template
Start on OPML, make plaintext contextdiff into template

--- a/gitphp.lib.php
+++ b/gitphp.lib.php
@@ -861,7 +861,7 @@
 
 function git_commitdiff_plain($projectroot,$project,$hash,$hash_parent)
 {
-	global $gitphp_conf;
+	global $gitphp_conf,$tpl;
 	$ret = prep_tmpdir($gitphp_conf['gittmp']);
 	if ($ret !== TRUE) {
 		echo $ret;
@@ -890,16 +890,16 @@
 	header("Content-type: text/plain; charset=UTF-8");
 	header("Content-disposition: inline; filename=\"git-" . $hash . ".patch\"");
 	$ad = date_str($co['author_epoch'],$co['author_tz']);
-	echo "From: " . $co['author'] . "\n";
-	echo "Date: " . $ad['rfc2822'] . "\n";
-	echo "Subject: " . $co['title'] . "\n";
+	$tpl->clear_all_assign();
+	$tpl->assign("from",$co['author']);
+	$tpl->assign("date",$ad['rfc2822']);
+	$tpl->assign("subject",$co['title']);
 	if (isset($tagname))
-		echo "X-Git-Tag: " . $tagname . "\n";
-	echo "X-Git-Url: " . $gitphp_conf['self'] . "?p=" . $project . "&a=commitdiff&h=" . $hash . "\n";
-	echo "\n";
-	foreach ($co['comment'] as $i => $line)
-		echo $line . "\n";
-	echo "---\n\n";
+		$tpl->assign("tagname",$tagname);
+	$tpl->assign("url",$gitphp_conf['self'] . "?p=" . $project . "&a=commitdiff&h=" . $hash);
+	$tpl->assign("comment",$co['comment']);
+	$tpl->display("diff_plaintext.tpl");
+	echo "\n\n";
 	foreach ($difftree as $i => $line) {
 		if (ereg("^:([0-7]{6}) ([0-7]{6}) ([0-9a-fA-F]{40}) ([0-9a-fA-F]{40}) (.)\t(.*)$",$line,$regs)) {
 			if ($regs[5] == "A")
@@ -1031,5 +1031,11 @@
 	$tpl->display("tags_footer.tpl");
 }
 
+function git_opml($projectroot,$projectlist)
+{
+	$projlist = git_read_projects($projectroot,$projectlist);
+	header("Content-type: text/xml; charset=UTF-8");
+}
+
 ?>
 

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -84,6 +84,10 @@
 				case "tags":
 					git_tags($gitphp_conf['projectroot'],$_GET['p']);
 					break;
+				case "opml":
+					$suppress_headers = TRUE;
+ 					git_opml($gitphp_conf['projectroot'],$git_projects);
+					break;
 				default:
 					echo "Unknown action";
 					break;

--- /dev/null
+++ b/templates/diff_plaintext.tpl
@@ -1,1 +1,34 @@
+{*
+ *  diff_plaintext.tpl
+ *  gitphp: A PHP git repository browser
+ *  Component: Plaintext diff 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.
+ *}
+From: {$from}
+Date: {$date}
+Subject: {$subject}
+{if $tagname}
+X-Git-Tag: {$tagname}
+{/if}
+X-Git-Url: {$url}
+---
+{foreach from=$comment item=line}
+{$line}
+{/foreach}
+---
 

comments