Skip to content

Instantly share code, notes, and snippets.

@mattn
Created March 19, 2014 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattn/9641684 to your computer and use it in GitHub Desktop.
Save mattn/9641684 to your computer and use it in GitHub Desktop.
diff --git a/lib/Ukigumo/Server/Web/Dispatcher.pm b/lib/Ukigumo/Server/Web/Dispatcher.pm
index f417210..17b04e8 100644
--- a/lib/Ukigumo/Server/Web/Dispatcher.pm
+++ b/lib/Ukigumo/Server/Web/Dispatcher.pm
@@ -42,12 +42,35 @@ get '/cc.xml' => sub {
push @{$projects{$project->{project}}}, $project;
}
- $c->render( 'cc.xml.tx',
+ my $res = $c->render( 'cc.xml.tx',
{
now => time(),
projects => \%projects,
}
);
+ $res->content_type( 'application/xml' );
+ $res;
+};
+
+get '/rss.xml' => sub {
+ my ($c, $args) = @_;
+
+ my $limit = 50;
+
+ my ($reports, $pager) = Ukigumo::Server::Command::Report->recent_list(
+ limit => $limit,
+ );
+ for my $report (@{$reports}) {
+ $report->{body} = Ukigumo::Server::Command::Report->find( report_id => $report->{report_id} )->{body};
+ }
+ my $res = $c->render(
+ 'rss.xml.tx' => {
+ reports => $reports,
+ now => time(),
+ }
+ );
+ $res->content_type( 'application/xml' );
+ $res;
};
get '/recent' => sub {
diff --git a/share/tmpl/rss.xml.tx b/share/tmpl/rss.xml.tx
new file mode 100644
index 0000000..3145fd7
--- /dev/null
+++ b/share/tmpl/rss.xml.tx
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
+<channel>
+<title>Recent reports</title>
+<link><: uri_for('/') :></link>
+<description>Recent build statuses</description>
+<generator>Ukigumo::Server</generator>
+: for $reports -> $v {
+<item>
+<title><: $v.project :>-<: $v.branch :>-<: $v.revision :> <: $v.status | status_str :></title>
+<link><: uri_for('/report/' ~ $v.report_id) :></link>
+<date><: $now-$v.ctime | ctime_cc_str :></date>
+<description><pre><: $v.body :></pre></description>
+</item>
+: }
+</channel>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment