]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/comments.pm
_comment directive: if the user looks like an OpenID, store that
[ikiwiki.git] / IkiWiki / Plugin / comments.pm
index 3b87528941e4b6ffd8467b70e0d265400b6dd559..336ed1a823c6937b2c79b063fd8fc2aaf3209533 100644 (file)
@@ -151,11 +151,28 @@ sub preprocess {
        my $commentip;
        my $commentauthor;
        my $commentauthorurl;
+       my $commentopenid;
 
        if (defined $params{username}) {
                $commentuser = $params{username};
-               ($commentauthorurl, $commentauthor) =
-                       linkuser($params{username});
+
+               my $oiduser = eval { IkiWiki::openiduser($commentuser) };
+
+               if (defined $oiduser) {
+                       # looks like an OpenID
+                       $commentauthorurl = $commentuser;
+                       $commentauthor = $oiduser;
+                       $commentopenid = $commentuser;
+               }
+               else {
+                       $commentauthorurl = IkiWiki::cgiurl(
+                               do => 'commenter',
+                               page => (length $config{userdir}
+                                       ? "$config{userdir}/$commentuser"
+                                       : "$commentuser"));
+
+                       $commentauthor = $commentuser;
+               }
        }
        else {
                if (defined $params{ip}) {
@@ -165,6 +182,7 @@ sub preprocess {
        }
 
        $pagestate{$page}{comments}{commentuser} = $commentuser;
+       $pagestate{$page}{comments}{commentopenid} = $commentopenid;
        $pagestate{$page}{comments}{commentip} = $commentip;
        $pagestate{$page}{comments}{commentauthor} = $commentauthor;
        $pagestate{$page}{comments}{commentauthorurl} = $commentauthorurl;
@@ -194,7 +212,7 @@ sub preprocess {
        }
 
        if ($params{page} =~ m/\/(\Q$config{comments_pagename}\E\d+)$/) {
-               $pagestate{$page}{meta}{permalink} = urlto($params{destpage}, undef, 1).
+               $pagestate{$page}{meta}{permalink} = urlto(IkiWiki::dirname($params{page}), undef, 1).
                        "#".$params{page};
        }
 
@@ -281,9 +299,7 @@ sub sessioncgi ($$) {
                action => $config{cgiurl},
                header => 0,
                table => 0,
-               template => scalar IkiWiki::template_params('comments_form.tmpl'),
-               # wtf does this do in editpage?
-               wikiname => $config{wikiname},
+               template => scalar IkiWiki::template_params('editcomment.tmpl'),
        );
 
        IkiWiki::decode_form_utf8($form);
@@ -447,7 +463,7 @@ sub sessioncgi ($$) {
                                        content => $preview);
                        });
 
-               my $template = template("comments_display.tmpl");
+               my $template = template("comment.tmpl");
                $template->param(content => $preview);
                $template->param(title => $form->field('subject'));
                $template->param(ctime => displaytime(time));
@@ -529,15 +545,16 @@ sub pagetemplate (@) {
 
        my $page = $params{page};
        my $template = $params{template};
+       my $shown = ($template->query(name => 'commentslink') ||
+                    $template->query(name => 'comments')) &&
+                   commentsshown($page);
 
        if ($template->query(name => 'comments')) {
-               my $shown = commentsshown($page);
-
                my $comments = undef;
                if ($shown) {
                        $comments = IkiWiki::preprocess_inline(
                                pages => "internal($page/$config{comments_pagename}*)",
-                               template => 'comments_display',
+                               template => 'comment',
                                show => 0,
                                reverse => 'yes',
                                page => $page,
@@ -563,7 +580,7 @@ sub pagetemplate (@) {
                # the link. But, to update the number, blog pages
                # would have to update whenever comments of any inlines
                # page are added, which is not currently done.
-               if (commentsshown($page)) {
+               if ($shown) {
                        $template->param(commentslink =>
                                htmllink($page, $params{destpage}, $page,
                                        linktext => gettext("Comments"),