root/trunk/plagger/lib/Plagger/Feed.pm

Revision 177 (checked in by miyagawa, 14 years ago)
  • Fixed tDiaryComment to strictly match with tDiary's feed, and strips comment entry rather than rating it
  • Added $feed->source_xml to get the raw XML
  • Property svn:keywords set to Id Revision
Line 
1 package Plagger::Feed;
2 use strict;
3
4 use base qw( Class::Accessor::Fast );
5 __PACKAGE__->mk_accessors(qw( link url image description language author updated tags meta type source_xml ));
6
7 use Digest::MD5 qw(md5_hex);
8 use Plagger::Util;
9
10 sub new {
11     my $class = shift;
12     bless {
13         meta  => {},
14         tags  => [],
15         entries => [],
16         type  => 'feed',
17     }, $class;
18 }
19
20 sub add_entry {
21     my($self, $entry) = @_;
22     push @{ $self->{entries} }, $entry;
23 }
24
25 sub delete_entry {
26     my($self, $entry) = @_;
27     my @entries = grep { $_ ne $entry } $self->entries;
28     $self->{entries} = \@entries;
29 }
30
31 sub entries {
32     my $self = shift;
33     wantarray ? @{ $self->{entries} } : $self->{entries};
34 }
35
36 sub count {
37     my $self = shift;
38     scalar @{ $self->{entries} };
39 }
40
41 sub title {
42     my $self = shift;
43     if (@_) {
44         my $title = shift;
45         utf8::decode($title) unless utf8::is_utf8($title);
46         $self->{title} = $title;
47     }
48     $self->{title};
49 }
50
51 sub id {
52     my $self = shift;
53     $self->{id} = shift if @_;
54     $self->{id} || Digest::MD5::md5_hex($self->url || $self->link);
55 }
56
57 sub title_text {
58     my $self = shift;
59     Plagger::Util::strip_html($self->title);
60 }
61
62 1;
Note: See TracBrowser for help on using the browser.