From: David Bremner Date: Mon, 11 Aug 2008 01:59:56 +0000 (-0300) Subject: sketch for two stage workflow X-Git-Tag: 0.1~39 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/e90373964cc123fdbd98a27a3b69cd8b0d8ecdef sketch for two stage workflow --- diff --git a/filters/postal-deliver.pl b/filters/postal-deliver.pl new file mode 100644 index 000000000..eb696c2b3 --- /dev/null +++ b/filters/postal-deliver.pl @@ -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 index 60fdec6ee..000000000 --- a/filters/postal-filer.pl +++ /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 index 000000000..44d3b7700 --- /dev/null +++ b/filters/postal-queue.pl @@ -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 +} +