Changeset 238
- Timestamp:
- 08/25/06 13:41:23 (2 years ago)
- Files:
-
- plagger/trunk/lib/Plagger/Entry.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plagger/trunk/lib/Plagger/Entry.pm
r107 r238 3 3 4 4 use base qw( Plagger::Thing ); 5 __PACKAGE__->mk_accessors(qw( title author tags date link feed_link id summary body rate icon meta source enclosure )); 5 __PACKAGE__->mk_accessors(qw( title author tags link feed_link id summary body rate icon meta source )); 6 __PACKAGE__->mk_date_accessors(qw( date )); 6 7 7 8 use Digest::MD5; … … 13 14 my $class = shift; 14 15 bless { 15 rate => 0,16 widgets => [],17 tags => [],18 meta => {},19 enclosure => [],16 rate => 0, 17 widgets => [], 18 tags => [], 19 meta => {}, 20 enclosures => [], 20 21 }, $class; 21 22 } … … 67 68 sub body_text { 68 69 my $self = shift; 69 Plagger::Util::strip_html($self->body );70 Plagger::Util::strip_html($self->body || ''); 70 71 } 71 72 72 73 sub add_enclosure { 73 74 my($self, $enclosure) = @_; 74 push @{ $self->{enclosure} }, $enclosure; 75 76 # don't add enclosure with the same URL again and again 77 unless ($enclosure->url && grep { $_->url && $_->url eq $enclosure->url } $self->enclosures) { 78 push @{ $self->{enclosures} }, $enclosure; 79 } 80 } 81 82 sub enclosure { 83 my $self = shift; 84 wantarray ? @{$self->{enclosures}} : $self->{enclosures}->[0]; 85 } 86 87 sub enclosures { 88 my $self = shift; 89 wantarray ? @{$self->{enclosures}} : $self->{enclosures}; 90 } 91 92 sub has_enclosure { 93 my $self = shift; 94 scalar @{$self->{enclosures}} > 0; 95 } 96 97 sub digest { 98 my $self = shift; 99 my $data = $self->title . ($self->body || ''); 100 Encode::_utf8_off($data); 101 Digest::MD5::md5_hex($data); 75 102 } 76 103
