* Applied Jeremie Koenig's pluggable editpage buttons patch:
- add a title to the editpage form; - pass a reference to the list of buttons to the formbuilder_setup hooks, so we can add ours; - relax asumption about the possible submit values (use "Save Page" explicitly); - de-hardcode the submit buttons from the editpage template (This was needed for compatability with a bug in CGI::FormBuilder 3.0401, but ikiwiki already needs a newer version.) * Pass buttons to all other formbuilder_setup hooks too.master
parent
ceae681a43
commit
ce7596dad9
|
@ -157,7 +157,8 @@ sub cgi_signin ($$) { #{{{
|
||||||
force => 1);
|
force => 1);
|
||||||
|
|
||||||
run_hooks(formbuilder_setup => sub {
|
run_hooks(formbuilder_setup => sub {
|
||||||
shift->(form => $form, cgi => $q, session => $session);
|
shift->(form => $form, cgi => $q, session => $session,
|
||||||
|
buttons => $buttons);
|
||||||
});
|
});
|
||||||
|
|
||||||
decode_form_utf8($form);
|
decode_form_utf8($form);
|
||||||
|
@ -228,7 +229,8 @@ sub cgi_prefs ($$) { #{{{
|
||||||
my $buttons=["Save Preferences", "Logout", "Cancel"];
|
my $buttons=["Save Preferences", "Logout", "Cancel"];
|
||||||
|
|
||||||
run_hooks(formbuilder_setup => sub {
|
run_hooks(formbuilder_setup => sub {
|
||||||
shift->(form => $form, cgi => $q, session => $session);
|
shift->(form => $form, cgi => $q, session => $session,
|
||||||
|
buttons => $buttons);
|
||||||
});
|
});
|
||||||
|
|
||||||
$form->field(name => "do", type => "hidden");
|
$form->field(name => "do", type => "hidden");
|
||||||
|
@ -304,6 +306,7 @@ sub cgi_editpage ($$) { #{{{
|
||||||
eval q{use CGI::FormBuilder};
|
eval q{use CGI::FormBuilder};
|
||||||
error($@) if $@;
|
error($@) if $@;
|
||||||
my $form = CGI::FormBuilder->new(
|
my $form = CGI::FormBuilder->new(
|
||||||
|
title => "editpage",
|
||||||
fields => \@fields,
|
fields => \@fields,
|
||||||
charset => "utf-8",
|
charset => "utf-8",
|
||||||
method => 'POST',
|
method => 'POST',
|
||||||
|
@ -321,7 +324,8 @@ sub cgi_editpage ($$) { #{{{
|
||||||
);
|
);
|
||||||
|
|
||||||
run_hooks(formbuilder_setup => sub {
|
run_hooks(formbuilder_setup => sub {
|
||||||
shift->(form => $form, cgi => $q, session => $session);
|
shift->(form => $form, cgi => $q, session => $session,
|
||||||
|
buttons => \@buttons);
|
||||||
});
|
});
|
||||||
|
|
||||||
decode_form_utf8($form);
|
decode_form_utf8($form);
|
||||||
|
@ -402,12 +406,12 @@ sub cgi_editpage ($$) { #{{{
|
||||||
preprocess($page, $page,
|
preprocess($page, $page,
|
||||||
filter($page, $page, $form->field('editcontent')), 0, 1))));
|
filter($page, $page, $form->field('editcontent')), 0, 1))));
|
||||||
}
|
}
|
||||||
else {
|
elsif ($form->submitted eq "Save Page") {
|
||||||
$form->tmpl_param("page_preview", "");
|
$form->tmpl_param("page_preview", "");
|
||||||
}
|
}
|
||||||
$form->tmpl_param("page_conflict", "");
|
$form->tmpl_param("page_conflict", "");
|
||||||
|
|
||||||
if (! $form->submitted || $form->submitted eq "Preview" ||
|
if ($form->submitted ne "Save Page" ||
|
||||||
! $form->validate) {
|
! $form->validate) {
|
||||||
if ($form->field("do") eq "create") {
|
if ($form->field("do") eq "create") {
|
||||||
my @page_locs;
|
my @page_locs;
|
||||||
|
|
|
@ -32,8 +32,18 @@ ikiwiki (2.6) UNRELEASED; urgency=low
|
||||||
* Fix bug when editing file from underlaydir, need to rcs_add it even though
|
* Fix bug when editing file from underlaydir, need to rcs_add it even though
|
||||||
a page creation isn't occuring.
|
a page creation isn't occuring.
|
||||||
* Various minor fixes and stylistic improvements suggested by Perl::Critic.
|
* Various minor fixes and stylistic improvements suggested by Perl::Critic.
|
||||||
|
* Applied Jeremie Koenig's pluggable editpage buttons patch:
|
||||||
|
- add a title to the editpage form;
|
||||||
|
- pass a reference to the list of buttons to the formbuilder_setup
|
||||||
|
hooks, so we can add ours;
|
||||||
|
- relax asumption about the possible submit values (use "Save Page"
|
||||||
|
explicitly);
|
||||||
|
- de-hardcode the submit buttons from the editpage template
|
||||||
|
(This was needed for compatability with a bug in CGI::FormBuilder
|
||||||
|
3.0401, but ikiwiki already needs a newer version.)
|
||||||
|
* Pass buttons to all other formbuilder_setup hooks too.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Wed, 15 Aug 2007 03:05:15 -0400
|
-- Joey Hess <joeyh@debian.org> Fri, 17 Aug 2007 01:19:44 -0400
|
||||||
|
|
||||||
ikiwiki (2.5) unstable; urgency=low
|
ikiwiki (2.5) unstable; urgency=low
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,11 @@ which does the following:
|
||||||
* de-hardcode the submit buttons from the editpage template
|
* de-hardcode the submit buttons from the editpage template
|
||||||
(was this intended to work around something?).
|
(was this intended to work around something?).
|
||||||
|
|
||||||
|
> That was there to work around a bug in CGI::FormBuilder 3.0401
|
||||||
|
> that broke FORM-SUBMIT on customised templates. That seems to be
|
||||||
|
> fixed in the newer version ikiwiki already depends on. Patch accepted.
|
||||||
|
> --[[Joey]]
|
||||||
|
|
||||||
## Problems
|
## Problems
|
||||||
|
|
||||||
No special handling is done of concurrent edits: changes introduced
|
No special handling is done of concurrent edits: changes introduced
|
||||||
|
|
|
@ -258,8 +258,9 @@ If the hook has no opinion about whether the edit can proceed, return
|
||||||
|
|
||||||
These hooks allow tapping into the parts of ikiwiki that use [[cpan
|
These hooks allow tapping into the parts of ikiwiki that use [[cpan
|
||||||
CGI::FormBuilder]] to generate web forms. These hooks are passed named
|
CGI::FormBuilder]] to generate web forms. These hooks are passed named
|
||||||
parameters: `cgi`, `session`, and `form`. These are, respectively, the
|
parameters: `cgi`, `session`, `form`, and `buttons`. These are, respectively,
|
||||||
`CGI` object, the user's `CGI::Session`, and a `CGI::FormBuilder`.
|
the `CGI` object, the user's `CGI::Session`, a `CGI::FormBuilder`, and a
|
||||||
|
reference to an array of names of buttons to go on the form.
|
||||||
|
|
||||||
Each time a form is set up, the `formbuilder_setup` hook is called.
|
Each time a form is set up, the `formbuilder_setup` hook is called.
|
||||||
Typically the `formbuilder_setup` hook will check the form's title, and if
|
Typically the `formbuilder_setup` hook will check the form's title, and if
|
||||||
|
|
|
@ -57,9 +57,7 @@ Page type: <TMPL_VAR FIELD-TYPE>
|
||||||
Optional comment about this change:<br />
|
Optional comment about this change:<br />
|
||||||
<TMPL_VAR FIELD-COMMENTS><br />
|
<TMPL_VAR FIELD-COMMENTS><br />
|
||||||
</TMPL_IF>
|
</TMPL_IF>
|
||||||
<input id="_submit" name="_submit" type="submit" value="Save Page" />
|
<TMPL_VAR FORM-SUBMIT>
|
||||||
<input id="_submit_2" name="_submit" type="submit" value="Preview" />
|
|
||||||
<input id="_submit_3" name="_submit" type="submit" value="Cancel" />
|
|
||||||
<TMPL_VAR HELPONFORMATTINGLINK>
|
<TMPL_VAR HELPONFORMATTINGLINK>
|
||||||
<TMPL_VAR FORM-END>
|
<TMPL_VAR FORM-END>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue