summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-07-22 20:30:54 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-07-22 20:30:54 -0400
commit29f32d0ba35fdd6ce25201146025917395c77c1b (patch)
treedf690b151a42b1787afb644b1fddf835cd5015a7 /IkiWiki
parent1c9a3cb82b5810214d9c1b9bad2462cd7e784ff6 (diff)
add a list of broken links after the rename
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/rename.pm75
1 files changed, 46 insertions, 29 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);