App-Syndicator
view release on metacpan or search on metacpan
lib/App/Syndicator/Message.pm view on Meta::CPAN
has xml_entry => (
is => 'rw',
);
method BUILDARGS(ClassName $class: Entry_T $entry) {
return $class->next::method({xml_entry => $entry});
}
method delete {
$self->title('');
$self->body('');
$self->star(0);
$self->is_deleted(1);
}
method BUILD {
if (my $entry = $self->xml_entry) {
$self->uri($entry->link);
$self->base_uri($entry->base) if defined $entry->base;
$self->author($entry->author)
if defined $entry->author;
my $title = $self->html_to_ascii($entry->title);
chomp $title;
$title =~ s/^\s+(.+)$/$1/;
$title =~ s/\s+/ /g;
$self->title($title);
$self->published(
$entry->modified || $entry->issued || DateTime->now
);
my $content = $entry->content->body;
my $summary = $entry->summary->body;
if (defined $content && length($content)) {
$self->body($self->html_to_ascii($content));
}
elsif (defined $summary && length($summary)) {
$self->body($self->html_to_ascii($summary))
}
else {
die "no body for this message!";
}
$self->id(
md5_base64(
$entry->id,
$self->published
)
);
$self->xml_entry(undef);
}
}
# should really be in a view.
method render_title {
return ($self->is_read ? '' : '<bold>[NEW] </bold>')
. ($self->star ? '<bold>[*] </bold>' : '')
. $self->title;
}
}
( run in 0.694 second using v1.01-cache-2.11-cpan-39bf76dae61 )