summaryrefslogtreecommitdiff
path: root/contrib/angstrom/rss.php
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/angstrom/rss.php')
-rw-r--r--contrib/angstrom/rss.php87
1 files changed, 51 insertions, 36 deletions
diff --git a/contrib/angstrom/rss.php b/contrib/angstrom/rss.php
index cf5a9e0218..2e1f49c4cc 100644
--- a/contrib/angstrom/rss.php
+++ b/contrib/angstrom/rss.php
@@ -1,48 +1,63 @@
-<?php echo ('<?xml version="1.0" encoding="utf-8"?>'); ?>
-<rss version="2.0" xml:base="http://www.angstrom-distribution.org/unstable/autobuild/" xmlns:dc="http://purl.org/dc/elements/1.1/">
- <channel>
- <title>Ångström autobuilder updates</title>
- <link>http://www.angstrom-distribution.org/unstable/autobuild/</link>
- <description></description>
- <language>en</language>
<?php
-$base_path = "/home/angstrom/website/unstable/autobuild";
+/*
+ * This generator expect only log from autobuilder in simple format:
+ * TIME_OF_BUILD BUILD_TARGET BUILD_MODE MACHINE
+ *
+ * where TIME_OF_BUILD is epoch
+ *
+ * All what it does is parsing log and output it in reverse order (new builds
+ * first) in RSS 2.0 format.
+ *
+ * (C) 2007 Marcin Juszkiewicz
+ *
+ * License: MIT
+ *
+ */
-if ($handle = opendir("$base_path"))
-{
- while (false !== ($file = readdir($handle)))
- {
- if(!(is_dir($file) && $file != "." && $file != ".."))
- {
- continue;
- }
+$build_link_base = 'http://www.angstrom-distribution.org/unstable/autobuild/';
+
+$builder_log_date = file('autobuilder.log');
+
+if(empty($builder_log_date))
+ die("No logs\n");
+
+$builder_log_date = array_reverse($builder_log_date);
+
+$rss_xml = new xmlWriter();
- $second_handle = opendir("$base_path/$file/");
+if(!$rss_xml)
+ die("Unable to create XML Writer\n");
- while (false !== ($file2 = readdir($second_handle)))
- {
- if(is_file("/$base_path/$file/$file2"))
- {
- $fmtime = filemtime("$file/$file2");
+$rss_xml->openMemory();
- echo "<item>\n"
- echo "<title>$file/$file2 uploaded</title>\n";
- echo " <link>http://www.angstrom-distribution.org/unstable/autobuild/$file/$file2</link>\n";
+$rss_xml->startDocument('1.0','utf-8');
+$rss_xml->startElement('rss');
+$rss_xml->writeAttribute('version', '2.0');
- $rsstime = strftime("%a, %d %b %Y %T +0100", $fmtime);
+$rss_xml->startElement('channel');
- echo "<pubDate>$rsstime</pubDate>\n";
- echo "<dc:creator>Angstrom autobuilder</dc:creator>";
- echo "</item>\n";
- }
- }
+$rss_xml->writeElement('title', 'Ångström autobuilder updates');
+$rss_xml->writeElement('link', $build_link_base);
+$rss_xml->writeElement('description', 'Ångström autobuilder updates list');
- closedir($second_handle);
- }
+foreach($builder_log_date as $build)
+{
+ $build = str_replace("\n", "", $build);
+ $data = explode(' ', $build);
+
+ $rss_xml->startElement('item');
+ $rss_xml->writeElement('title', "{$data[1]} ({$data[2]}) built for {$data[3]} (" . date('c', $data[0]) . ")");
+ $rss_xml->writeElement('link', "{$build_link_base}{$data[3]}/");
+ $rss_xml->writeElement('pubDate', date('r', $data[0]));
- closedir($handle);
+ $rss_xml->endElement();
}
+
+$rss_xml->endElement();
+$rss_xml->endElement();
+
+echo $rss_xml->outputMemory(true);
+
+echo "\n";
?>
- </channel>
-</rss>