Skip to content
Browse files

Initial rough web stuff

  • Loading branch information...
1 parent 84d0d32 commit 5b16ea6bdebe14d1a2d01a5199b4ed8e3e0eaa72 @singpolyma committed Jul 23, 2009
Showing with 82 additions and 0 deletions.
  1. +1 −0 web/.gitignore
  2. +16 −0 web/list.php
  3. +65 −0 web/show.php
View
1 web/.gitignore
@@ -0,0 +1 @@
+include/config.php
View
16 web/list.php
@@ -0,0 +1,16 @@
+<?php
+
+require dirname(__FILE__).'/include/config.php';
+
+$tickets = explode("\n",shell_exec("cd '".REPOSITORY_PATH."'; git ticket list"));
+
+echo "<ul>\n";
+foreach($tickets as $ticket) {
+ if(!$ticket) continue;
+ $uticket = rawurlencode($ticket);
+ $ticket = htmlspecialchars($ticket);
+ echo "\t<li><a href=\"show.php?$uticket\">$ticket</a></li>\n";
+}
+echo "</ul>\n";
+
+?>
View
65 web/show.php
@@ -0,0 +1,65 @@
+<?php
+
+if(!$_SERVER['QUERY_STRING']) {
+ die('Must specify a ticket to view!');
+}
+
+require dirname(__FILE__).'/include/config.php';
+
+// XXX Should come up with a way of escaping so that tickets can be in folders
+$ticket = explode("\n\n",file_get_contents(REPOSITORY_PATH.'/.tickets/'.basename($_SERVER['QUERY_STRING'])),2);
+
+$id = null;
+$meta = explode("\n", $ticket[0]);
+if(count($meta)) {
+ echo "<dl>\n";
+ foreach($meta as $line) {
+ $line = preg_split('/:\s*/', $line, 2);
+ if($line[0] && $line[1]) {
+ if(strtolower($line[0]) == 'message-id') {
+ $id = $line[1];
+ }
+ if(strtolower($line[0]) == 'from') {
+ $line[1] = preg_replace('/@[^<>]+/','',$line[1]);
+ }
+ $k = htmlspecialchars($line[0]);
+ $v = htmlspecialchars($line[1]);
+ echo "\t<dt>$k</dt>\n\t\t<dd>$v<\dd>\n";
+ }
+ }
+ echo "</dl>\n";
+}
+
+echo "\n<p>".str_replace("\n\n","</p>\n\n<p>",$ticket[1])."</p>\n";
+
+if($id) {
+ $id = escapeshellarg('^In-Reply-To: '.$id);
+ $comments = explode("\n",shell_exec("cd '".REPOSITORY_PATH."/.tickets'; grep -il $id *"));
+ if(count($comments)) {
+ echo "\n<ul>\n";
+ foreach($comments as $comment) {
+ if(!$comment) continue;
+ $comment = explode("\n\n",file_get_contents(REPOSITORY_PATH.'/.tickets/'.$comment));
+ $comment[0] = explode("\n", $comment[0]);
+ foreach($comment[0] as $meta) {
+ if(!$meta) continue;
+ $meta = preg_split('/:\s*/', $meta, 2);
+ if(strtolower($meta[0]) == 'from') $from = preg_replace('/@[^<>]+/','',$meta[1]);
+ if(strtolower($meta[0]) == 'date') $date = $meta[1];
+ }
+ echo "\t<li>\n";
+ echo "\n\t\t<dl>\n";
+ echo "\t\t\t<dt>From</dt>\n";
+ echo "\t\t\t\t<dd>".htmlspecialchars($from)."</dd>\n";
+ echo "\t\t\t<dt>Date</dt>\n";
+ echo "\t\t\t\t<dd>".htmlspecialchars($date)."</dd>\n";
+ echo "\t\t</dl>\n";
+ echo "\n\t\t<p>".str_replace("\n\n","</p>\n\n\t\t<p>",$comment[1])."</p>\n";
+ echo "\t</li>\n";
+ }
+ echo "</ul>\n";
+ }
+}
+
+
+?>

0 comments on commit 5b16ea6

Please sign in to comment.
Something went wrong with that request. Please try again.