Skip to content

Commit

Permalink
Merge 514fa2e into 000da0d
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Mar 20, 2014
2 parents 000da0d + 514fa2e commit a85517b
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 7 deletions.
2 changes: 1 addition & 1 deletion META.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"Plack::Middleware::Session" : "0.14",
"Plack::Session::Store::File" : "0",
"Pod::Usage" : "0",
"POSIX::strftime::Compiler" : "0.31",
"Router::Simple" : "0.14",
"Router::Simple::Sinatraish" : "0",
"Starlet" : "0",
Expand All @@ -83,7 +84,6 @@
"Text::Xslate::Util" : "0",
"Time::Duration" : "0",
"Time::Duration::ja" : "0.03",
"Time::Piece" : "1.20",
"URI::Escape" : "0",
"URI::WithBase" : "0",
"Ukigumo::Common" : "0.04",
Expand Down
2 changes: 1 addition & 1 deletion cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires 'Amon2' => '2.50';
requires 'Amon2::Plugin::ShareDir';
requires 'Text::Xslate' => '1.1005';
requires 'Plack::Middleware::ReverseProxy' => '0.09';
requires 'Time::Piece' => '1.20';
requires 'POSIX::strftime::Compiler' => '0.31';
requires 'DBI' => 0;
requires 'DBD::SQLite' => 1.33;
requires 'Data::Validator' => 0.08;
Expand Down
1 change: 0 additions & 1 deletion lib/Ukigumo/Server/Command/Branch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use 5.010001;

use Amon2::Declare;
use Data::Validator;
use Time::Piece;

sub find_or_create {
my $class = shift;
Expand Down
27 changes: 25 additions & 2 deletions lib/Ukigumo/Server/Web/Dispatcher.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use warnings;
use 5.010001;
use Amon2::Web::Dispatcher::Lite;
use URI::Escape qw(uri_unescape uri_escape);
use Time::Piece;
use Ukigumo::Server::Command::Report;
use Ukigumo::Server::Command::Branch;
use Data::Validator;
Expand Down Expand Up @@ -42,12 +41,36 @@ 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(),
base_uri => $c->req->base,
}
);
$res->content_type( 'application/xml' );
$res;
};

get '/recent' => sub {
Expand Down
4 changes: 2 additions & 2 deletions lib/Ukigumo/Server/Web/ViewFunctions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use parent qw(Exporter);
use URI::WithBase;
use Text::Xslate qw/mark_raw html_escape/;
use Module::Functions;
use Time::Piece;
use POSIX::strftime::Compiler qw/strftime/;
use Ukigumo::Constants;

our @EXPORT = get_public_functions();
Expand Down Expand Up @@ -36,7 +36,7 @@ sub l {

sub ctime_cc_str {
my $epoch = shift;
Time::Piece->new($epoch)->strftime('%Y-%m-%dT%H:%M:%S.000%z');
strftime('%Y-%m-%dT%H:%M:%S.000%z', localtime $epoch);
}

sub status_cc_str {
Expand Down
32 changes: 32 additions & 0 deletions share/static/css/rss.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
rss {
display: block;
font-family: verdana, arial;
}
title {
display: block;
margin: 5px;
padding: 2px;
color: gray;
border-bottom: 1px solid silver;
}
link {
display: block;
font-size: small;
padding-left: 10px;
}
item {
display: block;
padding: 2px 30px 2px 30px;
}
docs {
display: block;
background-color: #ffffe6;
margin: 20px;
text-align: center;
padding: 5px;
color: #7f7f7f;
border: 1px solid silver;
}
language, lastBuildDate, ttl, guid, category, description, pubDate, generator, channel>link {
display: none;
}
1 change: 1 addition & 0 deletions share/tmpl/include/layout.tx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"]]>
<meta name="robots" content="noindex,nofollow,noarchive" />
<meta name="format-detection" content="telephone=no" />
<link rel="alternate" type="application/rss+xml" title="RSS" href="<: uri_for('/rss.xml') :>" />
<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="<: uri_for('/static/img/favicon.ico') :>" />
<link href="<: uri_for('/static/less/bootstrap/bootstrap.less') :>" rel="stylesheet/less" media="screen" />
<script src="<: uri_for('/static/js/jquery-1.6.3.min.js') :>"></script>
Expand Down
18 changes: 18 additions & 0 deletions share/tmpl/rss.xml.tx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="<: abs_uri_for('/static/css/rss.css') :>" ?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>Recent reports</title>
<link><: abs_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><: abs_uri_for('/report/' ~ $v.report_id) :></link>
<date><: $v.ctime | ctime_cc_str :></date>
<description><pre><: $v.body :></pre></description>
</item>
: }
</channel>
</rss>

0 comments on commit a85517b

Please sign in to comment.