Permalink
Browse files

add another rss feed listing all the events

  • Loading branch information...
1 parent 8a3b2d5 commit 22e1ad42c365da7066979aeecc1048e598355434 @szabgab committed Mar 6, 2011
Showing with 23 additions and 7 deletions.
  1. +22 −7 lib/PEG.pm
  2. +1 −0 views/layouts/main.tt
View
@@ -81,14 +81,21 @@ get '/rss/news' => sub {
return _rss('news');
};
+get '/rss/events' => sub {
+ return _rss('events');
+};
+
sub _rss {
+ my $name = shift;
+
my $rss = XML::RSS->new( version => '1.0' );
my $year = 1900 + (localtime)[5];
- my $url = 'http://perl-ecosystem.org';
+ my $base = "http://perl-ecosystem.org";
+ my $url = "$base/$name";
$rss->channel(
- title => "Perl Ecosystem Group",
- link => "$url/",
+ title => "Perl Ecosystem Group $name",
+ link => $url,
description => 'Bridging the gap between business and the open source Perl community',
dc => {
language => 'en-us',
@@ -103,13 +110,21 @@ sub _rss {
}
);
- foreach my $n (@{ _content()->{news}{news} }) {
- my $text = $n->{text};
- $text =~ s{"/}{"$url/}g;
+ foreach my $n (@{ _content()->{$name}{$name} }) {
+ my $text = $n->{text} || '';
+ $text =~ s{"/}{"$base/}g;
+
+ if ($name eq 'events') {
+ if ($n->{days} == 1) {
+ $text = "On $n->{date}";
+ } else {
+ $text = "starting on $n->{date} for $n->{days} days";
+ }
+ }
$rss->add_item(
title => decode( 'utf-8', $n->{title} ),
- link => $url . ( $n->{permalink} || '/news' ),
+ link => $url . ( $n->{permalink} || '' ),
description => decode( 'utf-8', $text ),
dc => {
creator => $n->{author},
@@ -9,6 +9,7 @@
<meta name="keywords" content="Perl, training, consulting, business, community, promotion, advocacy" />
<meta name="description" content="<% template.description %>" />
<link href="/rss/news" rel="alternate" type="application/rss+xml" title ="Perl Ecosystem Group News" />
+ <link href="/rss/events" rel="alternate" type="application/rss+xml" title ="Perl Ecosystem Group Events" />
</head>
<body>

0 comments on commit 22e1ad4

Please sign in to comment.