Matt Housh
e78df72edd
* rss generator: minor updates for XML output formatting and PHP log warnings * cacher: replaced flyspray task caching with gitea issues caching
56 lines
2.1 KiB
PHP
56 lines
2.1 KiB
PHP
<?php
|
|
|
|
# global config
|
|
$limit = 40;
|
|
$dbfile = '/home/crux/timeline/timeline.db';
|
|
|
|
if (isset($_GET['limit'])) {
|
|
$limit = intval($_GET['limit']);
|
|
}
|
|
|
|
$dbc = new SQLite3($dbfile);
|
|
|
|
$sql = "SELECT DISTINCT * FROM events ORDER BY event_tstamp DESC LIMIT $limit";
|
|
$res = $dbc->query($sql);
|
|
if (!$res) die ("Query error: $last_cached_sql");
|
|
|
|
header ("Content-type: text/xml");
|
|
$timeline = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<rss version=\"2.0\">\n\n<channel>\n";
|
|
$timeline .= " <title>CRUX timeline</title>\n <description>CRUX: timeline (commits, issues, wiki edits)</description>\n <link>http://crux.nu</link>\n";
|
|
|
|
while ($evt = $res->fetchArray()) {
|
|
#print_r($evt); # uncomment for debug
|
|
|
|
$url = $evt['event_url'];
|
|
$url = str_replace("&","&", $url);
|
|
# strip diff link
|
|
$description = preg_replace('/\(\[\[.*\]\]\)/s','', $evt['event_description']);
|
|
# strip wiki link with url
|
|
$description = preg_replace('/\[\[(.*)\|(\d+)\]\]/s','$2', $description);
|
|
# strip users (git)
|
|
$description = preg_replace('/\[\[~(.*)\|(.*)\]\]/s','$2', $description);
|
|
# strip wiki link without url
|
|
$description = preg_replace('/\[\[(\w+)\.(\w+)\]\] /s','$1.$2', $description);
|
|
# strip wiki user with ~
|
|
$description = preg_replace('/\[\[~(\w+)\]\] /s','$1', $description);
|
|
# Compact description for git commits
|
|
$description = preg_replace('/\[\[http(.*)\|(.*)\]\] committed by/','$2 by', $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>\n <title>$description$titlenotes</title>\n <description>$notes</description>\n <link>$url</link>\n </item>\n";
|
|
}
|
|
$timeline .= "</channel>\n</rss>\n";
|
|
echo $timeline;
|
|
|
|
?>
|