add a list of broken links after the rename
parent
1c9a3cb82b
commit
29f32d0ba3
|
@ -129,10 +129,8 @@ sub rename_start ($$$$) {
|
||||||
exit 0;
|
exit 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $renamesummary;
|
sub postrename ($;$$) {
|
||||||
sub postrename ($;$$$) {
|
|
||||||
my $session=shift;
|
my $session=shift;
|
||||||
my $src=shift;
|
|
||||||
my $dest=shift;
|
my $dest=shift;
|
||||||
my $attachment=shift;
|
my $attachment=shift;
|
||||||
|
|
||||||
|
@ -141,15 +139,6 @@ sub postrename ($;$$$) {
|
||||||
$session->clear("postrename");
|
$session->clear("postrename");
|
||||||
IkiWiki::cgi_savesession($session);
|
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) {
|
if (defined $dest && ! $attachment) {
|
||||||
# They renamed the page they were editing. This requires
|
# They renamed the page they were editing. This requires
|
||||||
# fixups to the edit form state.
|
# fixups to the edit form state.
|
||||||
|
@ -163,22 +152,6 @@ sub postrename ($;$$$) {
|
||||||
IkiWiki::cgi_editpage($postrename, $session);
|
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 (@) { #{{{
|
sub formbuilder (@) { #{{{
|
||||||
my %params=@_;
|
my %params=@_;
|
||||||
my $form=$params{form};
|
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 ($$) { #{{{
|
sub sessioncgi ($$) { #{{{
|
||||||
my $q=shift;
|
my $q=shift;
|
||||||
|
|
||||||
|
@ -255,7 +246,33 @@ sub sessioncgi ($$) { #{{{
|
||||||
IkiWiki::refresh();
|
IkiWiki::refresh();
|
||||||
IkiWiki::saveindex();
|
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 {
|
else {
|
||||||
IkiWiki::showform($form, $buttons, $session, $q);
|
IkiWiki::showform($form, $buttons, $session, $q);
|
||||||
|
|
|
@ -2,5 +2,12 @@
|
||||||
<b>Successfully renamed <TMPL_VAR SRC> to <TMPL_VAR DEST>.</b>
|
<b>Successfully renamed <TMPL_VAR SRC> to <TMPL_VAR DEST>.</b>
|
||||||
</p>
|
</p>
|
||||||
<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>
|
</p>
|
||||||
|
|
Loading…
Reference in New Issue