X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/c574e7b4220fb781030d42e80071fd6fab6a163a..796f5749859a1fa48ad068b5f2ab9889e0ae88e8:/ikiwiki-comment.in?ds=inline diff --git a/ikiwiki-comment.in b/ikiwiki-comment.in index eb22d6c0d..174647b06 100755 --- a/ikiwiki-comment.in +++ b/ikiwiki-comment.in @@ -1,7 +1,8 @@ #!/usr/bin/perl +no lib '.'; use warnings; use strict; -use lib '.'; # For use in nonstandard directory, munged by Makefile. +use FindBin; use lib $FindBin::Bin; # For use in nonstandard directory, munged by Makefile. use IkiWiki; use IkiWiki::Plugin::comments; use Getopt::Long; @@ -14,12 +15,15 @@ sub main { my $pagefile=shift || usage(); my $interactive = -t STDIN; my $content; - my ($format, $username, $subject, $date); + my ($format, $username, $subject, $date, $url, $email, $ip); GetOptions( 'format:s' => \$format, 'username:s' => \$username, 'subject:s' => \$subject, 'date:s' => \$date, + 'url:s' => \$url, + 'email:s' => \$email, + 'ip:s' => \$ip, ) || usage(); my $dir=get_dir($pagefile); @@ -32,15 +36,21 @@ sub main { $username ||= get_username(); $subject ||= get_subject($page, $dir); $date ||= IkiWiki::Plugin::comments::commentdate(); + $url ||= undef; + $email ||= undef; + $ip ||= undef; } else { $format ||= undef; die "must supply username" unless defined $username; $subject ||= get_subject($page, $dir); die "must supply date" unless defined $date; + $url ||= undef; + $email ||= undef; + $ip ||= undef; chomp($content = join('', )); } - my $comment=get_comment($format, $username, $subject, $date, $content); + my $comment=get_comment($format, $username, $subject, $date, $url, $email, $ip, $content); # For interactive use, this will yield a hash of the comment before # it's edited, but that's ok; the date provides sufficient entropy @@ -81,13 +91,16 @@ sub get_subject { } sub get_comment { - my ($format, $username, $subject, $date, $content) = @_; + my ($format, $username, $subject, $date, $url, $email, $ip, $content) = @_; $format = defined $format ? $format = " format=$format" : q{}; $content = '' unless defined $content; my $comment="[[!comment$format\n"; $comment.=" username=\"$username\"\n"; $comment.=" subject=\"\"\"$subject\"\"\"\n"; $comment.=" date=\"$date\"\n"; + $comment.=" url=\"$url\"\n" if defined $url; + $comment.=" email=\"$email\"\n" if defined $email; + $comment.=" ip=\"$ip\"\n" if defined $ip; $comment.=" content=\"\"\"\n$content\n\"\"\"]]\n"; return $comment; } @@ -103,7 +116,7 @@ sub exec_editor { @editor=split(' ', $ENV{EDITOR}); } if (exists $ENV{VISUAL}) { - @editor=split(' ', $ENV{VISUAL}); + @editor=split(' ', $ENV{VISUAL}); } exec(@editor, $file); }