From 29f32d0ba35fdd6ce25201146025917395c77c1b Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Tue, 22 Jul 2008 20:30:54 -0400
Subject: [PATCH] add a list of broken links after the rename
---
IkiWiki/Plugin/rename.pm | 75 ++++++++++++++++++++++--------------
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" => '');
-
- 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" => '');
+
+ 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 @@
Successfully renamed to .
-Summary of links: TODO
+
+The following pages still link to :
+
+
+No pages have broken links to .
+