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 q{use Libravatar::URL};
194 if (defined $commentopenid) {
196 $commentauthoravatar = libravatar_url(openid => $commentopenid, https => $ENV{HTTPS});
199 if (! defined $commentauthoravatar &&
200 (my $email = IkiWiki::userinfo_get($commentuser, 'email'))) {
202 $commentauthoravatar = libravatar_url(email => $email, https => $ENV{HTTPS});
208 if (defined $params{ip}) {
209 $commentip = $params{ip};
211 $commentauthor = gettext("Anonymous");
214 $commentstate{$page}{commentuser} = $commentuser;
215 $commentstate{$page}{commentopenid} = $commentopenid;
216 $commentstate{$page}{commentip} = $commentip;
217 $commentstate{$page}{commentauthor} = $commentauthor;
218 $commentstate{$page}{commentauthorurl} = $commentauthorurl;
219 $commentstate{$page}{commentauthoravatar} = $commentauthoravatar;
220 if (! defined $pagestate{$page}{meta}{author}) {
221 $pagestate{$page}{meta}{author} = $commentauthor;
223 if (! defined $pagestate{$page}{meta}{authorurl}) {
224 $pagestate{$page}{meta}{authorurl} = $commentauthorurl;
227 if ($config{comments_allowauthor}) {
228 if (defined $params{claimedauthor}) {
229 $pagestate{$page}{meta}{author} = $params{claimedauthor};
232 if (defined $params{url}) {
233 my $url=$params{url};
235 eval q{use URI::Heuristic};
237 $url=URI::Heuristic::uf_uristr($url);
241 $pagestate{$page}{meta}{authorurl} = $url;
246 $pagestate{$page}{meta}{author} = $commentauthor;
247 $pagestate{$page}{meta}{authorurl} = $commentauthorurl;
250 if (defined $params{subject}) {
251 # decode title the same way meta does
252 eval q{use HTML::Entities};
253 $pagestate{$page}{meta}{title} = decode_entities($params{subject});
256 if ($params{page} =~ m/\/\Q$config{comments_pagename}\E\d+_/) {
257 $pagestate{$page}{meta}{permalink} = urlto(IkiWiki::dirname($params{page})).
258 "#".page_to_id($params{page});
261 eval q{use Date::Parse};
263 my $time = str2time($params{date});
264 $IkiWiki::pagectime{$page} = $time if defined $time;
270 sub preprocess_moderation {
273 $params{desc}=gettext("Comment Moderation")
274 unless defined $params{desc};
276 if (length $config{cgiurl}) {
278 IkiWiki::cgiurl(do => 'commentmoderation').
279 '">'.$params{desc}.'</a>';
282 return $params{desc};
286 sub sessioncgi ($$) {
290 my $do = $cgi->param('do');
291 if ($do eq 'comment') {
292 editcomment($cgi, $session);
294 elsif ($do eq 'commentmoderation') {
295 commentmoderation($cgi, $session);
297 elsif ($do eq 'commentsignin') {
298 IkiWiki::cgi_signin($cgi, $session);
303 # Mostly cargo-culted from IkiWiki::plugin::editpage
304 sub editcomment ($$) {
308 IkiWiki::decode_cgi_utf8($cgi);
310 eval q{use CGI::FormBuilder};
313 my @buttons = (POST_COMMENT, PREVIEW, CANCEL);
314 my $form = CGI::FormBuilder->new(
315 fields => [qw{do sid page subject editcontent type author url}],
318 required => [qw{editcontent}],
321 action => IkiWiki::cgiurl(),
324 template => { template('editcomment.tmpl') },
327 IkiWiki::decode_form_utf8($form);
328 IkiWiki::run_hooks(formbuilder_setup => sub {
329 shift->(title => "comment", form => $form, cgi => $cgi,
330 session => $session, buttons => \@buttons);
332 IkiWiki::decode_form_utf8($form);
334 my $type = $form->param('type');
335 if (defined $type && length $type && $IkiWiki::hooks{htmlize}{$type}) {
336 $type = IkiWiki::possibly_foolish_untaint($type);
339 $type = $config{default_pageext};
344 if (exists $IkiWiki::hooks{htmlize}) {
345 foreach my $key (grep { !/^_/ } keys %{$IkiWiki::hooks{htmlize}}) {
346 push @page_types, [$key, $IkiWiki::hooks{htmlize}{$key}{longname} || $key];
349 @page_types=sort @page_types;
351 $form->field(name => 'do', type => 'hidden');
352 $form->field(name => 'sid', type => 'hidden', value => $session->id,
354 $form->field(name => 'page', type => 'hidden');
355 $form->field(name => 'subject', type => 'text', size => 72);
356 $form->field(name => 'editcontent', type => 'textarea', rows => 10);
357 $form->field(name => "type", value => $type, force => 1,
358 type => 'select', options => \@page_types);
360 $form->tmpl_param(username => $session->param('name'));
362 if ($config{comments_allowauthor} and
363 ! defined $session->param('name')) {
364 $form->tmpl_param(allowauthor => 1);
365 $form->field(name => 'author', type => 'text', size => '40');
366 $form->field(name => 'url', type => 'text', size => '40');
369 $form->tmpl_param(allowauthor => 0);
370 $form->field(name => 'author', type => 'hidden', value => '',
372 $form->field(name => 'url', type => 'hidden', value => '',
376 if (! defined $session->param('name')) {
377 # Make signinurl work and return here.
378 $form->tmpl_param(signinurl => IkiWiki::cgiurl(do => 'commentsignin'));
379 $session->param(postsignin => $ENV{QUERY_STRING});
380 IkiWiki::cgi_savesession($session);
383 # The untaint is OK (as in editpage) because we're about to pass
384 # it to file_pruned and wiki_file_regexp anyway.
385 my ($page) = $form->field('page')=~/$config{wiki_file_regexp}/;
386 $page = IkiWiki::possibly_foolish_untaint($page);
387 if (! defined $page || ! length $page ||
388 IkiWiki::file_pruned($page)) {
389 error(gettext("bad page name"));
392 $form->title(sprintf(gettext("commenting on %s"),
393 IkiWiki::pagetitle(IkiWiki::basename($page))));
395 $form->tmpl_param('helponformattinglink',
396 htmllink($page, $page, 'ikiwiki/formatting',
398 linktext => 'FormattingHelp'),
399 allowdirectives => $config{allow_directives});
401 if ($form->submitted eq CANCEL) {
402 # bounce back to the page they wanted to comment on, and exit.
403 IkiWiki::redirect($cgi, urlto($page));
407 if (not exists $pagesources{$page}) {
408 error(sprintf(gettext(
409 "page '%s' doesn't exist, so you can't comment"),
413 if (pagespec_match($page, $config{comments_closed_pagespec},
414 location => $page)) {
415 error(sprintf(gettext(
416 "comments on page '%s' are closed"),
420 # Set a flag to indicate that we're posting a comment,
421 # so that postcomment() can tell it should match.
423 IkiWiki::check_canedit($page, $cgi, $session);
426 my $content = "[[!comment format=$type\n";
428 if (defined $session->param('name')) {
429 my $username = $session->param('name');
430 $username =~ s/"/"/g;
431 $content .= " username=\"$username\"\n";
433 if (defined $session->param('nickname')) {
434 my $nickname = $session->param('nickname');
435 $nickname =~ s/"/"/g;
436 $content .= " nickname=\"$nickname\"\n";
438 elsif (defined $session->remote_addr()) {
439 my $ip = $session->remote_addr();
440 if ($ip =~ m/^([.0-9]+)$/) {
441 $content .= " ip=\"$1\"\n";
445 if ($config{comments_allowauthor}) {
446 my $author = $form->field('author');
447 if (defined $author && length $author) {
448 $author =~ s/"/"/g;
449 $content .= " claimedauthor=\"$author\"\n";
451 my $url = $form->field('url');
452 if (defined $url && length $url) {
453 $url =~ s/"/"/g;
454 $content .= " url=\"$url\"\n";
458 my $subject = $form->field('subject');
459 if (defined $subject && length $subject) {
460 $subject =~ s/"/"/g;
463 $subject = "comment ".(num_comments($page, $config{srcdir}) + 1);
465 $content .= " subject=\"$subject\"\n";
467 $content .= " date=\"" . decode_utf8(strftime('%Y-%m-%dT%H:%M:%SZ', gmtime)) . "\"\n";
469 my $editcontent = $form->field('editcontent');
470 $editcontent="" if ! defined $editcontent;
471 $editcontent =~ s/\r\n/\n/g;
472 $editcontent =~ s/\r/\n/g;
473 $editcontent =~ s/"/\\"/g;
474 $content .= " content=\"\"\"\n$editcontent\n\"\"\"]]\n";
476 my $location=unique_comment_location($page, $content, $config{srcdir});
478 # This is essentially a simplified version of editpage:
479 # - the user does not control the page that's created, only the parent
480 # - it's always a create operation, never an edit
481 # - this means that conflicts should never happen
482 # - this means that if they do, rocks fall and everyone dies
484 if ($form->submitted eq PREVIEW) {
485 my $preview=previewcomment($content, $location, $page, time);
486 IkiWiki::run_hooks(format => sub {
487 $preview = shift->(page => $page,
488 content => $preview);
490 $form->tmpl_param(page_preview => $preview);
493 $form->tmpl_param(page_preview => "");
496 if ($form->submitted eq POST_COMMENT && $form->validate) {
497 IkiWiki::checksessionexpiry($cgi, $session);
500 my $ok=IkiWiki::check_content(content => $form->field('editcontent'),
501 subject => $form->field('subject'),
502 $config{comments_allowauthor} ? (
503 author => $form->field('author'),
504 url => $form->field('url'),
514 $location=unique_comment_location($page, $content, $config{srcdir}, "._comment_pending");
515 writefile("$location._comment_pending", $config{srcdir}, $content);
517 # Refresh so anything that deals with pending
518 # comments can be updated.
519 require IkiWiki::Render;
521 IkiWiki::saveindex();
523 IkiWiki::printheader($session);
524 print IkiWiki::cgitemplate($cgi, gettext(gettext("comment stored for moderation")),
526 gettext("Your comment will be posted after moderator review").
531 # FIXME: could probably do some sort of graceful retry
532 # on error? Would require significant unwinding though
533 my $file = "$location._comment";
534 writefile($file, $config{srcdir}, $content);
538 if ($config{rcs} and $config{comments_commit}) {
539 my $message = gettext("Added a comment");
540 if (defined $form->field('subject') &&
541 length $form->field('subject')) {
543 gettext("Added a comment: %s"),
544 $form->field('subject'));
547 IkiWiki::rcs_add($file);
548 IkiWiki::disable_commit_hook();
549 $conflict = IkiWiki::rcs_commit_staged(
553 IkiWiki::enable_commit_hook();
554 IkiWiki::rcs_update();
557 # Now we need a refresh
558 require IkiWiki::Render;
560 IkiWiki::saveindex();
562 # this should never happen, unless a committer deliberately
563 # breaks it or something
564 error($conflict) if defined $conflict;
566 # Jump to the new comment on the page.
567 # The trailing question mark tries to avoid broken
568 # caches and get the most recent version of the page.
569 IkiWiki::redirect($cgi, urlto($page).
570 "?updated#".page_to_id($location));
574 IkiWiki::showform($form, \@buttons, $session, $cgi,
581 sub commentmoderation ($$) {
585 IkiWiki::needsignin($cgi, $session);
586 if (! IkiWiki::is_admin($session->param("name"))) {
587 error(gettext("you are not logged in as an admin"));
590 IkiWiki::decode_cgi_utf8($cgi);
592 if (defined $cgi->param('sid')) {
593 IkiWiki::checksessionexpiry($cgi, $session);
595 my $rejectalldefer=$cgi->param('rejectalldefer');
599 foreach my $id (keys %vars) {
600 if ($id =~ /(.*)\._comment(?:_pending)?$/) {
601 $id=decode_utf8($id);
602 my $action=$cgi->param($id);
603 next if $action eq 'Defer' && ! $rejectalldefer;
605 # Make sure that the id is of a legal
607 my ($f) = $id =~ /$config{wiki_file_regexp}/;
608 if (! defined $f || ! length $f ||
609 IkiWiki::file_pruned($f)) {
610 error("illegal file");
613 my $page=IkiWiki::dirname($f);
614 my $file="$config{srcdir}/$f";
617 $file="$config{wikistatedir}/comments_pending/".$f;
620 if ($action eq 'Accept') {
621 my $content=eval { readfile($file) };
622 next if $@; # file vanished since form was displayed
623 my $dest=unique_comment_location($page, $content, $config{srcdir})."._comment";
624 writefile($dest, $config{srcdir}, $content);
625 if ($config{rcs} and $config{comments_commit}) {
626 IkiWiki::rcs_add($dest);
631 require IkiWiki::Render;
632 IkiWiki::prune($file);
638 if ($config{rcs} and $config{comments_commit}) {
639 my $message = gettext("Comment moderation");
640 IkiWiki::disable_commit_hook();
641 $conflict=IkiWiki::rcs_commit_staged(
645 IkiWiki::enable_commit_hook();
646 IkiWiki::rcs_update();
649 # Now we need a refresh
650 require IkiWiki::Render;
652 IkiWiki::saveindex();
654 error($conflict) if defined $conflict;
659 my ($id, $dir, $ctime)=@{$_};
660 my $content=readfile("$dir/$id");
661 my $preview=previewcomment($content, $id,
667 } sort { $b->[2] <=> $a->[2] } comments_pending();
669 my $template=template("commentmoderation.tmpl");
672 comments => \@comments,
673 cgiurl => IkiWiki::cgiurl(),
675 IkiWiki::printheader($session);
676 my $out=$template->output;
677 IkiWiki::run_hooks(format => sub {
678 $out = shift->(page => "", content => $out);
680 print IkiWiki::cgitemplate($cgi, gettext("comment moderation"), $out);
684 sub formbuilder_setup (@) {
687 my $form=$params{form};
688 if ($form->title eq "preferences" &&
689 IkiWiki::is_admin($params{session}->param("name"))) {
690 push @{$params{buttons}}, "Comment Moderation";
691 if ($form->submitted && $form->submitted eq "Comment Moderation") {
692 commentmoderation($params{cgi}, $params{session});
697 sub comments_pending () {
700 eval q{use File::Find};
704 my $origdir=getcwd();
706 my $find_comments=sub {
709 return unless -d $dir;
711 chdir($dir) || die "chdir $dir: $!";
716 my $file=decode_utf8($_);
718 return if ! length $file || IkiWiki::file_pruned($file)
719 || -l $_ || -d _ || $file !~ /\Q$extension\E$/;
720 my ($f) = $file =~ /$config{wiki_file_regexp}/; # untaint
722 my $ctime=(stat($_))[10];
723 push @ret, [$f, $dir, $ctime];
728 chdir($origdir) || die "chdir $origdir: $!";
731 $find_comments->($config{srcdir}, "._comment_pending");
733 $find_comments->("$config{wikistatedir}/comments_pending/",
739 sub previewcomment ($$$) {
745 # Previewing a comment should implicitly enable comment posting mode.
746 my $oldpostcomment=$postcomment;
749 my $preview = IkiWiki::htmlize($location, $page, '_comment',
750 IkiWiki::linkify($location, $page,
751 IkiWiki::preprocess($location, $page,
752 IkiWiki::filter($location, $page, $content), 0, 1)));
754 my $template = template("comment.tmpl");
755 $template->param(content => $preview);
756 $template->param(ctime => displaytime($time, undef, 1));
757 $template->param(html5 => $config{html5});
759 IkiWiki::run_hooks(pagetemplate => sub {
760 shift->(page => $location,
762 template => $template);
765 $template->param(have_actions => 0);
767 $postcomment=$oldpostcomment;
769 return $template->output;
772 sub commentsshown ($) {
775 return pagespec_match($page, $config{comments_pagespec},
779 sub commentsopen ($) {
782 return length $config{cgiurl} > 0 &&
783 (! length $config{comments_closed_pagespec} ||
784 ! pagespec_match($page, $config{comments_closed_pagespec},
788 sub pagetemplate (@) {
791 my $page = $params{page};
792 my $template = $params{template};
793 my $shown = ($template->query(name => 'commentslink') ||
794 $template->query(name => 'commentsurl') ||
795 $template->query(name => 'atomcommentsurl') ||
796 $template->query(name => 'comments')) &&
797 commentsshown($page);
799 if ($template->query(name => 'comments')) {
800 my $comments = undef;
802 $comments = IkiWiki::preprocess_inline(
803 pages => "comment($page) and !comment($page/*)",
804 template => 'comment',
808 destpage => $params{destpage},
809 feedfile => 'comments',
814 if (defined $comments && length $comments) {
815 $template->param(comments => $comments);
818 if ($shown && commentsopen($page)) {
819 $template->param(addcommenturl => addcommenturl($page));
824 if ($template->query(name => 'commentsurl')) {
825 $template->param(commentsurl =>
826 urlto($page).'#comments');
829 if ($template->query(name => 'atomcommentsurl') && $config{usedirs}) {
830 # This will 404 until there are some comments, but I
831 # think that's probably OK...
832 $template->param(atomcommentsurl =>
833 urlto($page).'comments.atom');
836 if ($template->query(name => 'commentslink')) {
837 my $num=num_comments($page, $config{srcdir});
840 $link = htmllink($page, $params{destpage}, $page,
841 linktext => sprintf(ngettext("%i comment", "%i comments", $num), $num),
842 anchor => "comments",
846 elsif (commentsopen($page)) {
847 $link = "<a href=\"".addcommenturl($page)."\">".
848 #translators: Here "Comment" is a verb;
849 #translators: the user clicks on it to
850 #translators: post a comment.
854 $template->param(commentslink => $link)
859 # everything below this point is only relevant to the comments
861 if (!exists $commentstate{$page}) {
865 if ($template->query(name => 'commentid')) {
866 $template->param(commentid => page_to_id($page));
869 if ($template->query(name => 'commentuser')) {
870 $template->param(commentuser =>
871 $commentstate{$page}{commentuser});
874 if ($template->query(name => 'commentopenid')) {
875 $template->param(commentopenid =>
876 $commentstate{$page}{commentopenid});
879 if ($template->query(name => 'commentip')) {
880 $template->param(commentip =>
881 $commentstate{$page}{commentip});
884 if ($template->query(name => 'commentauthor')) {
885 $template->param(commentauthor =>
886 $commentstate{$page}{commentauthor});
889 if ($template->query(name => 'commentauthorurl')) {
890 $template->param(commentauthorurl =>
891 $commentstate{$page}{commentauthorurl});
894 if ($template->query(name => 'commentauthoravatar')) {
895 $template->param(commentauthoravatar =>
896 $commentstate{$page}{commentauthoravatar});
899 if ($template->query(name => 'removeurl') &&
900 IkiWiki::Plugin::remove->can("check_canremove") &&
901 length $config{cgiurl}) {
902 $template->param(removeurl => IkiWiki::cgiurl(do => 'remove',
904 $template->param(have_actions => 1);
908 sub addcommenturl ($) {
911 return IkiWiki::cgiurl(do => 'comment', page => $page);
914 sub num_comments ($$) {
918 my @comments=glob("$dir/$page/$config{comments_pagename}*._comment");
919 return int @comments;
922 sub unique_comment_location ($$$$) {
924 eval q{use Digest::MD5 'md5_hex'};
926 my $content_md5=md5_hex(Encode::encode_utf8(shift));
928 my $ext=shift || "._comment";
931 my $i = num_comments($page, $dir);
934 $location = "$page/$config{comments_pagename}${i}_${content_md5}";
935 } while (-e "$dir/$location$ext");
941 # Converts a comment page name into a unique, legal html id
942 # attribute value, that can be used as an anchor to link to the
946 eval q{use Digest::MD5 'md5_hex'};
949 return "comment-".md5_hex(Encode::encode_utf8(($page)));
952 package IkiWiki::PageSpec;
954 sub match_postcomment ($$;@) {
958 if (! $postcomment) {
959 return IkiWiki::FailReason->new("not posting a comment");
961 return match_glob($page, $glob, @_);
964 sub match_comment ($$;@) {
968 if (! $postcomment) {
969 # To see if it's a comment, check the source file type.
970 # Deal with comments that were just deleted.
971 my $source=exists $IkiWiki::pagesources{$page} ?
972 $IkiWiki::pagesources{$page} :
973 $IkiWiki::delpagesources{$page};
974 my $type=defined $source ? IkiWiki::pagetype($source) : undef;
975 if (! defined $type || $type ne "_comment") {
976 return IkiWiki::FailReason->new("$page is not a comment");
980 return match_glob($page, "$glob/*", internal => 1, @_);
983 sub match_comment_pending ($$;@) {
987 my $source=exists $IkiWiki::pagesources{$page} ?
988 $IkiWiki::pagesources{$page} :
989 $IkiWiki::delpagesources{$page};
990 my $type=defined $source ? IkiWiki::pagetype($source) : undef;
991 if (! defined $type || $type ne "_comment_pending") {
992 return IkiWiki::FailReason->new("$page is not a pending comment");
995 return match_glob($page, "$glob/*", internal => 1, @_);