timeline: added notes to rss, more compact description for feed title

This commit is contained in:
Simone Rota 2006-08-13 12:37:46 +00:00
parent e316a396e8
commit d6c3beeba2

View File

@ -1,16 +1,15 @@
<?php
require_once('DB.php');
$days = 15;
if (isset($_GET['days'])) {
$days = intval($_GET['days']);
$limit = 10;
if (isset($_GET['limit'])) {
$limit = intval($_GET['limit']);
}
$dsn = 'sqlite:////home/crux/public_html/local/timeline.db';
$db =& DB::connect($dsn);
if (DB::isError($db)) die("Cannot connect to database");
$db->setFetchMode(DB_FETCHMODE_ASSOC);
$from = time() - ($days * 24 * 60 * 60);
$sql = "select * from events where event_tstamp >= $from order by event_tstamp desc";
$sql = "select * from events order by event_tstamp desc limit $limit";
$res =& $db->Query($sql);
if (DB::isError($res)) die("Query error");
@ -18,10 +17,6 @@ header ("Content-type: text/xml");
$timeline .= '<?xml version="1.0"?>'."\n";
$timeline .= '<rss version="2.0"><channel><title>CRUX timeline</title><description>CRUX: timeline (commits, tasks, wiki edits)</description><link>http://crux.nu</link>';
while ($evt =& $res->fetchRow()) {
$event_description = $evt['event_description'];
if ($evt['event_notes'] != "") {
$event_description .= ": ".$evt['event_notes'];
}
$url = $evt['event_url'];
$url = str_replace("&","&amp;", $url);
# strip diff link
@ -34,12 +29,24 @@ while ($evt =& $res->fetchRow()) {
$description = preg_replace('/\[\[(\w+)\.(\w+)\]\] /s','$1.$2', $description);
# strip wiki user with ~
$description = preg_replace('/\[\[~(\w+)\]\] /s','$1', $description);
$evt['event_notes'] = "Notes";
# Compact description for svn commits
$description = preg_replace('/Revision (.*) committed by .*/','r$1', $description);
# Compact description for wiki edits
$description = str_replace ("Wiki page ","", $description);
$notes = "";
$titlenotes = "";
if ($evt['event_notes'] != "") {
$notes = $evt['event_notes'];
$titlenotes = ": ".$notes;
if (strlen($notes) > 40) {
$titlenotes = ": ".substr($notes,0,40)."...";
}
}
$timeline .= "
<item>
<title>$description</title>
<description></description>
<title>$description$titlenotes</title>
<description>$notes</description>
<link>$url</link>
</item>\n";
}