Author: sip Date: 2006-08-13 14:37:46 +0200 (Sun, 13 Aug 2006) New Revision: 1717 Modified: tools/webtools/timeline/rss.php Log: timeline: added notes to rss, more compact description for feed title Modified: tools/webtools/timeline/rss.php =================================================================== --- tools/webtools/timeline/rss.php 2006-08-13 11:38:41 UTC (rev 1716) +++ tools/webtools/timeline/rss.php 2006-08-13 12:37:46 UTC (rev 1717) @@ -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 @@ $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("&","&", $url); # strip diff link @@ -34,12 +29,24 @@ $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"; }
participants (1)
-
crux@crux.nu