Changeset 1621
- Timestamp:
- 08/29/06 02:11:44
- Files:
-
- branches/hackathon-summary/plagger (modified) (previous)
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Notify/Audio.pm (modified) (1 diff)
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/CSV.pm (modified) (2 diffs)
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/Delicious.pm (modified) (1 diff)
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/Feed.pm (modified) (2 diffs)
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/HatenaBookmark.pm (modified) (1 diff)
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/IMAP.pm (modified) (1 diff)
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/JavaScript.pm (modified) (2 diffs)
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/LivedoorClip.pm (modified) (1 diff)
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/Maildir.pm (modified) (1 diff)
- branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/PowerPoint.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/hackathon-summary/plagger/lib/Plagger/Plugin/Notify/Audio.pm
r1406 r1621 22 22 $context->register_hook( 23 23 $self, 24 'publish.entry .fixup' => \&update,24 'publish.entry' => \&update, 25 25 'publish.finalize' => \&finalize, 26 26 ); branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/CSV.pm
r304 r1621 28 28 } 29 29 30 my $file = $self->gen_filename($args->{feed}) || $args->{feed}->id . ".csv";30 my $file = Plagger::Util::filename_for($args->{feed}, $self->conf->{filename} || "%i.csv"); 31 31 my $path = File::Spec->catfile($dir, $file); 32 32 my $io = IO::File->new($append ? ">> $path" : "> $path"); … … 53 53 utf8::decode($str) unless utf8::is_utf8($str); 54 54 return encode($self->conf->{encoding} || 'utf8', $str); 55 }56 57 my %formats = (58 'u' => sub { my $s = $_[0]->url; $s =~ s!^https?://!!; $s },59 'l' => sub { my $s = $_[0]->link; $s =~ s!^https?://!!; $s },60 't' => sub { $_[0]->title },61 'i' => sub { $_[0]->id },62 );63 64 my $format_re = qr/%(u|l|t|i)/;65 66 sub gen_filename {67 my($self, $feed) = @_;68 69 my $file = $self->conf->{filename} || '';70 $file =~ s{$format_re}{71 $self->safe_filename($formats{$1}->($feed))72 }egx;73 74 $file;75 }76 77 sub safe_filename {78 my($self, $path) = @_;79 $path =~ s![^\w\s]+!_!g;80 $path =~ s!\s+!_!g;81 $path;82 55 } 83 56 branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/Delicious.pm
r647 r1621 10 10 $context->register_hook( 11 11 $self, 12 'p ublish.init'=> \&initialize,13 'publish.entry .fixup' => \&add_entry,12 'plugin.init' => \&initialize, 13 'publish.entry' => \&add_entry, 14 14 ); 15 15 } 16 17 sub rule_hook { 'publish.entry' } 16 18 17 19 sub initialize { branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/Feed.pm
r1236 r1621 107 107 108 108 # generate file path 109 my $filepath = File::Spec->catfile($self->conf->{dir}, $self->gen_filename($f)); 109 my $tmpl = '%i.' . ($feed_format eq 'RSS' ? 'rss' : 'atom'); 110 my $file = Plagger::Util::filename_for($f, $self->conf->{filename} || $tmpl); 111 my $filepath = File::Spec->catfile($self->conf->{dir}, $file); 110 112 111 113 $context->log(info => "save feed for " . $f->link . " to $filepath"); … … 116 118 print $output $xml; 117 119 close $output; 118 }119 120 my %formats = (121 'u' => sub { my $s = $_[0]->url; $s =~ s!^https?://!!; $s },122 'l' => sub { my $s = $_[0]->link; $s =~ s!^https?://!!; $s },123 't' => sub { $_[0]->title },124 'i' => sub { $_[0]->id },125 );126 127 my $format_re = qr/%(u|l|t|i)/;128 129 sub gen_filename {130 my($self, $feed) = @_;131 132 my $file = $self->conf->{filename} ||133 '%i.' . ($self->conf->{format} eq 'RSS' ? 'rss' : 'atom');134 $file =~ s{$format_re}{135 $self->safe_filename($formats{$1}->($feed))136 }egx;137 $file;138 }139 140 sub safe_filename {141 my($self, $path) = @_;142 $path =~ s![^\w\s]+!_!g;143 $path =~ s!\s+!_!g;144 $path;145 120 } 146 121 branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/HatenaBookmark.pm
r746 r1621 12 12 $context->register_hook( 13 13 $self, 14 'p ublish.init'=> \&initialize,15 'publish.entry .fixup' => \&add_entry,14 'plugin.init' => \&initialize, 15 'publish.entry' => \&add_entry, 16 16 ); 17 17 } 18 18 19 sub rule_hook { 'publish.entry .fixup' }19 sub rule_hook { 'publish.entry' } 20 20 21 21 sub initialize { branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/IMAP.pm
r1173 r1621 17 17 $context->register_hook( 18 18 $self, 19 'p ublish.init' => \&initialize,20 'publish.entry .fixup' => \&store_entry,19 'plugin.init' => \&initialize, 20 'publish.entry' => \&store_entry, 21 21 'publish.finalize' => \&finalize, 22 22 ); 23 23 } 24 25 sub rule_hook { 'publish.entry' } 24 26 25 27 sub initialize { branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/JavaScript.pm
r1173 r1621 27 27 my($self, $context, $args) = @_; 28 28 29 my $file = $self->gen_filename($args->{feed}, $self->conf->{filename} || '%i.js');29 my $file = Plagger::Util::filename_for($args->{feed}, $self->conf->{filename} || '%i.js'); 30 30 my $path = File::Spec->catfile($self->conf->{dir}, $file); 31 31 $context->log(info => "writing output to $path"); … … 36 36 print $out $body; 37 37 close $out; 38 }39 40 my %formats = (41 'u' => sub { my $s = $_[0]->url; $s =~ s!^https?://!!; $s },42 'l' => sub { my $s = $_[0]->link; $s =~ s!^https?://!!; $s },43 't' => sub { $_[0]->title },44 'i' => sub { $_[0]->id },45 );46 47 my $format_re = qr/%(u|l|t|i)/;48 49 sub gen_filename {50 my($self, $feed, $file) = @_;51 52 $file =~ s{$format_re}{53 $self->safe_filename($formats{$1}->($feed))54 }egx;55 56 $file;57 }58 59 sub safe_filename {60 my($self, $path) = @_;61 $path =~ s![^\w\s]+!_!g;62 $path =~ s!\s+!_!g;63 $path;64 38 } 65 39 branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/LivedoorClip.pm
r1081 r1621 12 12 $context->register_hook( 13 13 $self, 14 'publish.entry .fixup' => \&add_entry,15 'publish.init' => \&initialize,14 'publish.entry' => \&add_entry, 15 'publish.init' => \&initialize, 16 16 ); 17 17 } branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/Maildir.pm
r1173 r1621 12 12 use File::Find; 13 13 14 our $VERSION = '0.3';15 16 14 sub register { 17 15 my($self, $context) = @_; 18 16 $context->register_hook( 19 17 $self, 20 'p ublish.init'=> \&initialize,21 'publish.entry .fixup' => \&store_entry,22 'publish.finalize' => \&finalize,18 'plugin.init' => \&initialize, 19 'publish.entry' => \&store_entry, 20 'publish.finalize' => \&finalize, 23 21 ); 24 22 } 23 24 sub rule_hook { 'publish.entry' } 25 25 26 26 sub initialize { branches/hackathon-summary/plagger/lib/Plagger/Plugin/Publish/PowerPoint.pm
r1432 r1621 12 12 $context->register_hook( 13 13 $self, 14 'publish.init' => \&connect_powerpoint,15 14 'publish.feed' => \&publish_presentation, 15 'publish.init' => \&connect_powerpoint, 16 16 ); 17 17 } … … 45 45 # generate file path; 46 46 my $file = File::Spec->catfile( 47 $self->conf->{dir}, $self->gen_filename($feed)47 $self->conf->{dir}, Plagger::Util::filename_for($feed, $self->conf->{filename} || '%i.pps'), 48 48 ); 49 49 … … 65 65 $context->log(debug => "hello, PowerPoint"); 66 66 $self->{powerpoint} = Win32::PowerPoint->new; 67 }68 69 # stolen from ::Publish::Feed70 71 my %formats = (72 'u' => sub { my $s = $_[0]->url; $s =~ s!^https?://!!; $s },73 'l' => sub { my $s = $_[0]->link; $s =~ s!^https?://!!; $s },74 't' => sub { $_[0]->title },75 'i' => sub { $_[0]->id },76 );77 78 my $format_re = qr/%(u|l|t|i)/;79 80 sub gen_filename {81 my($self, $feed) = @_;82 83 my $file = $self->conf->{filename} || '%i.pps';84 $file =~ s{$format_re}{85 $self->safe_filename($formats{$1}->($feed))86 }egx;87 $file;88 }89 90 sub safe_filename {91 my($self, $path) = @_;92 $path =~ s![^\w\s]+!_!g;93 $path =~ s!\s+!_!g;94 $path;95 67 } 96 68
