Changeset 1521
- Timestamp:
- 08/20/06 20:29:02
- Files:
-
- branches/hackathon-summary/plagger/lib/Plagger/Content.pm (added)
- branches/hackathon-summary/plagger/lib/Plagger/Entry.pm (modified) (2 diffs)
- branches/hackathon-summary/plagger/lib/Plagger/Feed.pm (modified) (3 diffs)
- branches/hackathon-summary/plagger/lib/Plagger/Thing.pm (modified) (2 diffs)
- branches/hackathon-summary/plagger/t/core/content.t (added)
- branches/hackathon-summary/plagger/t/core/title_text.t (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/hackathon-summary/plagger/lib/Plagger/Entry.pm
r1173 r1521 3 3 4 4 use base qw( Plagger::Thing ); 5 __PACKAGE__->mk_accessors(qw( title author tags link feed_link id summary body rate icon meta source )); 5 __PACKAGE__->mk_accessors(qw( tags link feed_link id rate icon meta source )); 6 __PACKAGE__->mk_content_accessors(qw( title author summary body )); 6 7 __PACKAGE__->mk_date_accessors(qw( date )); 7 8 … … 63 64 sub title_text { 64 65 my $self = shift; 65 Plagger::Util::strip_html($self->title);66 $self->title->plaintext; 66 67 } 67 68 68 69 sub body_text { 69 70 my $self = shift; 70 Plagger::Util::strip_html($self->body || '');71 $self->body->plaintext; 71 72 } 72 73 branches/hackathon-summary/plagger/lib/Plagger/Feed.pm
r1386 r1521 3 3 4 4 use base qw( Plagger::Thing ); 5 __PACKAGE__->mk_accessors(qw( link url image description language author tags meta type source_xml aggregator )); 5 __PACKAGE__->mk_accessors(qw( link url image language tags meta type source_xml aggregator )); 6 __PACKAGE__->mk_content_accessors(qw( description author title )); 6 7 __PACKAGE__->mk_date_accessors(qw( updated )); 7 8 … … 42 43 } 43 44 44 sub title {45 my $self = shift;46 if (@_) {47 my $title = shift;48 utf8::decode($title) unless utf8::is_utf8($title);49 $self->{title} = $title;50 }51 $self->{title};52 }53 54 45 sub id { 55 46 my $self = shift; … … 68 59 sub title_text { 69 60 my $self = shift; 70 Plagger::Util::strip_html($self->title);61 $self->title->plaintext; 71 62 } 72 63 branches/hackathon-summary/plagger/lib/Plagger/Thing.pm
r1024 r1521 2 2 use strict; 3 3 use base qw( Class::Accessor::Fast ); 4 5 use Plagger::Content; 4 6 5 7 sub has_tag { … … 43 45 } 44 46 47 sub mk_content_accessors { 48 my $class = shift; 49 for my $key (@_) { 50 no strict 'refs'; 51 *{"$class\::$key"} = sub { 52 my $obj = shift; 53 if (@_) { 54 my $content = $_[0]; 55 unless (ref($content)) { 56 $content = Plagger::Content->new_from_text($content); 57 } 58 $obj->{$key} = $content; 59 } else { 60 return $obj->{$key}; 61 } 62 }; 63 } 64 } 65 45 66 1;
