| 1 | package XML::RSS::Headline::PerlMonks; | ||
| 2 | |||
| 3 | use 5.008005; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | our $VERSION = '0.02'; | ||
| 8 | |||
| 9 | use base 'XML::RSS::Headline'; | ||
| 10 | |||
| 11 | sub item { | ||
| 12 | my ($self,$item) = @_; | ||
| 13 | $self->SUPER::item($item); | ||
| 14 | |||
| 15 | my $key = "http://perlmonks.org/index.pl?node_id=393035"; | ||
| 16 | |||
| 17 | # seed with a default of unknown, this also keeps warnings happy. | ||
| 18 | $self->category( $item->{'category'} || 'Unknown' ); | ||
| 19 | $self->authortitle( $item->{$key}{'authortitle'} || 'Unknown' ); | ||
| 20 | $self->node_id( $item->{$key}{'node_id'} || 'Unknown' ); | ||
| 21 | $self->author_user( $item->{$key}{'author_user'} || 'Unknown' ); | ||
| 22 | $self->createtime( $item->{$key}{'createtime'} || 'Unknown' ); | ||
| 23 | } | ||
| 24 | |||
| 25 | sub authortitle { | ||
| 26 | my ($self,$authortitle) = @_; | ||
| 27 | $self->{'authortitle'} = $authortitle if $authortitle; | ||
| 28 | return $self->{'authortitle'}; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub author_user { | ||
| 32 | my ($self,$author_user) = @_; | ||
| 33 | $self->{'author_user'} = $author_user if $author_user; | ||
| 34 | return $self->{'author_user'}; | ||
| 35 | } | ||
| 36 | |||
| 37 | sub createtime { | ||
| 38 | my ($self,$createtime) = @_; | ||
| 39 | $self->{'createtime'} = $createtime if $createtime; | ||
| 40 | return $self->{'createtime'}; | ||
| 41 | } | ||
| 42 | |||
| 43 | sub node_id { | ||
| 44 | my ($self,$node_id) = @_; | ||
| 45 | $self->{'node_id'} = $node_id if $node_id; | ||
| 46 | return $self->{'node_id'}; | ||
| 47 | } | ||
| 48 | |||
| 49 | sub category { | ||
| 50 | my ($self,$category) = @_; | ||
| 51 | $self->{'category'} = $category if $category; | ||
| 52 | |||
| 53 | my %pretty = ( | ||
| 54 | 'perlquestion' => 'Seekers of Perl Wisdom', | ||
| 55 | 'perlmeditation' => 'Meditations', | ||
| 56 | 'obfuscated' => 'Obfuscation', | ||
| 57 | 'monkdiscuss' => 'PerlMonks Discussion', | ||
| 58 | 'snippet' => 'Snippets', | ||
| 59 | 'bookreview' => 'Reviews', | ||
| 60 | 'modulereview' => 'Reviews', | ||
| 61 | 'CUFP' => 'Cool Uses For Perl', | ||
| 62 | 'perlnews' => 'Perl News', | ||
| 63 | 'categorized question' => 'Q&A', | ||
| 64 | 'categorized answer' => 'Q&A', | ||
| 65 | 'QandASection' => 'Q&A', | ||
| 66 | 'sourcecode' => 'Code', | ||
| 67 | 'poem' => 'Poetry', | ||
| 68 | ); | ||
| 69 | |||
| 70 | return ( exists( $pretty{ $self->{'category'} } ) ) ? $pretty{ $self->{'category'} } : $self->{'category'}; | ||
| 71 | } | ||
| 72 | |||
| 73 | 1; | ||
| 74 | __END__ |