summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2008-12-30 21:36:40 +0100
committerintrigeri <intrigeri@boum.org>2008-12-30 21:36:40 +0100
commitc01485ae1ad751ac87eb3cfa392f6d276d5b1157 (patch)
tree62dd6f1ba3df0f6a669c08528f32be4202463ce4 /IkiWiki
parent4e4fb18dbecf22a9eeea37f2632924f6d1ea67da (diff)
renamed the renamepage hook to renamelink, added rename hook
Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/link.pm4
-rw-r--r--IkiWiki/Plugin/po.pm17
-rw-r--r--IkiWiki/Plugin/rename.pm16
3 files changed, 15 insertions, 22 deletions
diff --git a/IkiWiki/Plugin/link.pm b/IkiWiki/Plugin/link.pm
index 3799209d0..e9623035b 100644
--- a/IkiWiki/Plugin/link.pm
+++ b/IkiWiki/Plugin/link.pm
@@ -12,7 +12,7 @@ sub import {
hook(type => "checkconfig", id => "link", call => \&checkconfig);
hook(type => "linkify", id => "link", call => \&linkify);
hook(type => "scan", id => "link", call => \&scan);
- hook(type => "renamepage", id => "link", call => \&renamepage);
+ hook(type => "renamelink", id => "link", call => \&renamelink);
}
sub getsetup () {
@@ -90,7 +90,7 @@ sub scan (@) {
}
}
-sub renamepage (@) {
+sub renamelink (@) {
my %params=@_;
my $page=$params{page};
my $old=$params{oldpage};
diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm
index ae97a2f38..081752132 100644
--- a/IkiWiki/Plugin/po.pm
+++ b/IkiWiki/Plugin/po.pm
@@ -35,7 +35,7 @@ sub import { #{{{
hook(type => "filter", id => "po", call => \&filter);
hook(type => "htmlize", id => "po", call => \&htmlize);
hook(type => "pagetemplate", id => "po", call => \&pagetemplate, last => 1);
- hook(type => "renamepage", id => "po", call => \&renamepage);
+ hook(type => "rename", id => "po", call => \&renamepage);
hook(type => "delete", id => "po", call => \&mydelete);
hook(type => "change", id => "po", call => \&change);
hook(type => "editcontent", id => "po", call => \&editcontent);
@@ -330,22 +330,12 @@ sub pagetemplate (@) { #{{{
# Save information about master page rename, so that:
# - our delete hook can ignore the translations not renamed already
# - our change hook can rename the translations accordingly.
-#
-# FIXME:
-# This hook is called once per page linking to the old page, which
-# means our delete hook won't know it should not delete a renamed orphan
-# page's translation.
-#
-# Moreover, we can't recognize such pages at delete stage:
-# existing links are fixed in the renaming process, so every
-# renamed page's old location will be an orphan anyway at this time.
sub renamepage(@) { #{{{
my %params=@_;
my $oldpage=$params{oldpage};
my $newpage=$params{newpage};
setrenamed($oldpage, $newpage) if istranslatable($oldpage);
- return $params{content};
} #}}}
sub mydelete(@) { #{{{
@@ -822,9 +812,6 @@ sub homepageurl (;$) { #{{{
return urlto('', $page);
} #}}}
-# - do *not* implement this until the renamepage hook works
-# - do *not* delete translations of pages that were orphans
-# before being renamed (see renamepage hook comments above)
sub deletetranslations ($) { #{{{
my $deletedmasterfile=shift;
@@ -832,7 +819,7 @@ sub deletetranslations ($) { #{{{
} #}}}
sub renametranslations (@) { #{{{
- my ($oldpage, $newpage)=shift;
+ my ($oldpage, $newpage)=(shift, shift);
debug "po(renametranslations): TODO: rename translations of $oldpage to $newpage";
} #}}}
diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm
index b1bb15767..2200235f6 100644
--- a/IkiWiki/Plugin/rename.pm
+++ b/IkiWiki/Plugin/rename.pm
@@ -195,7 +195,7 @@ sub postrename ($;$$$) {
# Update edit form content to fix any links present
# on it.
$postrename->param("editcontent",
- renamepage_hook($dest, $src, $dest,
+ renamelink_hook($dest, $src, $dest,
$postrename->param("editcontent")));
# Get a new edit token; old was likely invalidated.
@@ -338,10 +338,16 @@ sub sessioncgi ($$) {
sprintf(gettext("rename %s to %s"), $srcfile, $destfile),
$session->param("name"), $ENV{REMOTE_ADDR}) if $config{rcs};
- # Then link fixups.
foreach my $rename (@torename) {
next if $rename->{src} eq $rename->{dest};
next if $rename->{error};
+ IkiWiki::run_hooks(rename => sub {
+ shift->(
+ oldpage => $src,
+ newpage => $dest,
+ );
+ });
+ # Then link fixups.
foreach my $p (fixlinks($rename, $session)) {
# map old page names to new
foreach my $r (@torename) {
@@ -420,10 +426,10 @@ sub sessioncgi ($$) {
}
}
-sub renamepage_hook ($$$$) {
+sub renamelink_hook ($$$$) {
my ($page, $src, $dest, $content)=@_;
- IkiWiki::run_hooks(renamepage => sub {
+ IkiWiki::run_hooks(renamelink => sub {
$content=shift->(
page => $page,
oldpage => $src,
@@ -480,7 +486,7 @@ sub fixlinks ($$$) {
if ($needfix) {
my $file=$pagesources{$page};
my $oldcontent=readfile($config{srcdir}."/".$file);
- my $content=renamepage_hook($page, $rename->{src}, $rename->{dest}, $oldcontent);
+ my $content=renamelink_hook($page, $rename->{src}, $rename->{dest}, $oldcontent);
if ($oldcontent ne $content) {
my $token=IkiWiki::rcs_prepedit($file);
eval { writefile($file, $config{srcdir}, $content) };