+
+ $commentstate{$page}{commentuser} = $commentuser;
+ $commentstate{$page}{commentopenid} = $commentopenid;
+ $commentstate{$page}{commentip} = $commentip;
+ $commentstate{$page}{commentauthor} = $commentauthor;
+ $commentstate{$page}{commentauthorurl} = $commentauthorurl;
+ if (! defined $pagestate{$page}{meta}{author}) {
+ $pagestate{$page}{meta}{author} = $commentauthor;
+ }
+ if (! defined $pagestate{$page}{meta}{authorurl}) {
+ $pagestate{$page}{meta}{authorurl} = $commentauthorurl;
+ }
+
+ if ($config{comments_allowauthor}) {
+ if (defined $params{claimedauthor}) {
+ $pagestate{$page}{meta}{author} = $params{claimedauthor};
+ }
+
+ if (defined $params{url}) {
+ my $url=$params{url};
+
+ eval q{use URI::Heuristic};
+ if (! $@) {
+ $url=URI::Heuristic::uf_uristr($url);
+ }
+
+ if (safeurl($url)) {
+ $pagestate{$page}{meta}{authorurl} = $url;
+ }
+ }
+ }
+ else {
+ $pagestate{$page}{meta}{author} = $commentauthor;
+ $pagestate{$page}{meta}{authorurl} = $commentauthorurl;
+ }
+
+ if (defined $params{subject}) {
+ $pagestate{$page}{meta}{title} = $params{subject};
+ }
+
+ if ($params{page} =~ m/\/(\Q$config{comments_pagename}\E\d+)$/) {
+ $pagestate{$page}{meta}{permalink} = urlto(IkiWiki::dirname($params{page}), undef, 1).
+ "#".$params{page};
+ }
+
+ eval q{use Date::Parse};
+ if (! $@) {
+ my $time = str2time($params{date});
+ $IkiWiki::pagectime{$page} = $time if defined $time;
+ }
+
+ return $content;
+}
+
+# This is exactly the same as recentchanges_link :-(
+sub linkcgi ($) {
+ my $cgi=shift;
+ if (defined $cgi->param('do') && $cgi->param('do') eq "commenter") {
+
+ my $page=decode_utf8($cgi->param("page"));
+ if (! defined $page) {
+ error("missing page parameter");
+ }
+
+ IkiWiki::loadindex();
+
+ my $link=bestlink("", $page);
+ if (! length $link) {
+ print "Content-type: text/html\n\n";
+ print IkiWiki::misctemplate(gettext(gettext("missing page")),
+ "<p>".
+ sprintf(gettext("The page %s does not exist."),
+ htmllink("", "", $page)).
+ "</p>");
+ }
+ else {
+ IkiWiki::redirect($cgi, urlto($link, undef, 1));
+ }
+
+ exit;
+ }
+}