rev 1441 - in trunk: . Siesta-Plugin-Demime Siesta-Plugin-Demime/lib Siesta-Plugin-Demime/lib/Siesta Siesta-Plugin-Demime/lib/Siesta/Plugin

[prev] [thread] [next] [lurker] [Date index for 2003/10/17]

From: simon
Subject: rev 1441 - in trunk: . Siesta-Plugin-Demime Siesta-Plugin-Demime/lib Siesta-Plugin-Demime/lib/Siesta Siesta-Plugin-Demime/lib/Siesta/Plugin
Date: 16:33 on 17 Oct 2003
Author: simon
Date: 2003-10-17 16:33:54 +0100 (Fri, 17 Oct 2003)
New Revision: 1441

Added:
   trunk/Siesta-Plugin-Demime/
   trunk/Siesta-Plugin-Demime/Build.PL
   trunk/Siesta-Plugin-Demime/INSTALL
   trunk/Siesta-Plugin-Demime/MANIFEST
   trunk/Siesta-Plugin-Demime/MANIFEST.SKIP
   trunk/Siesta-Plugin-Demime/README
   trunk/Siesta-Plugin-Demime/lib/
   trunk/Siesta-Plugin-Demime/lib/Siesta/
   trunk/Siesta-Plugin-Demime/lib/Siesta/Plugin/
   trunk/Siesta-Plugin-Demime/lib/Siesta/Plugin/Demime.pm
   trunk/Siesta-Plugin-Demime/t/
Log:
Add in the new plugin


Added: trunk/Siesta-Plugin-Demime/Build.PL
===================================================================
--- trunk/Siesta-Plugin-Demime/Build.PL	2003-10-17 15:28:25 UTC (rev 1440)
+++ trunk/Siesta-Plugin-Demime/Build.PL	2003-10-17 15:33:54 UTC (rev 1441)
@@ -0,0 +1,15 @@
+use strict;
+use Module::Build;
+
+my $build = Module::Build
+  ->new( module_name => "Siesta::Plugin::Demime",
+         license     => 'perl',
+         requires    => {
+                          'Test::More'    => 0,
+                          'MIME::Parser'  => 0,
+                        },
+         create_makefile_pl => 'passthrough',
+       );
+
+$build->create_build_script;
+

Added: trunk/Siesta-Plugin-Demime/INSTALL
===================================================================
--- trunk/Siesta-Plugin-Demime/INSTALL	2003-10-17 15:28:25 UTC (rev 1440)
+++ trunk/Siesta-Plugin-Demime/INSTALL	2003-10-17 15:33:54 UTC (rev 1441)
@@ -0,0 +1,12 @@
+
+Same as practically every other Perl module ...
+
+        % perl Build.PL
+        % perl Build
+        % perl Build test
+        % sudo Build install
+
+N.B : If you don't already have Module::Build then running Makefile.PL
+will prompt you to install it.
+
+

Added: trunk/Siesta-Plugin-Demime/MANIFEST
===================================================================
--- trunk/Siesta-Plugin-Demime/MANIFEST	2003-10-17 15:28:25 UTC (rev 1440)
+++ trunk/Siesta-Plugin-Demime/MANIFEST	2003-10-17 15:33:54 UTC (rev 1441)
@@ -0,0 +1,5 @@
+Build.PL
+INSTALL
+lib/Siesta/Plugin/Demime.pm
+MANIFEST            This list of files
+README

Added: trunk/Siesta-Plugin-Demime/MANIFEST.SKIP
===================================================================
--- trunk/Siesta-Plugin-Demime/MANIFEST.SKIP	2003-10-17 15:28:25 UTC (rev 1440)
+++ trunk/Siesta-Plugin-Demime/MANIFEST.SKIP	2003-10-17 15:33:54 UTC (rev 1441)
@@ -0,0 +1,9 @@
+\.svn
+\.bak
+~$
+\.tar\.gz$
+\.mail
+MANIFEST.SKIP
+_build
+blib
+Build$

Added: trunk/Siesta-Plugin-Demime/README
===================================================================
--- trunk/Siesta-Plugin-Demime/README	2003-10-17 15:28:25 UTC (rev 1440)
+++ trunk/Siesta-Plugin-Demime/README	2003-10-17 15:33:54 UTC (rev 1441)
@@ -0,0 +1,7 @@
+NAME
+    Siesta::Plugin::Demime - strip out atatchments and store them somewhere
+
+DESCRIPTION
+COPYRIGHT
+    Copyright 2003 - Simon Wistow <simon@xxxxxxxxxx.xxx>
+

Added: trunk/Siesta-Plugin-Demime/lib/Siesta/Plugin/Demime.pm
===================================================================
--- trunk/Siesta-Plugin-Demime/lib/Siesta/Plugin/Demime.pm	2003-10-17 15:28:25 UTC (rev 1440)
+++ trunk/Siesta-Plugin-Demime/lib/Siesta/Plugin/Demime.pm	2003-10-17 15:33:54 UTC (rev 1441)
@@ -0,0 +1,88 @@
+package Siesta::Plugin::Demime;
+use strict;
+use Siesta::Plugin;
+use base 'Siesta::Plugin';
+use Siesta;
+use MIME::Parser;
+
+
+our $VERSION='0.1';
+
+sub description {
+    'Strip out attachments and store them somewhere';
+}
+
+our %ok_parts = map { $_ => 1 } ( "text/plain", "multipart/alternative");
+
+sub process {
+    my $self   = shift;
+    my $mail   = shift;
+    my $list   = $self->list;
+    my $parser = MIME::Parser->new;
+
+    $parser->output_under($self->pref('where'));
+
+    my $entity = $parser->parse($mail->as_string)
+    $entity->make_multipart;
+    
+    for ($entity->parts) {
+           if (exists($ok_parts{$_->mime_type})  and !$fn) {
+            $content = $_ unless $content;
+            push @body, @{$_->body};
+        } else {
+            my $fn = $_->head->recommended_filename;
+            my $fh = IO::File->new(">$fn") || die "Can't open $fn";;
+            $_->print($fh);
+        }
+    }
+    
+
+    if ($content) {
+        my $io;
+        if ($io = $content->open("w")) {
+           foreach (@body) { $io->print($_) }
+           $io->close;
+        }
+    } else { 
+        # Shit, no text at all
+        $content =  MIME::Entity->build(
+                Type        => "text/plain",
+                Data        => \@body
+        );
+    }
+    $entity->parts([$content]);
+    $entity->make_singlepart;
+    $mail->set_body($entity->body->stringify);
+    
+    return 1;
+}
+
+sub options {
+    +{
+      'where'
+      => {
+          description => "where we strip attachments out to",
+          type        => "string",
+          default     => "/tmp",
+         },
+}
+
+1;
+
+=pod
+
+=head1 NAME
+
+Siesta::Plugin::Demime - strip out atatchments and store them somewhere
+
+=head1 DESCRIPTION
+
+
+=head1 COPYRIGHT
+
+Copyright 2003 - Simon Wistow <simon@xxxxxxxxxx.xxx>
+
+
+=cut
+
+


Property changes on: trunk/Siesta-Plugin-Demime/lib/Siesta/Plugin/Demime.pm
___________________________________________________________________
Name: svn:executable
   + *

Generated at 13:57 on 01 Jul 2004 by mariachi 0.52