source: server/trunk/web/lib/Sophie/Controller/Feed/Distrib.pm @ 422

Last change on this file since 422 was 280, checked in by nanardon, 13 years ago
  • Feed output only last month
File size: 1.8 KB
Line 
1package Sophie::Controller::Feed::Distrib;
2use Moose;
3use namespace::autoclean;
4
5BEGIN {extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9Sophie::Controller::Feed::Distrib - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19
20=head2 index
21
22=cut
23
24sub index :Path :Args(0) {
25    my ( $self, $c ) = @_;
26
27    $c->response->body('Matched Sophie::Controller::Feed::Distrib in Feed::Distrib.');
28}
29
30sub distrib :Path :Args {
31    my ( $self, $c, $distrib, $release, $arch ) = @_;
32    $c->stash->{dist}{distribution} = $distrib;
33    $c->stash->{dist}{release} = $release;
34    $c->stash->{dist}{arch} = $arch;
35
36    $c->forward('/distrib/exists', [ $c->stash->{dist} ]) or
37        $c->go('/404/index');
38}
39
40sub end : Private {
41    my ( $self, $c ) = @_;
42    $c->stash->{current_view} = 'Rss';
43    $c->stash->{rss} = $c->model('Rss');
44    foreach my $item (@{ $c->forward(
45        '/search/rpms/bydate',
46        [
47            {
48                %{ $c->stash->{dist} || {}},
49                src => 1,
50                rows => 50,
51            }, time - (3600 * 24 * 30)
52        ]
53    ) }) {
54        my $info = $c->forward('/rpms/basicinfo', [ $item->{pkgid} ]);
55        $c->stash->{rss}->add_item(
56            title => $item->{filename},
57            permaLink => $c->uri_for('/distrib', $item->{distribution},
58                $item->{release}, $item->{arch}, 'by-pkgid', $item->{pkgid}),
59            guid => $item->{pkgid},
60            description => "In " . join('/', $item->{distribution},
61                $item->{release}, $item->{arch}) . ":\n" .
62                $info->{description},
63        );
64    }
65
66    $c->forward('/feed/end');
67}
68
69=head1 AUTHOR
70
71Olivier Thauvin
72
73=head1 LICENSE
74
75This library is free software. You can redistribute it and/or modify
76it under the same terms as Perl itself.
77
78=cut
79
80__PACKAGE__->meta->make_immutable;
81
821;
Note: See TracBrowser for help on using the repository browser.