basic porting work for SCSite
[scpubgit/App-SCS.git] / lib / App / SCS / Plugin / Feeds.pm
CommitLineData
632f0e07 1package App::SCS::Plugin::Feeds;
2
3use Module::Runtime qw(use_module);
4use Moo;
5
6with 'App::SCS::Role::Plugin';
7
8has mount_at => (is => 'ro', default => sub { 'feed' });
9
10has generator => (
11 is => 'lazy',
12 handles => { _feed_http_response => 'feed_http_response' },
13);
14
15sub _build_generator {
16 my ($self) = @_;
17 use_module('App::SCS::Plugin::Feeds::Generator')->new(
18 pages => $self->pages,
19 mounted_at => $self->mount_at,
20 );
21}
22
23sub page_dispatchers {
24 my ($self) = @_;
25 my $base = $self->mount_at;
26 "/${base}/**/" => sub {
27 if (my $conf = $self->config->{$_[1]}) {
f50b4a35 28 $conf = { base => $_[1], %$conf };
632f0e07 29 $self->_feed_http_response(200 => $conf => $_[-1]);
30 }
31 },
32}
33
34sub provides_pages {
35 my ($self) = @_;
36 my $base = $self->mount_at;
37 return map "/${base}/$_/", keys %{$self->config};
38}
39
401;