diff options
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/CGI.pm | 1 | ||||
-rw-r--r-- | IkiWiki/Plugin/rename.pm | 46 |
2 files changed, 31 insertions, 16 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 287b1f5aa..4cb45895b 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -365,7 +365,6 @@ sub cgi_editpage ($$) { #{{{ htmllink($page, $page, "ikiwiki/formatting", noimageinline => 1, linktext => "FormattingHelp")); - $form->tmpl_param("message", ""); if ($form->submitted eq "Cancel") { if ($form->field("do") eq "create" && defined $from) { diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm index 9fa3f6a85..fdd9dc71c 100644 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@ -74,18 +74,6 @@ sub check_canrename ($$$$$$$) { #{{{ } } #}}} -sub formbuilder_setup (@) { #{{{ - my %params=@_; - my $form=$params{form}; - my $q=$params{cgi}; - - if (defined $form->field("do") && $form->field("do") eq "edit") { - # Rename button for the page, and also for attachments. - push @{$params{buttons}}, "Rename"; - $form->tmpl_param("field-rename" => '<input name="_submit" type="submit" value="Rename Attachment" />'); - } -} #}}} - sub rename_form ($$$) { #{{{ my $q=shift; my $session=shift; @@ -141,8 +129,10 @@ sub rename_start ($$$$) { exit 0; } -sub postrename ($;$$) { +my $renamesummary; +sub postrename ($;$$$) { my $session=shift; + my $src=shift; my $dest=shift; my $attachment=shift; @@ -151,6 +141,15 @@ sub postrename ($;$$) { $session->clear("postrename"); IkiWiki::cgi_savesession($session); + if (defined $src) { + # Generate a rename summary, that will be shown at the top + # of the edit template. + my $template=template("renamesummary.tmpl"); + $template->param(src => $src); + $template->param(dest => $dest); + $renamesummary=$template->output; + } + if (defined $dest && ! $attachment) { # They renamed the page they were editing. This requires # fixups to the edit form state. @@ -164,6 +163,22 @@ sub postrename ($;$$) { IkiWiki::cgi_editpage($postrename, $session); } +sub formbuilder_setup (@) { #{{{ + my %params=@_; + my $form=$params{form}; + my $q=$params{cgi}; + + if (defined $form->field("do") && $form->field("do") eq "edit") { + # Rename button for the page, and also for attachments. + push @{$params{buttons}}, "Rename"; + $form->tmpl_param("field-rename" => '<input name="_submit" type="submit" value="Rename Attachment" />'); + + if (defined $renamesummary) { + $form->tmpl_param(message => $renamesummary); + } + } +} #}}} + sub formbuilder (@) { #{{{ my %params=@_; my $form=$params{form}; @@ -226,7 +241,8 @@ sub sessioncgi ($$) { #{{{ if ($config{rcs}) { IkiWiki::disable_commit_hook(); IkiWiki::rcs_rename($srcfile, $destfile); - IkiWiki::rcs_commit_staged(sprintf(gettext("rename %s to %s", $src, $dest)), + IkiWiki::rcs_commit_staged( + sprintf(gettext("rename %s to %s"), $src, $dest), $session->param("name"), $ENV{REMOTE_ADDR}); IkiWiki::enable_commit_hook(); IkiWiki::rcs_update(); @@ -239,7 +255,7 @@ sub sessioncgi ($$) { #{{{ IkiWiki::refresh(); IkiWiki::saveindex(); - postrename($session, $dest, $q->param("attachment")); + postrename($session, $src, $dest, $q->param("attachment")); } else { IkiWiki::showform($form, $buttons, $session, $q); |