]> sipb.mit.edu Git - ikiwiki.git/blobdiff - ikiwiki-comment.in
Added my professional website
[ikiwiki.git] / ikiwiki-comment.in
index c742d7063fa89fc2de6358db06f64ae19bb5cd89..0891766ab6f154ae1f7977c49a58a7d86f44996b 100755 (executable)
@@ -14,12 +14,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);
@@ -31,16 +34,22 @@ sub main {
                $format         ||= 'mdwn';
                $username       ||= get_username();
                $subject        ||= get_subject($page, $dir);
-               $date           ||= get_date();
+               $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('', <STDIN>));
        }
 
-       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
@@ -80,21 +89,17 @@ sub get_subject {
        return "comment $comment_num";
 }
 
-sub get_date {
-       my $date = IkiWiki::Plugin::comments::commentdate();
-       $date =~ s|^date=\\"||;
-       $date =~ s|\\"$||;
-       return $date;
-}
-
 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;
 }