aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/rename.pm73
-rw-r--r--po/ikiwiki.pot45
-rw-r--r--templates/renamesummary.tmpl10
3 files changed, 96 insertions, 32 deletions
diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm
index 38f703ddd..553a67396 100644
--- a/IkiWiki/Plugin/rename.pm
+++ b/IkiWiki/Plugin/rename.pm
@@ -144,11 +144,11 @@ sub postrename ($;$$) {
# fixups to the edit form state.
# Tweak the edit form to be editing the new page.
$postrename->param("page", $dest);
- # Get a new edit token; old one might not be valid for the
- # renamed file.
- $postrename->param("rcsinfo", IkiWiki::rcs_prepedit($pagesources{$dest}));
}
+ # Get a new edit token; old likely not valid.
+ $postrename->param("rcsinfo", IkiWiki::rcs_prepedit($pagesources{$dest}));
+
IkiWiki::cgi_editpage($postrename, $session);
}
@@ -227,26 +227,56 @@ sub sessioncgi ($$) { #{{{
# Ensures that the dest directory exists and is ok.
IkiWiki::prep_writefile($destfile, $config{srcdir});
- # Do rename, and update the wiki.
+ # Do rename, update other pages, and refresh site.
+ IkiWiki::disable_commit_hook() if $config{rcs};
require IkiWiki::Render;
if ($config{rcs}) {
- IkiWiki::disable_commit_hook();
IkiWiki::rcs_rename($srcfile, $destfile);
IkiWiki::rcs_commit_staged(
sprintf(gettext("rename %s to %s"), $src, $dest),
$session->param("name"), $ENV{REMOTE_ADDR});
- IkiWiki::enable_commit_hook();
- IkiWiki::rcs_update();
}
else {
if (! rename("$config{srcdir}/$srcfile", "$config{srcdir}/$destfile")) {
error("rename: $!");
}
}
+ my @fixedlinks;
+ foreach my $page (keys %links) {
+ my $needfix=0;
+ foreach my $link (@{$links{$page}}) {
+ my $bestlink=bestlink($page, $link);
+ if ($bestlink eq $src) {
+ $needfix=1;
+ }
+ }
+ if ($needfix) {
+ my $file=$pagesources{$page};
+ my $oldcontent=readfile($config{srcdir}."/".$file);
+ my $content=renamepage_hook($page, $src, $dest, $oldcontent);
+ if ($oldcontent ne $content) {
+ my $token=IkiWiki::rcs_prepedit($file);
+ eval { writefile($file, $config{srcdir}, $content) };
+ next if $@;
+ my $conflict=IkiWiki::rcs_commit(
+ $file,
+ sprintf(gettext("update for rename of %s to %s"), $src, $dest),
+ $token,
+ $session->param("name"),
+ $ENV{REMOTE_ADDR}
+ );
+ push @fixedlinks, $page if ! defined $conflict;
+ }
+ }
+ }
+ if ($config{rcs}) {
+ IkiWiki::enable_commit_hook();
+ IkiWiki::rcs_update();
+ }
IkiWiki::refresh();
IkiWiki::saveindex();
- # scan for broken links to $src
+ # Scan for any remaining broken links to $src.
my @brokenlinks;
foreach my $page (keys %links) {
foreach my $link (@{$links{$page}}) {
@@ -262,7 +292,7 @@ sub sessioncgi ($$) { #{{{
my $template=template("renamesummary.tmpl");
$template->param(src => $src);
$template->param(dest => $dest);
- $template->param(linklist => [
+ $template->param(brokenlinks => [
map {
{
page => htmllink($dest, $dest, $_,
@@ -270,6 +300,14 @@ sub sessioncgi ($$) { #{{{
}
} @brokenlinks
]);
+ $template->param(fixedlinks => [
+ map {
+ {
+ page => htmllink($dest, $dest, $_,
+ noimageinline => 1)
+ }
+ } @fixedlinks
+ ]);
$renamesummary=$template->output;
postrename($session, $dest, $q->param("attachment"));
@@ -280,6 +318,21 @@ sub sessioncgi ($$) { #{{{
exit 0;
}
-}
+} #}}}
+
+sub renamepage_hook ($$$$) { #{{{
+ my ($page, $src, $dest, $content)=@_;
+
+ IkiWiki::run_hooks(renamepage => sub {
+ $content=shift->(
+ page => $page,
+ oldpage => $src,
+ newpage => $dest,
+ content => $content,
+ );
+ });
+
+ return $content;
+}# }}}
1
diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot
index 621bfdd4d..35b3bef51 100644
--- a/po/ikiwiki.pot
+++ b/po/ikiwiki.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-07-22 19:44-0400\n"
+"POT-Creation-Date: 2008-07-23 18:43-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -24,7 +24,7 @@ msgstr ""
msgid "login failed, perhaps you need to turn on cookies?"
msgstr ""
-#: ../IkiWiki/CGI.pm:190 ../IkiWiki/CGI.pm:527
+#: ../IkiWiki/CGI.pm:190 ../IkiWiki/CGI.pm:526
msgid "Your login session has expired."
msgstr ""
@@ -49,29 +49,29 @@ msgstr ""
msgid "%s is not an editable page"
msgstr ""
-#: ../IkiWiki/CGI.pm:438 ../IkiWiki/Plugin/brokenlinks.pm:24
+#: ../IkiWiki/CGI.pm:437 ../IkiWiki/Plugin/brokenlinks.pm:24
#: ../IkiWiki/Plugin/inline.pm:261 ../IkiWiki/Plugin/opendiscussion.pm:17
#: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:78
#: ../IkiWiki/Render.pm:148
msgid "discussion"
msgstr ""
-#: ../IkiWiki/CGI.pm:494
+#: ../IkiWiki/CGI.pm:493
#, perl-format
msgid "creating %s"
msgstr ""
-#: ../IkiWiki/CGI.pm:512 ../IkiWiki/CGI.pm:540 ../IkiWiki/CGI.pm:550
-#: ../IkiWiki/CGI.pm:586 ../IkiWiki/CGI.pm:631
+#: ../IkiWiki/CGI.pm:511 ../IkiWiki/CGI.pm:539 ../IkiWiki/CGI.pm:549
+#: ../IkiWiki/CGI.pm:584 ../IkiWiki/CGI.pm:629
#, perl-format
msgid "editing %s"
msgstr ""
-#: ../IkiWiki/CGI.pm:731
+#: ../IkiWiki/CGI.pm:729
msgid "You are banned."
msgstr ""
-#: ../IkiWiki/CGI.pm:760 ../IkiWiki/CGI.pm:761 ../IkiWiki.pm:783
+#: ../IkiWiki/CGI.pm:758 ../IkiWiki/CGI.pm:759 ../IkiWiki.pm:783
msgid "Error"
msgstr ""
@@ -553,24 +553,29 @@ msgstr ""
msgid "%s already exists on disk"
msgstr ""
-#: ../IkiWiki/Plugin/rename.pm:98
+#: ../IkiWiki/Plugin/rename.pm:86
#, perl-format
msgid "rename %s"
msgstr ""
-#: ../IkiWiki/Plugin/rename.pm:181
+#: ../IkiWiki/Plugin/rename.pm:169
msgid "Only one attachment can be renamed at a time."
msgstr ""
-#: ../IkiWiki/Plugin/rename.pm:184
+#: ../IkiWiki/Plugin/rename.pm:172
msgid "Please select the attachment to rename."
msgstr ""
-#: ../IkiWiki/Plugin/rename.pm:229
+#: ../IkiWiki/Plugin/rename.pm:236
#, perl-format
msgid "rename %s to %s"
msgstr ""
+#: ../IkiWiki/Plugin/rename.pm:263
+#, perl-format
+msgid "update for rename of %s to %s"
+msgstr ""
+
#: ../IkiWiki/Plugin/search.pm:20
#, perl-format
msgid "Must specify %s when using the search plugin"
@@ -692,42 +697,42 @@ msgstr ""
msgid "skipping bad filename %s"
msgstr ""
-#: ../IkiWiki/Render.pm:351
+#: ../IkiWiki/Render.pm:355
#, perl-format
msgid "removing old page %s"
msgstr ""
-#: ../IkiWiki/Render.pm:391
+#: ../IkiWiki/Render.pm:395
#, perl-format
msgid "scanning %s"
msgstr ""
-#: ../IkiWiki/Render.pm:396
+#: ../IkiWiki/Render.pm:400
#, perl-format
msgid "rendering %s"
msgstr ""
-#: ../IkiWiki/Render.pm:417
+#: ../IkiWiki/Render.pm:421
#, perl-format
msgid "rendering %s, which links to %s"
msgstr ""
-#: ../IkiWiki/Render.pm:438
+#: ../IkiWiki/Render.pm:442
#, perl-format
msgid "rendering %s, which depends on %s"
msgstr ""
-#: ../IkiWiki/Render.pm:477
+#: ../IkiWiki/Render.pm:481
#, perl-format
msgid "rendering %s, to update its backlinks"
msgstr ""
-#: ../IkiWiki/Render.pm:489
+#: ../IkiWiki/Render.pm:493
#, perl-format
msgid "removing %s, no longer rendered by %s"
msgstr ""
-#: ../IkiWiki/Render.pm:513
+#: ../IkiWiki/Render.pm:517
#, perl-format
msgid "ikiwiki: cannot render %s"
msgstr ""
diff --git a/templates/renamesummary.tmpl b/templates/renamesummary.tmpl
index 3d6866310..2676082f2 100644
--- a/templates/renamesummary.tmpl
+++ b/templates/renamesummary.tmpl
@@ -2,10 +2,16 @@
<b>Successfully renamed <TMPL_VAR SRC> to <TMPL_VAR DEST>.</b>
</p>
<p>
-<TMPL_IF LINKLIST>
+<TMPL_IF FIXEDLINKS>
+The following pages have been automatically modified to update their links to <TMPL_VAR DEST>:
+<ul>
+<TMPL_LOOP NAME=FIXEDLINKS><li><TMPL_VAR PAGE></li></TMPL_LOOP>
+</ul>
+</TMPL_IF>
+<TMPL_IF BROKENLINKS>
The following pages still link to <TMPL_VAR SRC>:
<ul>
-<TMPL_LOOP NAME=LINKLIST><li><TMPL_VAR PAGE></li></TMPL_LOOP>
+<TMPL_LOOP NAME=BROKENLINKS><li><TMPL_VAR PAGE></li></TMPL_LOOP>
</ul>
<TMPL_ELSE>
No pages have broken links to <TMPL_VAR SRC>.