--- mail2lj/mail2lj.pl 2007/08/12 19:54:44 1.1 +++ mail2lj/mail2lj.pl 2007/08/12 21:15:36 1.2 @@ -42,6 +42,8 @@ # Original script seems to be distributed as freeware, so I stick to that # decision. No warranty whatsoever, of course - use at your own risk ;-). # +# Changes by Boris Veytsman - added --cut option +# # ------------------------------------------------------------------------ use strict ; @@ -115,12 +117,14 @@ my %tr = ( # ------------------------------------------------------------------------ # # Changed by LG - added parsing of command line. +# Changed by BV - added options cur # ------------------------------------------------------------------------ # my %Opt = (); # Main options go here my $opt_h ; # Help flag my $opt_bounces ; # Alternative error recipient flag my $opt_addfrom ; # Add the From field to the post my $opt_addfromh ; # Add the htmlized From to the post +my $opt_ljcut ; # Add lj-cut after line number N my $opt_keepspaces ; # HTML-encode multiple spaces in e-mail my @opt_taglist ; # command-line taglist first goes here my $Parse = GetOptions( \%Opt, @@ -142,6 +146,7 @@ my $Parse = GetOptions( \%Opt, 'bounces|bounce|b=s' => \$opt_bounces, 'addfrom|add-from|from!' => \$opt_addfrom, 'addfromh|add-fromh|fromh!' => \$opt_addfromh, + 'ljcut|cut|l=s'=>\$opt_ljcut, 'keep-spaces|keep-space|keepspaces|keepspace|spaces|space!' => \$opt_keepspaces, 'help|h' => \$opt_h, ); @@ -215,7 +220,7 @@ my $mp = new MIME::Parser() or die "new # Changed by LG - changed directory. # $mp->output_dir("$home/mimetmp") ; -$mp->output_dir("/tmp/mimetmp-$ENV{user}") ; +$mp->output_dir("/tmp/mimetmp-".$ENV{user}) ; mkdir $mp->output_dir if not -d $mp->output_dir ; # Create it if missing # Get the whole mail. @@ -607,6 +612,22 @@ sub post_me2req { $hr->{event} =~ s/\t/\ \ \ \ \ \ \ \ /g ; $hr->{event} =~ s/ / \ /g ; } + + # + # Change by BV - added the option to put lj-cut after N + # + if ($opt_ljcut>0) { + my $start=0; + for (my $i=0; $i<$opt_ljcut; $i++) { + $start=index($hr->{event},"\n",$start)+1; + if ($start == 0) { + last; + } + } + if ($start>0) { + substr($hr->{event}, $start,0) = ''; + } + } $req->content_type('application/x-www-form-urlencoded'); $req->content(href2string $hr) ; @@ -923,6 +944,9 @@ Options: better preserved in the journal. The option can be negated ('--nospaces'). Default is '--nospaces'. +--ljcut, --cut, -l CUT + add after CUT lines. + --charset CHARSET This option tells the script that all COMMAND LINE options are given in this charset. Default is "$SystemCharset".