[prev] [thread] [next] [lurker] [Date index for 2003/07/30]
Author: simon Date: 2003-07-30 13:23:20 +0100 (Wed, 30 Jul 2003) New Revision: 1267 Added: trunk/siesta/t/10plugin_messagefooter.t Modified: trunk/siesta/Build.PL trunk/siesta/bin/bandito trunk/siesta/t/20fullsend.t Log: Add in stuff for list footers Modified: trunk/siesta/Build.PL ============================================================================== --- trunk/siesta/Build.PL 2003-07-28 19:10:09 UTC (rev 1266) +++ trunk/siesta/Build.PL 2003-07-30 12:23:20 UTC (rev 1267) @@ -7,8 +7,9 @@ license => 'perl', scripts => [ 'bin/tequila', 'bin/nacho' ], requires => { 'Test::More' => 0, + 'Apache::Session::SharedMem' => 0, 'Class::Accessor::Fast' => 0, - 'Mail::Address' => 0, + 'Digest::MD5' => 0, 'Email::Simple' => '1.4', 'Email::LocalDelivery' => '0.05', 'Class::DBI::BaseDSN' => 0, @@ -16,17 +17,17 @@ 'File::Path' => 0, 'File::Basename' => 0, 'File::Find::Rule' => 0, - 'UNIVERSAL::require' => 0, - 'Template' => 0, - 'Digest::MD5' => 0, + 'Mail::Address' => 0, 'Mail::DeliveryStatus::BounceParser' => 0, # Module::Build 0.18 is the first release with # working scripts shebang rewriting 'Module::Build' => '0.18', + 'Storable' => 0, 'String::ShellQuote' => 0, + 'Sys::Hostname' => 0, 'Tie::IxHash' => 0, - 'Storable' => 0, - 'Apache::Session::SharedMem' => 0, + 'Template' => 0, + 'UNIVERSAL::require' => 0, }, create_makefile_pl => 'passthrough', dynamic_config => 1, Modified: trunk/siesta/bin/bandito ============================================================================== --- trunk/siesta/bin/bandito 2003-07-28 19:10:09 UTC (rev 1266) +++ trunk/siesta/bin/bandito 2003-07-30 12:23:20 UTC (rev 1267) @@ -4,8 +4,10 @@ use Siesta; use Siesta::List; use Siesta::Member; + use Python::Serialise::Marshal; -use Data::Dumper; +use Email::Folder; +use Email::LocalDelivery; use POSIX qw/strftime/; @@ -28,7 +30,8 @@ importing them into Siesta. At the moment it only does Mailman but will eventually also do Ezmlm and Majordomo and anything else people want. -It handles most thing - however it won't be able to handle things like +It handles most thing - including moving your old archives across and +setting up the list footers. However it won't be able to handle things like digest members until Siesta gets digests. See the TODO section below. @@ -37,12 +40,14 @@ =over 4 -=item move archives across +=item digest members -=item sig gussying +=item welcome/farewell messages -=item digest members +=item max message size +=item bouncing + =back =head1 COPYRIGHT @@ -118,7 +123,7 @@ print "Adding plugins : "; -my @plugins = qw(Debounce MembersOnly Moderated ListHeaders ReplyTo SubjectTag Send Archive); +my @plugins = qw(Debounce MembersOnly Moderated ListHeaders ReplyTo SubjectTag MessageFooter Send Archive); print join ", ", @plugins; print "\n\n"; $list->set_plugins( post => @plugins ); @@ -157,10 +162,53 @@ $plugins{'Moderated'}->pref('tell_user', 1); +# the message footer +my $footer = $data->{'msg_footer'}; +if ($footer && $footer !~ /^\s+$/m) { + $footer =~ s!%\(([^\)]+)\)!\[% $1 %\]!gm; + $plugins{'MessageFooter'}->pref('footer',$footer); +} + +foreach my $key (qw(info description web_page_url host_name cgiext)) { + my $val = $data->{$key}; + $plugins{'MessageFooter'}->pref($key, $val) + if ($val && $val !~ /^\s+$/m); + +} +$plugins{'MessageFooter'}->pref('description',$data->{'description'}); +print "MessageFooter => ",$data->{'description'},"\n"; + + # now copy across the archives +# where are we going to get the mails from +my $in = $data->{'public_archive_file_dir'}; +my $folder = Email::Folder->new($in); +unless($folder) { + warn "Couldn't open '$in' to read archives from\n"; + goto FAIL; +} +# work out where to stick them +my $name = $list->name; +my $path = "$Siesta::Config::ARCHIVE/$name/"; + +# and then deliver each one +foreach my $mail ($folder->messages()) { + unless (Email::LocalDelivery->deliver( $mail->as_string, $path )) { + warn "local delivery into '$path' failed - couldn't copy archives from '$in'\n"; + goto FAIL; + } +} + +# yay! +print "Successfully copied archives from '$in' to '$path'\n"; + +# erk +FAIL: + + print "\n\nNow paste this into your aliases file :\n\n\n"; print $list->alias("bandito (the Siesta config stealing tool)"); Added: trunk/siesta/t/10plugin_messagefooter.t ============================================================================== --- trunk/siesta/t/10plugin_messagefooter.t 2003-07-28 19:10:09 UTC (rev 1266) +++ trunk/siesta/t/10plugin_messagefooter.t 2003-07-30 12:23:20 UTC (rev 1267) @@ -0,0 +1,47 @@ +#!perl -w +# $Id: $ +use strict; +use Test::More tests => 6; +use lib qw(t/lib); +use Siesta::Test; + +use Sys::Hostname; + +use Siesta::List; +use Siesta::Plugin::MessageFooter; + +my %message; + +my $list = Siesta::List->load('dealers'); +my $plugin = Siesta::Plugin::MessageFooter->new( queue => 'test', + list => $list ); + +my $list_id = $list->name; +my $hostname = hostname(); + + +my $message = new_mail(); +$plugin->pref("footer","List footer for [% real_name %]"); +ok( !$plugin->process($message), "processed mail" ); +like( $message->body(), qr{List footer for $list_id}, "added list name" ); + +$message = new_mail(); +$plugin->pref("footer","[% host_name %]"); +ok( !$plugin->process($message)); +like( $message->body(), qr{$hostname}, "added host name" ); + + +$message = new_mail(); +$plugin->pref("host_name","a random host name "); +ok( !$plugin->process($message)); +like( $message->body(), qr{a random host name}, "overrode host name" ); + + + +sub new_mail { +return Siesta::Message->new(<<'MAIL'); +From: dante@quick-stop + +yoohoo +MAIL +} Modified: trunk/siesta/t/20fullsend.t ============================================================================== --- trunk/siesta/t/20fullsend.t 2003-07-28 19:10:09 UTC (rev 1266) +++ trunk/siesta/t/20fullsend.t 2003-07-30 12:23:20 UTC (rev 1267) @@ -17,6 +17,7 @@ }); for (Siesta->available_plugins) { print "# adding $_\n"; + next if $_ =~ /Footer/; $list->add_plugin( post => $_ ); } }
Generated at 13:57 on 01 Jul 2004 by mariachi 0.52