Fix OPML chains
[catagits/Gitalist.git] / lib / Gitalist / Controller / OPML.pm
1 package Gitalist::Controller::OPML;
2
3 use Moose;
4 use Moose::Autobox;
5
6 use Sys::Hostname qw/hostname/;
7 use XML::OPML::SimpleGen;
8
9 use namespace::autoclean;
10
11 BEGIN { extends 'Gitalist::Controller' }
12
13 sub opml : Chained('/base') Args(0) {
14     my ($self, $c) = @_;
15
16     my $opml = XML::OPML::SimpleGen->new();
17
18     $opml->head(title => lc(hostname()) . ' - ' . blessed($c)->config->{name});
19
20     for my $repos ( $c->model()->repositories->flatten ) {
21         $opml->insert_outline(
22             text   => $repos->name. ' - '. $repos->description,
23             xmlUrl => $c->uri_for_action('/repository/rss', [$repos->name]),
24         );
25     }
26
27     $c->response->body($opml->as_string);
28     $c->response->content_type('application/rss');
29 }
30
31 __PACKAGE__->meta->make_immutable;