--- mail2lj/mail2lj.pl 2007/08/13 15:06:38 1.3 +++ mail2lj/mail2lj.pl 2007/08/14 05:38:33 1.5 @@ -139,6 +139,7 @@ my $Parse = GetOptions( \%Opt, 'prop_opt_backdated|backdated|back-dated|backdate|back-date|back!', 'subject|subj|s=s', 'taglist|tags|tag|t=s' => \@opt_taglist, # Will tweak + 'notaglist|notags|notag|not|no-taglist|no-tags|no-tag|no-t' => sub {undef @opt_taglist}, 'usejournal|use-journal|use|journal|j=s', 'prop_current_mood|current_mood|mood=s', 'prop_current_music|current_music|music=s', @@ -206,7 +207,13 @@ if ( exists $Opt{'comments'} ) { # with other parameters. $Opt{'prop_taglist'} = join( ", ", @opt_taglist ) if ( @opt_taglist ) ; -# Convert all command line options to unicode. +# Convert $opt_ljcut_text to UTF8. +if ( defined $opt_ljcut_text ) { + $opt_ljcut_text = + to_utf8({ -string => $opt_ljcut_text, -charset => $SystemCharset }) ; +} + +# Convert all %Opt command line options to unicode. # Function href2utf8() uses a reference to input hash, so %Opt is # being modified "in-place". href2utf8( \%Opt, $SystemCharset) ; @@ -522,7 +529,12 @@ sub post_body2href { # Changed by LG - added 'tags' option. } elsif ($var =~ /^tags?$/ || $var eq "taglist") { - $req_data->{prop_taglist} = $val; + $req_data->{prop_taglist} = $val; + + # Changed by LG - added 'notags' option. Empty the preceding + # taglist if set to true, otherwise do nothing + } elsif ($var =~ /^no-?tags?$/ || $var eq "no-?taglist") { + $req_data->{prop_taglist} = "" if $val =~ /^\s*((on)|(yes))\s*$/i ; # Anything else - just assign. } else { @@ -598,8 +610,18 @@ sub post_me2req { # Changed by LG - added options to add the 'From' field to the # posted message. + # + # NOTE: $from is already in UTF8. Strictly speaking, everything + # that we add to it MUST ALSO BE IN UTF8 (i.e. you need to run + # a to_utf8() function on it). But since all I'm adding is in + # ISO-8859-1 lower ASCII characters (which are guaranteed to + # have the same values in UTF8 as in plain ISO-8859-1), I'm + # cheating here and taking a shortcut. If you want to add + # something non-ASCII, you MUST convert it to UTF8 first! + # Be forewarned! if ( $opt_addfrom ) { $hr->{event} = "From: $from" . "\n\n" . $hr->{event} ; + $hr->{event} = $plain_from . $hr->{event} ; } elsif ( $opt_addfromh ) { my $html_from = "From: $from" ; $html_from =~ s/\@/[_\@_]/g ; @@ -898,6 +920,12 @@ Options: single or double quotes to protect from the shell. Multiple '-t' options are allowed and taglists will be combined. +--notaglist, --notags + Unsets all previously defined tags. Thus, a call to + $shortname ... --tags X --tags Y ... --notags --tags Z + will yield a taglist consisting of just "Z". This option is + rarely needed and added only for the sake of completeness. + -d DATE, --date DATE Label posting with this date. Date should be in LiveJournal's format: DD.MM.YYYY HH:mm. If absent, current date/time is used. @@ -1007,6 +1035,7 @@ command line options), they should look Security: private Subject: Rzhevskij zhiv! Tags: Junk, Viva Rzhevskij! + Notags: yes # Clears all preceding tags Formatted: on # Or equivalent "Autoformat: off" Usejournal: gusary Mood: okay