From 4745391360cf0843e376676479fee306d0a8312d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 12 Dec 2007 03:01:15 -0500 Subject: [PATCH] * Change formbuilder hook to not be responsible for displaying a form, so that more than one plugin can use this hook. I believe this is a safe change, since only passwordauth uses this hook. (If some other plugin already used it, it would have broken passwordauth!) --- IkiWiki/CGI.pm | 7 +++---- IkiWiki/Plugin/edittemplate.pm | 6 +++--- IkiWiki/Plugin/passwordauth.pm | 3 --- debian/changelog | 4 ++++ doc/plugins/write.mdwn | 6 ++---- 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 75f096e13..567fa85be 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -33,10 +33,9 @@ sub showform ($$$$) { #{{{ buttons => $buttons); }); } - else { - printheader($session); - print misctemplate($form->title, $form->render(submit => $buttons)); - } + + printheader($session); + print misctemplate($form->title, $form->render(submit => $buttons)); } sub redirect ($$) { #{{{ diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm index 20c948eb1..6689b9a5c 100644 --- a/IkiWiki/Plugin/edittemplate.pm +++ b/IkiWiki/Plugin/edittemplate.pm @@ -12,8 +12,8 @@ sub import { #{{{ call => \&needsbuild); hook(type => "preprocess", id => "edittemplate", call => \&preprocess); - hook(type => "formbuilder_setup", id => "edittemplate", - call => \&formbuilder_setup); + hook(type => "formbuilder", id => "edittemplate", + call => \&formbuilder); } #}}} sub needsbuild (@) { #{{{ @@ -49,7 +49,7 @@ sub preprocess (@) { #{{{ $params{template}, $params{match}); } # }}} -sub formbuilder_setup (@) { #{{{ +sub formbuilder (@) { #{{{ my %params=@_; my $form=$params{form}; diff --git a/IkiWiki/Plugin/passwordauth.pm b/IkiWiki/Plugin/passwordauth.pm index b61e6c86e..af16c2754 100644 --- a/IkiWiki/Plugin/passwordauth.pm +++ b/IkiWiki/Plugin/passwordauth.pm @@ -211,9 +211,6 @@ sub formbuilder (@) { #{{{ } } } - - IkiWiki::printheader($session); - print IkiWiki::misctemplate($form->title, $form->render(submit => $buttons)); } #}}} 1 diff --git a/debian/changelog b/debian/changelog index 2118aeaa0..e4d4083a9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,10 @@ ikiwiki (2.16) UNRELEASED; urgency=low * Fix file pruning code to work if ikiwiki is run with "." as the srcdir. * Add an edittemplate plugin, allowing registering template pages, that provide default content for new pages created using the web frontend. + * Change formbuilder hook to not be responsible for displaying a form, + so that more than one plugin can use this hook. + I believe this is a safe change, since only passwordauth uses this hook. + (If some other plugin already used it, it would have broken passwordauth!) -- Joey Hess Mon, 03 Dec 2007 14:47:36 -0500 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 1cb26a076..b7c487ee2 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -279,10 +279,8 @@ it's a form that it needs to modify, will call various methods to add/remove/change fields, tweak the validation code for the fields, etc. It will not validate or display the form. -Form validation and display can be overridden by the formbuilder hook. -By default, ikiwiki will do a basic validation and display of the form, -but if this hook is registered, it will stop that and let the hook take -over. +Just before a form is displayed to the user, the `formbuilder` hook is +called. It can be used to validate the form, but should not display it. ### savestate -- 2.26.2