<?php
/**
* title: launchpad releases news feed
* description: query last 20 entries from cache in launchpad.db
* version: 0.1
* category: template
* api: cli
* type: cron
* x-cron: 10 10 * * *
*
* Short summary
* → ./template/feed.launchpad.htm
*
*/
chdir(dirname(__DIR__));
include("./config.php");
db(new PDO("sqlite:launchpad.db"));
// query
$q = db("
SELECT r.name, r.title, r.version, SUBSTR(r.release_notes, 1, 200) AS release_notes,
r.web_link, p.title AS proj_title, SUBSTR(p.summary, 1, 200) AS summary
FROM releases AS r
LEFT JOIN projects AS p
ON p.name = r.name
ORDER BY date_created DESC
LIMIT 20
");
// collect
$out = "";
foreach ($q as $row) {
$row = array_map("input::html", $row);
$out .= <<<HTML
<a href="$row[web_link]" title="$row[summary]">$row[proj_title] <em class=version title="$row[release_notes]">$row[version]</em></a>
HTML;
}
// write
file_put_contents("./template/feed.launchpad.htm", $out);