avoid link fixup if page name stayed the same

master
Joey Hess 2008-08-07 16:17:50 -04:00
parent 46b9a83b61
commit 11550f9593
2 changed files with 59 additions and 53 deletions

View File

@ -249,9 +249,6 @@ sub sessioncgi ($$) { #{{{
my $srcfile=IkiWiki::possibly_foolish_untaint($pagesources{$src});
my $dest=IkiWiki::possibly_foolish_untaint(IkiWiki::titlepage($q->param("new_name")));
# The extension of dest is the same as src if it's
# a page. If it's an attachment, the extension is
# already included.
my $destfile=$dest;
if (! $q->param("attachment")) {
my $type=$q->param('type');
@ -286,6 +283,7 @@ sub sessioncgi ($$) { #{{{
}
}
my @fixedlinks;
if ($src ne $dest) {
foreach my $page (keys %links) {
my $needfix=0;
foreach my $link (@{$links{$page}}) {
@ -314,6 +312,7 @@ sub sessioncgi ($$) { #{{{
}
}
}
}
if ($config{rcs}) {
IkiWiki::enable_commit_hook();
IkiWiki::rcs_update();
@ -323,6 +322,7 @@ sub sessioncgi ($$) { #{{{
# Scan for any remaining broken links to $src.
my @brokenlinks;
if ($src ne $dest) {
foreach my $page (keys %links) {
my $broken=0;
foreach my $link (@{$links{$page}}) {
@ -334,12 +334,15 @@ sub sessioncgi ($$) { #{{{
}
push @brokenlinks, $page if $broken;
}
}
# 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(src => $srcfile);
$template->param(dest => $destfile);
if ($src ne $dest) {
$template->param(brokenlinks_checked => 1);
$template->param(brokenlinks => [
map {
{
@ -356,6 +359,7 @@ sub sessioncgi ($$) { #{{{
}
} @fixedlinks
]);
}
$renamesummary=$template->output;
postrename($session, $src, $dest, $q->param("attachment"));

View File

@ -8,6 +8,7 @@ The following pages have been automatically modified to update their links to <T
<TMPL_LOOP NAME=FIXEDLINKS><li><TMPL_VAR PAGE></li></TMPL_LOOP>
</ul>
</TMPL_IF>
<TMPL_IF BROKENLINKS_CHECKED>
<TMPL_IF BROKENLINKS>
The following pages still link to <TMPL_VAR SRC>:
<ul>
@ -16,4 +17,5 @@ The following pages still link to <TMPL_VAR SRC>:
<TMPL_ELSE>
No pages have broken links to <TMPL_VAR SRC>.
</TMPL_IF>
</TMPL_IF>
</p>