diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-07-22 20:30:54 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-07-22 20:30:54 -0400 |
commit | 29f32d0ba35fdd6ce25201146025917395c77c1b (patch) | |
tree | df690b151a42b1787afb644b1fddf835cd5015a7 | |
parent | 1c9a3cb82b5810214d9c1b9bad2462cd7e784ff6 (diff) |
add a list of broken links after the rename
-rw-r--r-- | IkiWiki/Plugin/rename.pm | 75 | ||||
-rw-r--r-- | templates/renamesummary.tmpl | 9 |
2 files changed, 54 insertions, 30 deletions
diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm index fdd9dc71c..38f703ddd 100644 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@ -129,10 +129,8 @@ sub rename_start ($$$$) { exit 0; } -my $renamesummary; -sub postrename ($;$$$) { +sub postrename ($;$$) { my $session=shift; - my $src=shift; my $dest=shift; my $attachment=shift; @@ -141,15 +139,6 @@ 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. @@ -163,22 +152,6 @@ 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}; @@ -203,6 +176,24 @@ sub formbuilder (@) { #{{{ } } #}}} +my $renamesummary; + +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 sessioncgi ($$) { #{{{ my $q=shift; @@ -255,7 +246,33 @@ sub sessioncgi ($$) { #{{{ IkiWiki::refresh(); IkiWiki::saveindex(); - postrename($session, $src, $dest, $q->param("attachment")); + # scan for broken links to $src + my @brokenlinks; + foreach my $page (keys %links) { + foreach my $link (@{$links{$page}}) { + my $bestlink=bestlink($page, $link); + if ($bestlink eq $src) { + push @brokenlinks, $page; + } + } + } + + # 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); + $template->param(linklist => [ + map { + { + page => htmllink($dest, $dest, $_, + noimageinline => 1) + } + } @brokenlinks + ]); + $renamesummary=$template->output; + + postrename($session, $dest, $q->param("attachment")); } else { IkiWiki::showform($form, $buttons, $session, $q); diff --git a/templates/renamesummary.tmpl b/templates/renamesummary.tmpl index 1d5e159d8..3d6866310 100644 --- a/templates/renamesummary.tmpl +++ b/templates/renamesummary.tmpl @@ -2,5 +2,12 @@ <b>Successfully renamed <TMPL_VAR SRC> to <TMPL_VAR DEST>.</b> </p> <p> -Summary of links: TODO +<TMPL_IF LINKLIST> +The following pages still link to <TMPL_VAR SRC>: +<ul> +<TMPL_LOOP NAME=LINKLIST><li><TMPL_VAR PAGE></li></TMPL_LOOP> +</ul> +<TMPL_ELSE> +No pages have broken links to <TMPL_VAR SRC>. +</TMPL_IF> </p> |