diff --git a/feed.php b/feed.php new file mode 100644 index 0000000..0d12385 --- /dev/null +++ b/feed.php @@ -0,0 +1,126 @@ + $email, "email" => ""); + if (preg_match("|([^\<]*)<([^>]*)>|", $email, $m)) { + $ret["name"] = trim($m[1]); + $ret["email"] = trim($m[2]); + } + return $ret; +} + + +function sort_by_date($a, $b) +{ + if ($a["time"] < $b["time"]) { + return 1; + } else if ($a["time"] > $b["time"]) { + return -1; + } + return 0; +} + +function print_changeset($row) +{ + $author = parse_email($row["author"]); + $gid = md5($author["email"]); + $avatar = (USE_SSL ? "https://secure.gravatar.com" : "http://www.gravatar.com") . + "/avatar/$gid?r=x&d=mm&s=48"; + return 'Avatar
' + . htmlspecialchars($author["name"]) . '' + . '' . htmlspecialchars($row["hash"]) . '
' + . htmlspecialchars($row["time"]). "

\n\n
" 
+		. htmlspecialchars($row["message"]) . '
'; +} + +function print_changes($current, $next) +{ + global $DB; + + $ret = ""; + + $revs = array(); + if (!($res = $DB->query(kl_str_sql("select revisions from changes where build<=!i and build>!i order by build desc", $current->nr, $next->nr)))) { + return $ret; + } else { + while ($row = $DB->fetchRow($res)) { + $revs = array_merge($revs, explode(",", $row["revisions"])); + } + } + + if ($res = $DB->query("select * from revs where hash in ('" . implode("','", $revs) . "')")) { + $ret .= ''; + + $changesets = array(); + + while ($row = $DB->fetchRow($res)) { + $changesets[] = $row; + } + + usort($changesets, "sort_by_date"); + + foreach ($changesets as $change) { + $ret .= print_changeset($change); + } + + $ret .= '
'; + } + + return $ret; +} + +$buildFeed = new FeedWriter(ATOM); +$buildFeed->setTitle('Singularity Automatic Development Builds'); +$buildFeed->setLink('http://files.streamgrid.net/singularity/'); +$buildFeed->setDescription('Latest automated build of the Singularity Viewer project'); +// $buildFeed->setImage('Testing the RSS writer class', +// 'http://www.ajaxray.com/projects/rss', +// 'http://www.rightbrainsolution.com/images/logo.gif'); + +$chan = "SingularityAlpha"; + +$pageSize = 20; + +$builds = array(); + +if ($res = $DB->query(kl_str_sql("select * from builds where chan=!s order by nr desc limit !i", $chan, $pageSize + 1))) { + while ($row = $DB->fetchRow($res)) { + + $build = new stdClass; + $DB->loadFromDbRow($build, $res, $row); + $builds[] = $build; + } +} + +$nrBuilds = count($builds); + +if ($nrBuilds) { + for ($i = 0; $i < $pageSize; $i++) { + if (!isset($builds[$i])) continue; + $newItem = $buildFeed->createNewItem(); + $newItem->setTitle("Singularity Alpha build " . $builds[$i]->nr); + $newItem->setLink("http://files.streamgrid.net/singularity/?build_id=" . $builds[$i]->nr); + $newItem->setDate($builds[$i]->modified); + if (isset($builds[$i+1])) { + $newItem->setDescription(print_changes($builds[$i], $builds[$i + 1])); + } + $buildFeed->addItem($newItem); + } + + $buildFeed->genarateFeed(); + +} + + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/index.php b/index.php index 3d0459c..68df762 100644 --- a/index.php +++ b/index.php @@ -17,9 +17,11 @@ function print_changeset($row) { $author = parse_email($row["author"]); $gid = md5($author["email"]); + $avatar = (USE_SSL ? "https://secure.gravatar.com" : "http://www.gravatar.com") . + "/avatar/$gid?r=x&d=mm&s=48"; print ' - Avatar
' . + Avatar
' . htmlspecialchars($author["name"]) . ' ' . htmlspecialchars($row["hash"]) . ' ' . htmlspecialchars($row["time"]). @@ -71,11 +73,11 @@ function print_changes($current, $next) } } -Function print_build($current, $next) +Function print_build($current, $next, $buildNr) { print " - nr})\">Build " . htmlspecialchars($current->nr). " + nr}\">Build " . htmlspecialchars($current->nr). " " . htmlspecialchars($current->modified). " (" . Layout::since(strtotime($current->modified)) . " ago) " . htmlspecialchars($current->chan). " Windows Installer \"Download\"/   @@ -83,7 +85,9 @@ Function print_build($current, $next) "; if ($next) { print ' - Show changes >>