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';
195 if (defined $commentopenid) {
196 $commentauthoravatar = libravatar_url(openid => $commentopenid, https => $ENV{HTTPS});
198 elsif (my $email = IkiWiki::userinfo_get($commentuser, 'email')) {
199 $commentauthoravatar = libravatar_url(email => $email, https => $ENV{HTTPS});
204 if (defined $params{ip}) {
205 $commentip = $params{ip};
207 $commentauthor = gettext("Anonymous");
210 $commentstate{$page}{commentuser} = $commentuser;
211 $commentstate{$page}{commentopenid} = $commentopenid;
212 $commentstate{$page}{commentip} = $commentip;
213 $commentstate{$page}{commentauthor} = $commentauthor;
214 $commentstate{$page}{commentauthorurl} = $commentauthorurl;
215 $commentstate{$page}{commentauthoravatar} = $commentauthoravatar;
216 if (! defined $pagestate{$page}{meta}{author}) {
217 $pagestate{$page}{meta}{author} = $commentauthor;
219 if (! defined $pagestate{$page}{meta}{authorurl}) {
220 $pagestate{$page}{meta}{authorurl} = $commentauthorurl;
223 if ($config{comments_allowauthor}) {
224 if (defined $params{claimedauthor}) {
225 $pagestate{$page}{meta}{author} = $params{claimedauthor};
228 if (defined $params{url}) {
229 my $url=$params{url};
231 eval q{use URI::Heuristic};
233 $url=URI::Heuristic::uf_uristr($url);
237 $pagestate{$page}{meta}{authorurl} = $url;
242 $pagestate{$page}{meta}{author} = $commentauthor;
243 $pagestate{$page}{meta}{authorurl} = $commentauthorurl;
246 if (defined $params{subject}) {
247 # decode title the same way meta does
248 eval q{use HTML::Entities};
249 $pagestate{$page}{meta}{title} = decode_entities($params{subject});
252 if ($params{page} =~ m/\/\Q$config{comments_pagename}\E\d+_/) {
253 $pagestate{$page}{meta}{permalink} = urlto(IkiWiki::dirname($params{page})).
254 "#".page_to_id($params{page});
257 eval q{use Date::Parse};
259 my $time = str2time($params{date});
260 $IkiWiki::pagectime{$page} = $time if defined $time;
266 sub preprocess_moderation {
269 $params{desc}=gettext("Comment Moderation")
270 unless defined $params{desc};
272 if (length $config{cgiurl}) {
274 IkiWiki::cgiurl(do => 'commentmoderation').
275 '">'.$params{desc}.'</a>';
278 return $params{desc};
282 sub sessioncgi ($$) {
286 my $do = $cgi->param('do');
287 if ($do eq 'comment') {
288 editcomment($cgi, $session);
290 elsif ($do eq 'commentmoderation') {
291 commentmoderation($cgi, $session);
293 elsif ($do eq 'commentsignin') {
294 IkiWiki::cgi_signin($cgi, $session);
299 # Mostly cargo-culted from IkiWiki::plugin::editpage
300 sub editcomment ($$) {
304 IkiWiki::decode_cgi_utf8($cgi);
306 eval q{use CGI::FormBuilder};
309 my @buttons = (POST_COMMENT, PREVIEW, CANCEL);
310 my $form = CGI::FormBuilder->new(
311 fields => [qw{do sid page subject editcontent type author url}],
314 required => [qw{editcontent}],
317 action => IkiWiki::cgiurl(),
320 template => { template('editcomment.tmpl') },
323 IkiWiki::decode_form_utf8($form);
324 IkiWiki::run_hooks(formbuilder_setup => sub {
325 shift->(title => "comment", form => $form, cgi => $cgi,
326 session => $session, buttons => \@buttons);
328 IkiWiki::decode_form_utf8($form);
330 my $type = $form->param('type');
331 if (defined $type && length $type && $IkiWiki::hooks{htmlize}{$type}) {
332 $type = IkiWiki::possibly_foolish_untaint($type);
335 $type = $config{default_pageext};
340 if (exists $IkiWiki::hooks{htmlize}) {
341 foreach my $key (grep { !/^_/ } keys %{$IkiWiki::hooks{htmlize}}) {
342 push @page_types, [$key, $IkiWiki::hooks{htmlize}{$key}{longname} || $key];
345 @page_types=sort @page_types;
347 $form->field(name => 'do', type => 'hidden');
348 $form->field(name => 'sid', type => 'hidden', value => $session->id,
350 $form->field(name => 'page', type => 'hidden');
351 $form->field(name => 'subject', type => 'text', size => 72);
352 $form->field(name => 'editcontent', type => 'textarea', rows => 10);
353 $form->field(name => "type", value => $type, force => 1,
354 type => 'select', options => \@page_types);
356 $form->tmpl_param(username => $session->param('name'));
358 if ($config{comments_allowauthor} and
359 ! defined $session->param('name')) {
360 $form->tmpl_param(allowauthor => 1);
361 $form->field(name => 'author', type => 'text', size => '40');
362 $form->field(name => 'url', type => 'text', size => '40');
365 $form->tmpl_param(allowauthor => 0);
366 $form->field(name => 'author', type => 'hidden', value => '',
368 $form->field(name => 'url', type => 'hidden', value => '',
372 if (! defined $session->param('name')) {
373 # Make signinurl work and return here.
374 $form->tmpl_param(signinurl => IkiWiki::cgiurl(do => 'commentsignin'));
375 $session->param(postsignin => $ENV{QUERY_STRING});
376 IkiWiki::cgi_savesession($session);
379 # The untaint is OK (as in editpage) because we're about to pass
380 # it to file_pruned and wiki_file_regexp anyway.
381 my ($page) = $form->field('page')=~/$config{wiki_file_regexp}/;
382 $page = IkiWiki::possibly_foolish_untaint($page);
383 if (! defined $page || ! length $page ||
384 IkiWiki::file_pruned($page)) {
385 error(gettext("bad page name"));
388 $form->title(sprintf(gettext("commenting on %s"),
389 IkiWiki::pagetitle(IkiWiki::basename($page))));
391 $form->tmpl_param('helponformattinglink',
392 htmllink($page, $page, 'ikiwiki/formatting',
394 linktext => 'FormattingHelp'),
395 allowdirectives => $config{allow_directives});
397 if ($form->submitted eq CANCEL) {
398 # bounce back to the page they wanted to comment on, and exit.
399 IkiWiki::redirect($cgi, urlto($page));
403 if (not exists $pagesources{$page}) {
404 error(sprintf(gettext(
405 "page '%s' doesn't exist, so you can't comment"),
409 if (pagespec_match($page, $config{comments_closed_pagespec},
410 location => $page)) {
411 error(sprintf(gettext(
412 "comments on page '%s' are closed"),
416 # Set a flag to indicate that we're posting a comment,
417 # so that postcomment() can tell it should match.
419 IkiWiki::check_canedit($page, $cgi, $session);
422 my $content = "[[!comment format=$type\n";
424 if (defined $session->param('name')) {
425 my $username = $session->param('name');
426 $username =~ s/"/"/g;
427 $content .= " username=\"$username\"\n";
429 if (defined $session->param('nickname')) {
430 my $nickname = $session->param('nickname');
431 $nickname =~ s/"/"/g;
432 $content .= " nickname=\"$nickname\"\n";
434 elsif (defined $session->remote_addr()) {
435 my $ip = $session->remote_addr();
436 if ($ip =~ m/^([.0-9]+)$/) {
437 $content .= " ip=\"$1\"\n";
441 if ($config{comments_allowauthor}) {
442 my $author = $form->field('author');
443 if (defined $author && length $author) {
444 $author =~ s/"/"/g;
445 $content .= " claimedauthor=\"$author\"\n";
447 my $url = $form->field('url');
448 if (defined $url && length $url) {
449 $url =~ s/"/"/g;
450 $content .= " url=\"$url\"\n";
454 my $subject = $form->field('subject');
455 if (defined $subject && length $subject) {
456 $subject =~ s/"/"/g;
459 $subject = "comment ".(num_comments($page, $config{srcdir}) + 1);
461 $content .= " subject=\"$subject\"\n";
463 $content .= " date=\"" . decode_utf8(strftime('%Y-%m-%dT%H:%M:%SZ', gmtime)) . "\"\n";
465 my $editcontent = $form->field('editcontent');
466 $editcontent="" if ! defined $editcontent;
467 $editcontent =~ s/\r\n/\n/g;
468 $editcontent =~ s/\r/\n/g;
469 $editcontent =~ s/"/\\"/g;
470 $content .= " content=\"\"\"\n$editcontent\n\"\"\"]]\n";
472 my $location=unique_comment_location($page, $content, $config{srcdir});
474 # This is essentially a simplified version of editpage:
475 # - the user does not control the page that's created, only the parent
476 # - it's always a create operation, never an edit
477 # - this means that conflicts should never happen
478 # - this means that if they do, rocks fall and everyone dies
480 if ($form->submitted eq PREVIEW) {
481 my $preview=previewcomment($content, $location, $page, time);
482 IkiWiki::run_hooks(format => sub {
483 $preview = shift->(page => $page,
484 content => $preview);
486 $form->tmpl_param(page_preview => $preview);
489 $form->tmpl_param(page_preview => "");
492 if ($form->submitted eq POST_COMMENT && $form->validate) {
493 IkiWiki::checksessionexpiry($cgi, $session);
496 my $ok=IkiWiki::check_content(content => $form->field('editcontent'),
497 subject => $form->field('subject'),
498 $config{comments_allowauthor} ? (
499 author => $form->field('author'),
500 url => $form->field('url'),
510 $location=unique_comment_location($page, $content, $config{srcdir}, "._comment_pending");
511 writefile("$location._comment_pending", $config{srcdir}, $content);
513 # Refresh so anything that deals with pending
514 # comments can be updated.
515 require IkiWiki::Render;
517 IkiWiki::saveindex();
519 IkiWiki::printheader($session);
520 print IkiWiki::cgitemplate($cgi, gettext(gettext("comment stored for moderation")),
522 gettext("Your comment will be posted after moderator review").
527 # FIXME: could probably do some sort of graceful retry
528 # on error? Would require significant unwinding though
529 my $file = "$location._comment";
530 writefile($file, $config{srcdir}, $content);
534 if ($config{rcs} and $config{comments_commit}) {
535 my $message = gettext("Added a comment");
536 if (defined $form->field('subject') &&
537 length $form->field('subject')) {
539 gettext("Added a comment: %s"),
540 $form->field('subject'));
543 IkiWiki::rcs_add($file);
544 IkiWiki::disable_commit_hook();
545 $conflict = IkiWiki::rcs_commit_staged(
549 IkiWiki::enable_commit_hook();
550 IkiWiki::rcs_update();
553 # Now we need a refresh
554 require IkiWiki::Render;
556 IkiWiki::saveindex();
558 # this should never happen, unless a committer deliberately
559 # breaks it or something
560 error($conflict) if defined $conflict;
562 # Jump to the new comment on the page.
563 # The trailing question mark tries to avoid broken
564 # caches and get the most recent version of the page.
565 IkiWiki::redirect($cgi, urlto($page).
566 "?updated#".page_to_id($location));
570 IkiWiki::showform($form, \@buttons, $session, $cgi,
577 sub commentmoderation ($$) {
581 IkiWiki::needsignin($cgi, $session);
582 if (! IkiWiki::is_admin($session->param("name"))) {
583 error(gettext("you are not logged in as an admin"));
586 IkiWiki::decode_cgi_utf8($cgi);
588 if (defined $cgi->param('sid')) {
589 IkiWiki::checksessionexpiry($cgi, $session);
591 my $rejectalldefer=$cgi->param('rejectalldefer');
595 foreach my $id (keys %vars) {
596 if ($id =~ /(.*)\._comment(?:_pending)?$/) {
597 $id=decode_utf8($id);
598 my $action=$cgi->param($id);
599 next if $action eq 'Defer' && ! $rejectalldefer;
601 # Make sure that the id is of a legal
603 my ($f) = $id =~ /$config{wiki_file_regexp}/;
604 if (! defined $f || ! length $f ||
605 IkiWiki::file_pruned($f)) {
606 error("illegal file");
609 my $page=IkiWiki::dirname($f);
610 my $file="$config{srcdir}/$f";
613 $file="$config{wikistatedir}/comments_pending/".$f;
616 if ($action eq 'Accept') {
617 my $content=eval { readfile($file) };
618 next if $@; # file vanished since form was displayed
619 my $dest=unique_comment_location($page, $content, $config{srcdir})."._comment";
620 writefile($dest, $config{srcdir}, $content);
621 if ($config{rcs} and $config{comments_commit}) {
622 IkiWiki::rcs_add($dest);
627 require IkiWiki::Render;
628 IkiWiki::prune($file);
634 if ($config{rcs} and $config{comments_commit}) {
635 my $message = gettext("Comment moderation");
636 IkiWiki::disable_commit_hook();
637 $conflict=IkiWiki::rcs_commit_staged(
641 IkiWiki::enable_commit_hook();
642 IkiWiki::rcs_update();
645 # Now we need a refresh
646 require IkiWiki::Render;
648 IkiWiki::saveindex();
650 error($conflict) if defined $conflict;
655 my ($id, $dir, $ctime)=@{$_};
656 my $content=readfile("$dir/$id");
657 my $preview=previewcomment($content, $id,
663 } sort { $b->[2] <=> $a->[2] } comments_pending();
665 my $template=template("commentmoderation.tmpl");
668 comments => \@comments,
669 cgiurl => IkiWiki::cgiurl(),
671 IkiWiki::printheader($session);
672 my $out=$template->output;
673 IkiWiki::run_hooks(format => sub {
674 $out = shift->(page => "", content => $out);
676 print IkiWiki::cgitemplate($cgi, gettext("comment moderation"), $out);
680 sub formbuilder_setup (@) {
683 my $form=$params{form};
684 if ($form->title eq "preferences" &&
685 IkiWiki::is_admin($params{session}->param("name"))) {
686 push @{$params{buttons}}, "Comment Moderation";
687 if ($form->submitted && $form->submitted eq "Comment Moderation") {
688 commentmoderation($params{cgi}, $params{session});
693 sub comments_pending () {
696 eval q{use File::Find};
700 my $origdir=getcwd();
702 my $find_comments=sub {
705 return unless -d $dir;
707 chdir($dir) || die "chdir $dir: $!";
712 my $file=decode_utf8($_);
714 return if ! length $file || IkiWiki::file_pruned($file)
715 || -l $_ || -d _ || $file !~ /\Q$extension\E$/;
716 my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint
718 my $ctime=(stat($_))[10];
719 push @ret, [$f, $dir, $ctime];
724 chdir($origdir) || die "chdir $origdir: $!";
727 $find_comments->($config{srcdir}, "._comment_pending");
729 $find_comments->("$config{wikistatedir}/comments_pending/",
735 sub previewcomment ($$$) {
741 # Previewing a comment should implicitly enable comment posting mode.
742 my $oldpostcomment=$postcomment;
745 my $preview = IkiWiki::htmlize($location, $page, '_comment',
746 IkiWiki::linkify($location, $page,
747 IkiWiki::preprocess($location, $page,
748 IkiWiki::filter($location, $page, $content), 0, 1)));
750 my $template = template("comment.tmpl");
751 $template->param(content => $preview);
752 $template->param(ctime => displaytime($time, undef, 1));
753 $template->param(html5 => $config{html5});
755 IkiWiki::run_hooks(pagetemplate => sub {
756 shift->(page => $location,
758 template => $template);
761 $template->param(have_actions => 0);
763 $postcomment=$oldpostcomment;
765 return $template->output;
768 sub commentsshown ($) {
771 return pagespec_match($page, $config{comments_pagespec},
775 sub commentsopen ($) {
778 return length $config{cgiurl} > 0 &&
779 (! length $config{comments_closed_pagespec} ||
780 ! pagespec_match($page, $config{comments_closed_pagespec},
784 sub pagetemplate (@) {
787 my $page = $params{page};
788 my $template = $params{template};
789 my $shown = ($template->query(name => 'commentslink') ||
790 $template->query(name => 'commentsurl') ||
791 $template->query(name => 'atomcommentsurl') ||
792 $template->query(name => 'comments')) &&
793 commentsshown($page);
795 if ($template->query(name => 'comments')) {
796 my $comments = undef;
798 $comments = IkiWiki::preprocess_inline(
799 pages => "comment($page) and !comment($page/*)",
800 template => 'comment',
804 destpage => $params{destpage},
805 feedfile => 'comments',
810 if (defined $comments && length $comments) {
811 $template->param(comments => $comments);
814 if ($shown && commentsopen($page)) {
815 $template->param(addcommenturl => addcommenturl($page));
820 if ($template->query(name => 'commentsurl')) {
821 $template->param(commentsurl =>
822 urlto($page).'#comments');
825 if ($template->query(name => 'atomcommentsurl') && $config{usedirs}) {
826 # This will 404 until there are some comments, but I
827 # think that's probably OK...
828 $template->param(atomcommentsurl =>
829 urlto($page).'comments.atom');
832 if ($template->query(name => 'commentslink')) {
833 my $num=num_comments($page, $config{srcdir});
836 $link = htmllink($page, $params{destpage}, $page,
837 linktext => sprintf(ngettext("%i comment", "%i comments", $num), $num),
838 anchor => "comments",
842 elsif (commentsopen($page)) {
843 $link = "<a href=\"".addcommenturl($page)."\">".
844 #translators: Here "Comment" is a verb;
845 #translators: the user clicks on it to
846 #translators: post a comment.
850 $template->param(commentslink => $link)
855 # everything below this point is only relevant to the comments
857 if (!exists $commentstate{$page}) {
861 if ($template->query(name => 'commentid')) {
862 $template->param(commentid => page_to_id($page));
865 if ($template->query(name => 'commentuser')) {
866 $template->param(commentuser =>
867 $commentstate{$page}{commentuser});
870 if ($template->query(name => 'commentopenid')) {
871 $template->param(commentopenid =>
872 $commentstate{$page}{commentopenid});
875 if ($template->query(name => 'commentip')) {
876 $template->param(commentip =>
877 $commentstate{$page}{commentip});
880 if ($template->query(name => 'commentauthor')) {
881 $template->param(commentauthor =>
882 $commentstate{$page}{commentauthor});
885 if ($template->query(name => 'commentauthorurl')) {
886 $template->param(commentauthorurl =>
887 $commentstate{$page}{commentauthorurl});
890 if ($template->query(name => 'commentauthoravatar')) {
891 $template->param(commentauthoravatar =>
892 $commentstate{$page}{commentauthoravatar});
895 if ($template->query(name => 'removeurl') &&
896 IkiWiki::Plugin::remove->can("check_canremove") &&
897 length $config{cgiurl}) {
898 $template->param(removeurl => IkiWiki::cgiurl(do => 'remove',
900 $template->param(have_actions => 1);
904 sub addcommenturl ($) {
907 return IkiWiki::cgiurl(do => 'comment', page => $page);
910 sub num_comments ($$) {
914 my @comments=glob("$dir/$page/$config{comments_pagename}*._comment");
915 return int @comments;
918 sub unique_comment_location ($$$$) {
920 eval q{use Digest::MD5 'md5_hex'};
922 my $content_md5=md5_hex(Encode::encode_utf8(shift));
924 my $ext=shift || "._comment";
927 my $i = num_comments($page, $dir);
930 $location = "$page/$config{comments_pagename}${i}_${content_md5}";
931 } while (-e "$dir/$location$ext");
937 # Converts a comment page name into a unique, legal html id
938 # attribute value, that can be used as an anchor to link to the
942 eval q{use Digest::MD5 'md5_hex'};
945 return "comment-".md5_hex(Encode::encode_utf8(($page)));
948 package IkiWiki::PageSpec;
950 sub match_postcomment ($$;@) {
954 if (! $postcomment) {
955 return IkiWiki::FailReason->new("not posting a comment");
957 return match_glob($page, $glob, @_);
960 sub match_comment ($$;@) {
964 if (! $postcomment) {
965 # To see if it's a comment, check the source file type.
966 # Deal with comments that were just deleted.
967 my $source=exists $IkiWiki::pagesources{$page} ?
968 $IkiWiki::pagesources{$page} :
969 $IkiWiki::delpagesources{$page};
970 my $type=defined $source ? IkiWiki::pagetype($source) : undef;
971 if (! defined $type || $type ne "_comment") {
972 return IkiWiki::FailReason->new("$page is not a comment");
976 return match_glob($page, "$glob/*", internal => 1, @_);
979 sub match_comment_pending ($$;@) {
983 my $source=exists $IkiWiki::pagesources{$page} ?
984 $IkiWiki::pagesources{$page} :
985 $IkiWiki::delpagesources{$page};
986 my $type=defined $source ? IkiWiki::pagetype($source) : undef;
987 if (! defined $type || $type ne "_comment_pending") {
988 return IkiWiki::FailReason->new("$page is not a pending comment");
991 return match_glob($page, "$glob/*", internal => 1, @_);