GetEditForm and GetCommentForm will now call all the subs in
@FormChanges in order to let them change the generated HTML. This is
used by all the modules that used to hook into either of these two
functions.
A typical change from questionasker.pl:
push(@MyFormChanges, \&QuestionAddTo);
sub QuestionAddTo {
my ($form, $type, $upload) = @_;
if (not $upload
and not QuestionaskerException(GetId())
and not $QuestionaskerRememberAnswer && GetParam($QuestionaskerSecretKey, 0)
and not UserIsEditor()) {
my $question = QuestionaskerGetQuestion();
$form =~ s/(.*)<p>(.*?)<label for="username">/$1$question<p>$2<label for="username">/;
}
return $form;
}
This commit als moves from &$foo to $foo->() based on a recommendation
in Modern Perl by Conway.
We already called all the subs on @MyFooters and printed the result,
but this commit moves all the code from PrintFooters into subs and
puts those subs on @MyFooters. This allows us to write modules that
can better control where exactly their output should appear. In this
case the change was required in order to allow the Google +1 module to
coexist with code that maybe prints the comment form for all pages.
For example, knowing that the Google +1 sub is the first on one the
list because of unshift(@MyFooters, \&GooglePlusPrintFooter), we can
now write the following:
splice(@MyFooters, 1, 0, \&MyCommentsInTheFooter);
sub MyCommentsInTheFooter {
my ($id, $rev, $comment) = @_;
if (not $GooglePlusThisPagePrintedJournal
and (GetParam('action', 'browse') eq 'browse'
and $id and $CommentsPrefix
and $id ne $RCName
and $id !~ /^$CommentsPrefix(.*)/o)) {
my $target = $CommentsPrefix . $id;
my $page = '';
$page = PageHtml($target) if $IndexHash{$target};
return $q->div({-class=>'comment'},
$q->h2(T('Comments')),
$page)
. GetCommentForm("$CommentsPrefix$id", $rev, $comment);
}
}
The Google +1 extension was also fixed to not triger the EFF's Privacy
Badger. This is OK because we're using a two step button: The user
needs to click a button before we're loading the script from Google.
The EN DASH is not really required in year ranges such as 2012–2015 when
we're talking about comments in source code that is probably being
displayed in a fixed font anyway. Changing back to an ordinary hypen
allows us to make a meaningful test for use utf8.
Replaced the $Id$ tags in $WikiDescription for all the modules and wiki.pl itself with a link to the source and an appropriate wiki page, if possible. This is shown in action=version and should help users figure out what another wiki has installed.
parameters and ask another question if the question has not been
answered.
(NewQuestionaskerGetFormStart, NewQuestionaskerGetEditForm): Hook
into GetEditForm instead of GetFormStart.
logging of Q&A.
($QuestionaskerRememberAnswer): New option.
(QuestionaskerInit): Add question parameter to cookie.
(NewQuestionaskerDoPost): Set question parameter in cookie if
answered correctly.
(NewQuestionaskerDoPost, NewQuestionaskerGetFormStart): Use new
option and parameter from cookie.
required for previews. Log all questions and answers. Print
footer.
(@QuestionaskerQuestions): Make default questions harder to answer
such that pasting spam into the answer field does not have a high
chance of answering the question.
(NewQuestionaskerDoPost): Extract id from the title parameter.
(%QuestionaskerProtectedForms): New option.
(NewQuestionaskerGetFormStart): Use it.
(QuestionaskerGetQuestion): Use CGI.pm functions to create HTML.
Make valid HTML.
option removed.
(NewQuestionaskerDoPost): Removed bypass.
(@QuestionaskerQuestions): Uncommented some questions, removed
some others.
(QuestionaskerException): New.
(NewQuestionaskerGetFormStart): No questions asked for admins.
Check for exceptions.