2 # Copyright © 2006-2008 Joey Hess <joey@ikiwiki.info>
3 # Copyright © 2008 Simon McVittie <http://smcv.pseudorandom.co.uk/>
4 # Licensed under the GNU GPL, version 2, or any later version published by the
5 # Free Software Foundation
6 package IkiWiki::Plugin::comments;
12 use POSIX qw(strftime);
14 use constant PREVIEW => "Preview";
15 use constant POST_COMMENT => "Post comment";
16 use constant CANCEL => "Cancel";
22 hook(type => "checkconfig", id => 'comments', call => \&checkconfig);
23 hook(type => "getsetup", id => 'comments', call => \&getsetup);
24 hook(type => "preprocess", id => 'comment', call => \&preprocess);
25 hook(type => "preprocess", id => 'commentmoderation', call => \&preprocess_moderation);
26 # here for backwards compatability with old comments
27 hook(type => "preprocess", id => '_comment', call => \&preprocess);
28 hook(type => "sessioncgi", id => 'comment', call => \&sessioncgi);
29 hook(type => "htmlize", id => "_comment", call => \&htmlize);
30 hook(type => "htmlize", id => "_comment_pending",
31 call => \&htmlize_pending);
32 hook(type => "pagetemplate", id => "comments", call => \&pagetemplate);
33 hook(type => "formbuilder_setup", id => "comments",
34 call => \&formbuilder_setup);
35 # Load goto to fix up user page links for logged-in commenters
36 IkiWiki::loadplugin("goto");
37 IkiWiki::loadplugin("inline");
47 comments_pagespec => {
49 example => 'blog/* and !*/Discussion',
50 description => 'PageSpec of pages where comments are allowed',
51 link => 'ikiwiki/PageSpec',
55 comments_closed_pagespec => {
57 example => 'blog/controversial or blog/flamewar',
58 description => 'PageSpec of pages where posting new comments is not allowed',
59 link => 'ikiwiki/PageSpec',
63 comments_pagename => {
65 default => 'comment_',
66 description => 'Base name for comments, e.g. "comment_" for pages like "sandbox/comment_12"',
67 safe => 0, # manual page moving required
70 comments_allowdirectives => {
73 description => 'Interpret directives in comments?',
77 comments_allowauthor => {
80 description => 'Allow anonymous commenters to set an author name?',
87 description => 'commit comments to the VCS',
88 # old uncommitted comments are likely to cause
89 # confusion if this is changed
96 $config{comments_commit} = 1
97 unless defined $config{comments_commit};
98 $config{comments_pagespec} = ''
99 unless defined $config{comments_pagespec};
100 $config{comments_closed_pagespec} = ''
101 unless defined $config{comments_closed_pagespec};
102 $config{comments_pagename} = 'comment_'
103 unless defined $config{comments_pagename};
108 return $params{content};
111 sub htmlize_pending {
113 return sprintf(gettext("this comment needs %s"),
115 IkiWiki::cgiurl(do => "commentmoderation").'">'.
116 gettext("moderation").'</a>');
119 # FIXME: copied verbatim from meta
122 if (exists $IkiWiki::Plugin::htmlscrubber::{safe_url_regexp} &&
123 defined $IkiWiki::Plugin::htmlscrubber::safe_url_regexp) {
124 return $url=~/$IkiWiki::Plugin::htmlscrubber::safe_url_regexp/;
133 my $page = $params{page};
135 my $format = $params{format};
136 if (defined $format && ! exists $IkiWiki::hooks{htmlize}{$format}) {
137 error(sprintf(gettext("unsupported page format %s"), $format));
140 my $content = $params{content};
141 if (! defined $content) {
142 error(gettext("comment must have content"));
144 $content =~ s/\\"/"/g;
146 if ($config{comments_allowdirectives}) {
147 $content = IkiWiki::preprocess($page, $params{destpage},
151 # no need to bother with htmlize if it's just HTML
152 $content = IkiWiki::htmlize($page, $params{destpage}, $format, $content)
155 IkiWiki::run_hooks(sanitize => sub {
158 destpage => $params{destpage},
163 # set metadata, possibly overriding [[!meta]] directives from the
169 my $commentauthorurl;
170 my $commentauthoravatar;
172 if (defined $params{username}) {
173 $commentuser = $params{username};
175 my $oiduser = eval { IkiWiki::openiduser($commentuser) };
177 if (defined $oiduser) {
178 # looks like an OpenID
179 $commentauthorurl = $commentuser;
180 $commentauthor = (defined $params{nickname} && length $params{nickname}) ? $params{nickname} : $oiduser;
181 $commentopenid = $commentuser;
184 $commentauthorurl = IkiWiki::cgiurl(
186 page => IkiWiki::userpage($commentuser)
189 $commentauthor = $commentuser;
192 eval 'use Libravatar::URL';
194 if (defined $commentopenid) {
195 $commentauthoravatar = libravatar_url(openid => $commentopenid, https => $ENV{HTTPS});
197 elsif (my $email = IkiWiki::userinfo_get($commentuser, 'email')) {
198 $commentauthoravatar = libravatar_url(email => $email, https => $ENV{HTTPS});
203 if (defined $params{ip}) {
204 $commentip = $params{ip};
206 $commentauthor = gettext("Anonymous");
209 $commentstate{$page}{commentuser} = $commentuser;
210 $commentstate{$page}{commentopenid} = $commentopenid;
211 $commentstate{$page}{commentip} = $commentip;
212 $commentstate{$page}{commentauthor} = $commentauthor;
213 $commentstate{$page}{commentauthorurl} = $commentauthorurl;
214 $commentstate{$page}{commentauthoravatar} = $commentauthoravatar;
215 if (! defined $pagestate{$page}{meta}{author}) {
216 $pagestate{$page}{meta}{author} = $commentauthor;
218 if (! defined $pagestate{$page}{meta}{authorurl}) {
219 $pagestate{$page}{meta}{authorurl} = $commentauthorurl;
222 if ($config{comments_allowauthor}) {
223 if (defined $params{claimedauthor}) {
224 $pagestate{$page}{meta}{author} = $params{claimedauthor};
227 if (defined $params{url}) {
228 my $url=$params{url};
230 eval q{use URI::Heuristic};
232 $url=URI::Heuristic::uf_uristr($url);
236 $pagestate{$page}{meta}{authorurl} = $url;
241 $pagestate{$page}{meta}{author} = $commentauthor;
242 $pagestate{$page}{meta}{authorurl} = $commentauthorurl;
245 if (defined $params{subject}) {
246 # decode title the same way meta does
247 eval q{use HTML::Entities};
248 $pagestate{$page}{meta}{title} = decode_entities($params{subject});
251 if ($params{page} =~ m/\/\Q$config{comments_pagename}\E\d+_/) {
252 $pagestate{$page}{meta}{permalink} = urlto(IkiWiki::dirname($params{page})).
253 "#".page_to_id($params{page});
256 eval q{use Date::Parse};
258 my $time = str2time($params{date});
259 $IkiWiki::pagectime{$page} = $time if defined $time;
265 sub preprocess_moderation {
268 $params{desc}=gettext("Comment Moderation")
269 unless defined $params{desc};
271 if (length $config{cgiurl}) {
273 IkiWiki::cgiurl(do => 'commentmoderation').
274 '">'.$params{desc}.'</a>';
277 return $params{desc};
281 sub sessioncgi ($$) {
285 my $do = $cgi->param('do');
286 if ($do eq 'comment') {
287 editcomment($cgi, $session);
289 elsif ($do eq 'commentmoderation') {
290 commentmoderation($cgi, $session);
292 elsif ($do eq 'commentsignin') {
293 IkiWiki::cgi_signin($cgi, $session);
298 # Mostly cargo-culted from IkiWiki::plugin::editpage
299 sub editcomment ($$) {
303 IkiWiki::decode_cgi_utf8($cgi);
305 eval q{use CGI::FormBuilder};
308 my @buttons = (POST_COMMENT, PREVIEW, CANCEL);
309 my $form = CGI::FormBuilder->new(
310 fields => [qw{do sid page subject editcontent type author url}],
313 required => [qw{editcontent}],
316 action => IkiWiki::cgiurl(),
319 template => { template('editcomment.tmpl') },
322 IkiWiki::decode_form_utf8($form);
323 IkiWiki::run_hooks(formbuilder_setup => sub {
324 shift->(title => "comment", form => $form, cgi => $cgi,
325 session => $session, buttons => \@buttons);
327 IkiWiki::decode_form_utf8($form);
329 my $type = $form->param('type');
330 if (defined $type && length $type && $IkiWiki::hooks{htmlize}{$type}) {
331 $type = IkiWiki::possibly_foolish_untaint($type);
334 $type = $config{default_pageext};
339 if (exists $IkiWiki::hooks{htmlize}) {
340 foreach my $key (grep { !/^_/ } keys %{$IkiWiki::hooks{htmlize}}) {
341 push @page_types, [$key, $IkiWiki::hooks{htmlize}{$key}{longname} || $key];
344 @page_types=sort @page_types;
346 $form->field(name => 'do', type => 'hidden');
347 $form->field(name => 'sid', type => 'hidden', value => $session->id,
349 $form->field(name => 'page', type => 'hidden');
350 $form->field(name => 'subject', type => 'text', size => 72);
351 $form->field(name => 'editcontent', type => 'textarea', rows => 10);
352 $form->field(name => "type", value => $type, force => 1,
353 type => 'select', options => \@page_types);
355 $form->tmpl_param(username => $session->param('name'));
357 if ($config{comments_allowauthor} and
358 ! defined $session->param('name')) {
359 $form->tmpl_param(allowauthor => 1);
360 $form->field(name => 'author', type => 'text', size => '40');
361 $form->field(name => 'url', type => 'text', size => '40');
364 $form->tmpl_param(allowauthor => 0);
365 $form->field(name => 'author', type => 'hidden', value => '',
367 $form->field(name => 'url', type => 'hidden', value => '',
371 if (! defined $session->param('name')) {
372 # Make signinurl work and return here.
373 $form->tmpl_param(signinurl => IkiWiki::cgiurl(do => 'commentsignin'));
374 $session->param(postsignin => $ENV{QUERY_STRING});
375 IkiWiki::cgi_savesession($session);
378 # The untaint is OK (as in editpage) because we're about to pass
379 # it to file_pruned and wiki_file_regexp anyway.
380 my ($page) = $form->field('page')=~/$config{wiki_file_regexp}/;
381 $page = IkiWiki::possibly_foolish_untaint($page);
382 if (! defined $page || ! length $page ||
383 IkiWiki::file_pruned($page)) {
384 error(gettext("bad page name"));
387 $form->title(sprintf(gettext("commenting on %s"),
388 IkiWiki::pagetitle(IkiWiki::basename($page))));
390 $form->tmpl_param('helponformattinglink',
391 htmllink($page, $page, 'ikiwiki/formatting',
393 linktext => 'FormattingHelp'),
394 allowdirectives => $config{allow_directives});
396 if ($form->submitted eq CANCEL) {
397 # bounce back to the page they wanted to comment on, and exit.
398 IkiWiki::redirect($cgi, urlto($page));
402 if (not exists $pagesources{$page}) {
403 error(sprintf(gettext(
404 "page '%s' doesn't exist, so you can't comment"),
408 if (pagespec_match($page, $config{comments_closed_pagespec},
409 location => $page)) {
410 error(sprintf(gettext(
411 "comments on page '%s' are closed"),
415 # Set a flag to indicate that we're posting a comment,
416 # so that postcomment() can tell it should match.
418 IkiWiki::check_canedit($page, $cgi, $session);
421 my $content = "[[!comment format=$type\n";
423 if (defined $session->param('name')) {
424 my $username = $session->param('name');
425 $username =~ s/"/"/g;
426 $content .= " username=\"$username\"\n";
428 if (defined $session->param('nickname')) {
429 my $nickname = $session->param('nickname');
430 $nickname =~ s/"/"/g;
431 $content .= " nickname=\"$nickname\"\n";
433 elsif (defined $session->remote_addr()) {
434 my $ip = $session->remote_addr();
435 if ($ip =~ m/^([.0-9]+)$/) {
436 $content .= " ip=\"$1\"\n";
440 if ($config{comments_allowauthor}) {
441 my $author = $form->field('author');
442 if (defined $author && length $author) {
443 $author =~ s/"/"/g;
444 $content .= " claimedauthor=\"$author\"\n";
446 my $url = $form->field('url');
447 if (defined $url && length $url) {
448 $url =~ s/"/"/g;
449 $content .= " url=\"$url\"\n";
453 my $subject = $form->field('subject');
454 if (defined $subject && length $subject) {
455 $subject =~ s/"/"/g;
458 $subject = "comment ".(num_comments($page, $config{srcdir}) + 1);
460 $content .= " subject=\"$subject\"\n";
462 $content .= " date=\"" . decode_utf8(strftime('%Y-%m-%dT%H:%M:%SZ', gmtime)) . "\"\n";
464 my $editcontent = $form->field('editcontent');
465 $editcontent="" if ! defined $editcontent;
466 $editcontent =~ s/\r\n/\n/g;
467 $editcontent =~ s/\r/\n/g;
468 $editcontent =~ s/"/\\"/g;
469 $content .= " content=\"\"\"\n$editcontent\n\"\"\"]]\n";
471 my $location=unique_comment_location($page, $content, $config{srcdir});
473 # This is essentially a simplified version of editpage:
474 # - the user does not control the page that's created, only the parent
475 # - it's always a create operation, never an edit
476 # - this means that conflicts should never happen
477 # - this means that if they do, rocks fall and everyone dies
479 if ($form->submitted eq PREVIEW) {
480 my $preview=previewcomment($content, $location, $page, time);
481 IkiWiki::run_hooks(format => sub {
482 $preview = shift->(page => $page,
483 content => $preview);
485 $form->tmpl_param(page_preview => $preview);
488 $form->tmpl_param(page_preview => "");
491 if ($form->submitted eq POST_COMMENT && $form->validate) {
492 IkiWiki::checksessionexpiry($cgi, $session);
495 my $ok=IkiWiki::check_content(content => $form->field('editcontent'),
496 subject => $form->field('subject'),
497 $config{comments_allowauthor} ? (
498 author => $form->field('author'),
499 url => $form->field('url'),
509 $location=unique_comment_location($page, $content, $config{srcdir}, "._comment_pending");
510 writefile("$location._comment_pending", $config{srcdir}, $content);
512 # Refresh so anything that deals with pending
513 # comments can be updated.
514 require IkiWiki::Render;
516 IkiWiki::saveindex();
518 IkiWiki::printheader($session);
519 print IkiWiki::cgitemplate($cgi, gettext(gettext("comment stored for moderation")),
521 gettext("Your comment will be posted after moderator review").
526 # FIXME: could probably do some sort of graceful retry
527 # on error? Would require significant unwinding though
528 my $file = "$location._comment";
529 writefile($file, $config{srcdir}, $content);
533 if ($config{rcs} and $config{comments_commit}) {
534 my $message = gettext("Added a comment");
535 if (defined $form->field('subject') &&
536 length $form->field('subject')) {
538 gettext("Added a comment: %s"),
539 $form->field('subject'));
542 IkiWiki::rcs_add($file);
543 IkiWiki::disable_commit_hook();
544 $conflict = IkiWiki::rcs_commit_staged(
548 IkiWiki::enable_commit_hook();
549 IkiWiki::rcs_update();
552 # Now we need a refresh
553 require IkiWiki::Render;
555 IkiWiki::saveindex();
557 # this should never happen, unless a committer deliberately
558 # breaks it or something
559 error($conflict) if defined $conflict;
561 # Jump to the new comment on the page.
562 # The trailing question mark tries to avoid broken
563 # caches and get the most recent version of the page.
564 IkiWiki::redirect($cgi, urlto($page).
565 "?updated#".page_to_id($location));
569 IkiWiki::showform($form, \@buttons, $session, $cgi,
576 sub commentmoderation ($$) {
580 IkiWiki::needsignin($cgi, $session);
581 if (! IkiWiki::is_admin($session->param("name"))) {
582 error(gettext("you are not logged in as an admin"));
585 IkiWiki::decode_cgi_utf8($cgi);
587 if (defined $cgi->param('sid')) {
588 IkiWiki::checksessionexpiry($cgi, $session);
590 my $rejectalldefer=$cgi->param('rejectalldefer');
594 foreach my $id (keys %vars) {
595 if ($id =~ /(.*)\._comment(?:_pending)?$/) {
596 $id=decode_utf8($id);
597 my $action=$cgi->param($id);
598 next if $action eq 'Defer' && ! $rejectalldefer;
600 # Make sure that the id is of a legal
602 my ($f) = $id =~ /$config{wiki_file_regexp}/;
603 if (! defined $f || ! length $f ||
604 IkiWiki::file_pruned($f)) {
605 error("illegal file");
608 my $page=IkiWiki::dirname($f);
609 my $file="$config{srcdir}/$f";
612 $file="$config{wikistatedir}/comments_pending/".$f;
615 if ($action eq 'Accept') {
616 my $content=eval { readfile($file) };
617 next if $@; # file vanished since form was displayed
618 my $dest=unique_comment_location($page, $content, $config{srcdir})."._comment";
619 writefile($dest, $config{srcdir}, $content);
620 if ($config{rcs} and $config{comments_commit}) {
621 IkiWiki::rcs_add($dest);
626 require IkiWiki::Render;
627 IkiWiki::prune($file);
633 if ($config{rcs} and $config{comments_commit}) {
634 my $message = gettext("Comment moderation");
635 IkiWiki::disable_commit_hook();
636 $conflict=IkiWiki::rcs_commit_staged(
640 IkiWiki::enable_commit_hook();
641 IkiWiki::rcs_update();
644 # Now we need a refresh
645 require IkiWiki::Render;
647 IkiWiki::saveindex();
649 error($conflict) if defined $conflict;
654 my ($id, $dir, $ctime)=@{$_};
655 my $content=readfile("$dir/$id");
656 my $preview=previewcomment($content, $id,
662 } sort { $b->[2] <=> $a->[2] } comments_pending();
664 my $template=template("commentmoderation.tmpl");
667 comments => \@comments,
668 cgiurl => IkiWiki::cgiurl(),
670 IkiWiki::printheader($session);
671 my $out=$template->output;
672 IkiWiki::run_hooks(format => sub {
673 $out = shift->(page => "", content => $out);
675 print IkiWiki::cgitemplate($cgi, gettext("comment moderation"), $out);
679 sub formbuilder_setup (@) {
682 my $form=$params{form};
683 if ($form->title eq "preferences" &&
684 IkiWiki::is_admin($params{session}->param("name"))) {
685 push @{$params{buttons}}, "Comment Moderation";
686 if ($form->submitted && $form->submitted eq "Comment Moderation") {
687 commentmoderation($params{cgi}, $params{session});
692 sub comments_pending () {
695 eval q{use File::Find};
699 my $origdir=getcwd();
701 my $find_comments=sub {
704 return unless -d $dir;
706 chdir($dir) || die "chdir $dir: $!";
711 my $file=decode_utf8($_);
713 return if ! length $file || IkiWiki::file_pruned($file)
714 || -l $_ || -d _ || $file !~ /\Q$extension\E$/;
715 my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint
717 my $ctime=(stat($_))[10];
718 push @ret, [$f, $dir, $ctime];
723 chdir($origdir) || die "chdir $origdir: $!";
726 $find_comments->($config{srcdir}, "._comment_pending");
728 $find_comments->("$config{wikistatedir}/comments_pending/",
734 sub previewcomment ($$$) {
740 # Previewing a comment should implicitly enable comment posting mode.
741 my $oldpostcomment=$postcomment;
744 my $preview = IkiWiki::htmlize($location, $page, '_comment',
745 IkiWiki::linkify($location, $page,
746 IkiWiki::preprocess($location, $page,
747 IkiWiki::filter($location, $page, $content), 0, 1)));
749 my $template = template("comment.tmpl");
750 $template->param(content => $preview);
751 $template->param(ctime => displaytime($time, undef, 1));
752 $template->param(html5 => $config{html5});
754 IkiWiki::run_hooks(pagetemplate => sub {
755 shift->(page => $location,
757 template => $template);
760 $template->param(have_actions => 0);
762 $postcomment=$oldpostcomment;
764 return $template->output;
767 sub commentsshown ($) {
770 return pagespec_match($page, $config{comments_pagespec},
774 sub commentsopen ($) {
777 return length $config{cgiurl} > 0 &&
778 (! length $config{comments_closed_pagespec} ||
779 ! pagespec_match($page, $config{comments_closed_pagespec},
783 sub pagetemplate (@) {
786 my $page = $params{page};
787 my $template = $params{template};
788 my $shown = ($template->query(name => 'commentslink') ||
789 $template->query(name => 'commentsurl') ||
790 $template->query(name => 'atomcommentsurl') ||
791 $template->query(name => 'comments')) &&
792 commentsshown($page);
794 if ($template->query(name => 'comments')) {
795 my $comments = undef;
797 $comments = IkiWiki::preprocess_inline(
798 pages => "comment($page) and !comment($page/*)",
799 template => 'comment',
803 destpage => $params{destpage},
804 feedfile => 'comments',
809 if (defined $comments && length $comments) {
810 $template->param(comments => $comments);
813 if ($shown && commentsopen($page)) {
814 $template->param(addcommenturl => addcommenturl($page));
819 if ($template->query(name => 'commentsurl')) {
820 $template->param(commentsurl =>
821 urlto($page).'#comments');
824 if ($template->query(name => 'atomcommentsurl') && $config{usedirs}) {
825 # This will 404 until there are some comments, but I
826 # think that's probably OK...
827 $template->param(atomcommentsurl =>
828 urlto($page).'comments.atom');
831 if ($template->query(name => 'commentslink')) {
832 my $num=num_comments($page, $config{srcdir});
835 $link = htmllink($page, $params{destpage}, $page,
836 linktext => sprintf(ngettext("%i comment", "%i comments", $num), $num),
837 anchor => "comments",
841 elsif (commentsopen($page)) {
842 $link = "<a href=\"".addcommenturl($page)."\">".
843 #translators: Here "Comment" is a verb;
844 #translators: the user clicks on it to
845 #translators: post a comment.
849 $template->param(commentslink => $link)
854 # everything below this point is only relevant to the comments
856 if (!exists $commentstate{$page}) {
860 if ($template->query(name => 'commentid')) {
861 $template->param(commentid => page_to_id($page));
864 if ($template->query(name => 'commentuser')) {
865 $template->param(commentuser =>
866 $commentstate{$page}{commentuser});
869 if ($template->query(name => 'commentopenid')) {
870 $template->param(commentopenid =>
871 $commentstate{$page}{commentopenid});
874 if ($template->query(name => 'commentip')) {
875 $template->param(commentip =>
876 $commentstate{$page}{commentip});
879 if ($template->query(name => 'commentauthor')) {
880 $template->param(commentauthor =>
881 $commentstate{$page}{commentauthor});
884 if ($template->query(name => 'commentauthorurl')) {
885 $template->param(commentauthorurl =>
886 $commentstate{$page}{commentauthorurl});
889 if ($template->query(name => 'commentauthoravatar')) {
890 $template->param(commentauthoravatar =>
891 $commentstate{$page}{commentauthoravatar});
894 if ($template->query(name => 'removeurl') &&
895 IkiWiki::Plugin::remove->can("check_canremove") &&
896 length $config{cgiurl}) {
897 $template->param(removeurl => IkiWiki::cgiurl(do => 'remove',
899 $template->param(have_actions => 1);
903 sub addcommenturl ($) {
906 return IkiWiki::cgiurl(do => 'comment', page => $page);
909 sub num_comments ($$) {
913 my @comments=glob("$dir/$page/$config{comments_pagename}*._comment");
914 return int @comments;
917 sub unique_comment_location ($$$$) {
919 eval q{use Digest::MD5 'md5_hex'};
921 my $content_md5=md5_hex(Encode::encode_utf8(shift));
923 my $ext=shift || "._comment";
926 my $i = num_comments($page, $dir);
929 $location = "$page/$config{comments_pagename}${i}_${content_md5}";
930 } while (-e "$dir/$location$ext");
936 # Converts a comment page name into a unique, legal html id
937 # attribute value, that can be used as an anchor to link to the
941 eval q{use Digest::MD5 'md5_hex'};
944 return "comment-".md5_hex(Encode::encode_utf8(($page)));
947 package IkiWiki::PageSpec;
949 sub match_postcomment ($$;@) {
953 if (! $postcomment) {
954 return IkiWiki::FailReason->new("not posting a comment");
956 return match_glob($page, $glob, @_);
959 sub match_comment ($$;@) {
963 if (! $postcomment) {
964 # To see if it's a comment, check the source file type.
965 # Deal with comments that were just deleted.
966 my $source=exists $IkiWiki::pagesources{$page} ?
967 $IkiWiki::pagesources{$page} :
968 $IkiWiki::delpagesources{$page};
969 my $type=defined $source ? IkiWiki::pagetype($source) : undef;
970 if (! defined $type || $type ne "_comment") {
971 return IkiWiki::FailReason->new("$page is not a comment");
975 return match_glob($page, "$glob/*", internal => 1, @_);
978 sub match_comment_pending ($$;@) {
982 my $source=exists $IkiWiki::pagesources{$page} ?
983 $IkiWiki::pagesources{$page} :
984 $IkiWiki::delpagesources{$page};
985 my $type=defined $source ? IkiWiki::pagetype($source) : undef;
986 if (! defined $type || $type ne "_comment_pending") {
987 return IkiWiki::FailReason->new("$page is not a pending comment");
990 return match_glob($page, "$glob/*", internal => 1, @_);