]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Applied Jeremie Koenig's pluggable editpage buttons patch:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 17 Aug 2007 05:34:59 +0000 (05:34 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Fri, 17 Aug 2007 05:34:59 +0000 (05:34 +0000)
  - 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.

IkiWiki/CGI.pm
debian/changelog
doc/plugins/contrib/showdiff.mdwn
doc/plugins/write.mdwn
templates/editpage.tmpl

index 07319ad22223da7261ee568ee1f46cbee3d394b7..e8df1fe1145dd4a37e6eebb3de1680dcfce99529 100644 (file)
@@ -157,7 +157,8 @@ sub cgi_signin ($$) { #{{{
                force => 1);
        
        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);
@@ -228,7 +229,8 @@ sub cgi_prefs ($$) { #{{{
        my $buttons=["Save Preferences", "Logout", "Cancel"];
 
        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");
@@ -304,6 +306,7 @@ sub cgi_editpage ($$) { #{{{
        eval q{use CGI::FormBuilder};
        error($@) if $@;
        my $form = CGI::FormBuilder->new(
+               title => "editpage",
                fields => \@fields,
                charset => "utf-8",
                method => 'POST',
@@ -321,7 +324,8 @@ sub cgi_editpage ($$) { #{{{
        );
        
        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);
@@ -402,12 +406,12 @@ sub cgi_editpage ($$) { #{{{
                        preprocess($page, $page,
                        filter($page, $page, $form->field('editcontent')), 0, 1))));
        }
-       else {
+       elsif ($form->submitted eq "Save Page") {
                $form->tmpl_param("page_preview", "");
        }
        $form->tmpl_param("page_conflict", "");
        
-       if (! $form->submitted || $form->submitted eq "Preview" || 
+       if ($form->submitted ne "Save Page" || 
            ! $form->validate) {
                if ($form->field("do") eq "create") {
                        my @page_locs;
index 381164e1525658cf304043d335823a9781261331..cca99ecf1b32dd4c50a298ee4f33b2c2b303f2c9 100644 (file)
@@ -32,8 +32,18 @@ ikiwiki (2.6) UNRELEASED; urgency=low
   * Fix bug when editing file from underlaydir, need to rcs_add it even though
     a page creation isn't occuring.
   * Various minor fixes and stylistic improvements suggested by Perl::Critic.
-
- -- Joey Hess <joeyh@debian.org>  Wed, 15 Aug 2007 03:05:15 -0400
+  * 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>  Fri, 17 Aug 2007 01:19:44 -0400
 
 ikiwiki (2.5) unstable; urgency=low
 
index cedc4311c96f165666842068a013840e24947817..0436fdef61a298cf642d95a4c59327e1d373bedb 100644 (file)
@@ -19,6 +19,11 @@ which does the following:
   * de-hardcode the submit buttons from the editpage template
     (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
 
 No special handling is done of concurrent edits: changes introduced
index 3030d65585d2cf4daea20dc74ee7d7d8348bb430..efb65523b323676589617dcd5520cfc7945defb8 100644 (file)
@@ -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
 CGI::FormBuilder]] to generate web forms. These hooks are passed named
-parameters: `cgi`, `session`, and `form`. These are, respectively, the
-`CGI` object, the user's `CGI::Session`, and a `CGI::FormBuilder`.
+parameters: `cgi`, `session`, `form`, and `buttons`. These are, respectively,
+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.
 Typically the `formbuilder_setup` hook will check the form's title, and if
index 18e00849ba1f23eee0086f8b3ff2e0b94085342d..cf4950ead9210fe42cdf126b4299cba1f55dccd4 100644 (file)
@@ -57,9 +57,7 @@ Page type: <TMPL_VAR FIELD-TYPE>
 Optional comment about this change:<br />
 <TMPL_VAR FIELD-COMMENTS><br />
 </TMPL_IF>
-<input id="_submit" name="_submit" type="submit" value="Save Page" />
-<input id="_submit_2" name="_submit" type="submit" value="Preview" />
-<input id="_submit_3" name="_submit" type="submit" value="Cancel" />
+<TMPL_VAR FORM-SUBMIT>
 <TMPL_VAR HELPONFORMATTINGLINK>
 <TMPL_VAR FORM-END>