From: Joey Hess
Date: Wed, 23 Jul 2008 00:30:54 +0000 (-0400)
Subject: add a list of broken links after the rename
X-Git-Tag: 2.55~63
X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=29f32d0ba35fdd6ce25201146025917395c77c1b;p=ikiwiki.git
add a list of broken links after the rename
---
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 .
+