]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
sketch for two stage workflow
authorDavid Bremner <bremner@unb.ca>
Mon, 11 Aug 2008 01:59:56 +0000 (22:59 -0300)
committerDavid Bremner <bremner@unb.ca>
Mon, 11 Aug 2008 12:18:36 +0000 (09:18 -0300)
filters/postal-deliver.pl [new file with mode: 0644]
filters/postal-filer.pl [deleted file]
filters/postal-queue.pl [new file with mode: 0644]

diff --git a/filters/postal-deliver.pl b/filters/postal-deliver.pl
new file mode 100644 (file)
index 0000000..eb696c2
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/perl
+
+use Email::Filter;
+use Convert::YText qw(decode_ytext encode_ytext);
+
+# we need at least version 2.54 of IkiWiki for the new config api
+BEGIN { require IkiWiki; die unless ($IkiWiki::version >= 2.54) }
+
+use IkiWiki::Setup;
+use Getopt::Long;
+
+my $config_file=undef;
+
+GetOptions('config=s'=>\$config_file);
+
+die "configuration file is mandatory" unless ($config_file);
+
+my %config=IkiWiki::Setup::load($config_file);
+
+my $maildir=$config{postal_maildir} || die "maildir not set";
+
+my $prefix=$config{postal_prefix} || die "prefix not set";
+
+$mail=Email::Filter->new(emergency => $maildir);
+
+my $to=$mail->to;
+if ($to =~ m/$prefix($Convert::YText::valid_rex)/){
+    my $key=decode_ytext($1);
+
+    $mail->simple->header_set('X-IkiPostal-Key',$key);
+
+    # need to somehow escape the names. Here we use the fact that YText 
+    # cannot have @ signs.
+    my @path=split(qr{/},$key);
+    map { $_=encode_ytext($_); s/\./@/g } @path;
+    
+    my $mailbox=$maildir . ".".join(".",@path)."/" ;
+    
+    $mail->accept($mailbox);
+
+
+};
+
+
diff --git a/filters/postal-filer.pl b/filters/postal-filer.pl
deleted file mode 100644 (file)
index 60fdec6..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/perl
-
-use Email::Filter;
-use Convert::YText qw(decode_ytext encode_ytext);
-
-# we need at least version 2.54 of IkiWiki for the new config api
-BEGIN { require IkiWiki; die unless ($IkiWiki::version >= 2.54) }
-
-use IkiWiki::Setup;
-use Getopt::Long;
-
-my $config_file=undef;
-
-GetOptions('config=s'=>\$config_file);
-
-die "configuration file is mandatory" unless ($config_file);
-
-my %config=IkiWiki::Setup::load($config_file);
-
-my $maildir=$config{postal_maildir} || die "maildir not set";
-
-my $prefix=$config{postal_prefix} || die "prefix not set";
-
-$mail=Email::Filter->new(emergency => $maildir);
-
-my $to=$mail->to;
-if ($to =~ m/$prefix($Convert::YText::valid_rex)/){
-    my $key=decode_ytext($1);
-
-    $mail->simple->header_set('X-IkiPostal-Key',$key);
-
-    # need to somehow escape the names. Here we use the fact that YText 
-    # cannot have @ signs.
-    my @path=split(qr{/},$key);
-    map { $_=encode_ytext($_); s/\./@/g } @path;
-    
-    my $mailbox=$maildir . "/.".join(".",@path)."/" ;
-    
-    $mail->accept($mailbox);
-
-
-};
-
-
diff --git a/filters/postal-queue.pl b/filters/postal-queue.pl
new file mode 100644 (file)
index 0000000..44d3b77
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+
+use Email::Folder;
+use Convert::YText qw(decode_ytext encode_ytext);
+
+# we need at least version 2.54 of IkiWiki for the new config api
+BEGIN { require IkiWiki; die unless ($IkiWiki::version >= 2.54) }
+
+use IkiWiki::Setup;
+use Getopt::Long;
+use Carp;
+
+my $config_file=undef;
+
+GetOptions('config=s'=>\$config_file);
+
+die "configuration file is mandatory" unless ($config_file);
+
+my %config=IkiWiki::Setup::load($config_file);
+
+my $queue=$config{queue} || croak("missing queue location");
+
+my $folder=Email::Folder->new($path,reader=>'Email::Folder::maildir') 
+    || croak("mailbox could not be opened");
+
+for my $messages  ($folder->messages){
+
+    my $to=$message->to;
+    if ($to =~ m/$prefix($Convert::YText::valid_rex)/){
+       my $page=decode_ytext($1);
+       
+       # sanity check the page path
+       
+       # check if comments folder exists, create if needed
+
+       # write the message to the folder
+
+       $msg_file= $comment_folder->write($message);
+
+       # update vcs
+    
+       IkiWIki::rcs_add($msg_file);
+       
+       # tag for deletion
+       
+       push (@must_die, $message->message-id);
+       
+       $folder->delete($message);
+           
+    }
+    # make regex for message-id
+
+    # called delete_message from Email::Delete
+}
+