root/trunk/plagger/lib/Plagger/Plugin/Filter/TagsToTitle.pm

Revision 1432 (checked in by charsbar, 14 years ago)

remove $VERSION from several plugins

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 package Plagger::Plugin::Filter::TagsToTitle;
2 use strict;
3 use base qw( Plagger::Plugin );
4
5 sub register {
6     my ($self, $context) = @_;
7     $context->register_hook(
8         $self,
9         'update.feed.fixup' => \&filter,
10     );
11 }
12
13 sub filter {
14     my ($self, $context, $args) = @_;
15
16     my $add_to = $self->conf->{add_to} || 'left';
17
18     foreach my $entry ($args->{feed}->entries) {
19         my @tags  = $entry->tags ? map { "[$_]" } @{ $entry->tags } : ();
20         my $title = $entry->title;
21
22         # XXX: should I see (or erase) original tags? optional?
23         # my @orig = $title =~ /\[[^]]+\]\s*/g;
24         # $title =~ s/\[[^]]+\]\s*//g;
25
26         push    @tags, $title if $add_to eq 'left';
27         unshift @tags, $title if $add_to eq 'right';
28
29         $entry->title( join(' ', @tags) );
30     }
31 }
32
33 1;
34
35 __END__
36
37 =head1 NAME
38
39 Plagger::Plugin::Filter::TagsToTitle - add tags to entry title
40
41 =head1 SYNOPSIS
42
43   - module: Filter::TagsToTitle
44     config:
45       add_to: left
46
47 =head1 CONFIG
48
49 =over 4
50
51 =item add_to
52
53 Specify 'left' or 'right' of the title. Defaults to 'left'.
54
55 =back
56
57 =head1 AUTHOR
58
59 Kenichi Ishigaki
60
61 =head1 SEE ALSO
62
63 L<Plagger>
64
65 =cut
Note: See TracBrowser for help on using the browser.