From: intrigeri Date: Thu, 1 Jan 2009 12:34:00 +0000 (+0100) Subject: Merge commit 'upstream/master' into prv/po X-Git-Url: https://scripts.mit.edu/gitweb/www/ikiwiki.git/commitdiff_plain/5c2f6cb8935f828274511ba5ca0d92b586632740?hp=-c Merge commit 'upstream/master' into prv/po --- 5c2f6cb8935f828274511ba5ca0d92b586632740 diff --combined IkiWiki/Plugin/link.pm index e9623035b,b79273f96..48691d973 --- a/IkiWiki/Plugin/link.pm +++ b/IkiWiki/Plugin/link.pm @@@ -3,7 -3,7 +3,7 @@@ package IkiWiki::Plugin::link use warnings; use strict; - use IkiWiki 2.00; + use IkiWiki 3.00; my $link_regexp; @@@ -12,7 -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 +90,7 @@@ sub scan (@) } } -sub renamepage (@) { +sub renamelink (@) { my %params=@_; my $page=$params{page}; my $old=$params{oldpage}; diff --combined IkiWiki/Plugin/parentlinks.pm index 866201e5e,ebf1d449a..1ee69cbff --- a/IkiWiki/Plugin/parentlinks.pm +++ b/IkiWiki/Plugin/parentlinks.pm @@@ -4,7 -4,7 +4,7 @@@ package IkiWiki::Plugin::parentlinks use warnings; use strict; - use IkiWiki 2.00; + use IkiWiki 3.00; sub import { hook(type => "parentlinks", id => "parentlinks", call => \&parentlinks); @@@ -36,7 -36,7 +36,7 @@@ sub parentlinks ($) $depth=$i; $height=($pagedepth - $depth); push @ret, { - url => urlto($path, $page), + url => urlto(bestlink($page, $path), $page), page => $title, depth => $depth, height => $height, diff --combined IkiWiki/Plugin/rename.pm index 227f59bfa,54c7faf13..25ddd2d65 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@@ -3,7 -3,7 +3,7 @@@ package IkiWiki::Plugin::rename use warnings; use strict; - use IkiWiki 2.00; + use IkiWiki 3.00; sub import { hook(type => "getsetup", id => "rename", call => \&getsetup); @@@ -195,7 -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. @@@ -291,8 -291,6 +291,8 @@@ sub sessioncgi ($$) required => 1, }; + IkiWiki::run_hooks(rename => sub { shift->(\@torename); }); + # See if any subpages need to be renamed. if ($q->param("subpages") && $src ne $dest) { foreach my $p (keys %pagesources) { @@@ -422,10 -420,10 +422,10 @@@ } } -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, @@@ -482,7 -480,7 +482,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) }; diff --combined doc/plugins/write.mdwn index d024a5dd4,405876d58..eb50ca4ef --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@@ -19,7 -19,7 +19,7 @@@ that can be fleshed out to make a usefu `IkiWiki::Plugin::pagecount` is another simple example. All perl plugins should `use IkiWiki` to import the ikiwiki plugin interface. It's a good idea to include the version number of the plugin interface that your plugin - expects: `use IkiWiki 2.00`. + expects: `use IkiWiki 3.00`. An external plugin is an executable program. It can be written in any language. Its interface to ikiwiki is via XML RPC, which it reads from @@@ -360,25 -360,14 +360,25 @@@ This hook is called whenever ikiwiki no the state is saved. The function can save other state, modify values before they're saved, etc. -### renamepage +### renamelink - hook(type => "renamepage", id => "foo", call => \&renamepage); + hook(type => "renamelink", id => "foo", call => \&renamelink); This hook is called by the [[plugins/rename]] plugin when it renames -something. The hook is passed named parameters: `page`, `oldpage`, -`newpage`, and `content`, and should try to modify the content to reflect -the name change. For example, by converting links to point to the new page. +something, once per page linking to the renamed page's old location. +The hook is passed named parameters: `page`, `oldpage`, `newpage`, and +`content`, and should try to modify the content of `page` to reflect +the name change. For example, by converting links to point to the +new page. + +### rename + + hook(type => "rename", id => "foo", call => \&renamepages); + +When a page or set of pages is renamed, the referenced function is +called, and passed a reference to an array of hashes with keys: +`src`, `srcfile`, `dest`, `destfile`, `required`. It can modify +the array. ### getsetup @@@ -442,7 -431,7 +442,7 @@@ describes the plugin as a whole. For ex To import the ikiwiki plugin interface: - use IkiWiki '2.00'; + use IkiWiki '3.00'; This will import several variables and functions into your plugin's namespace. These variables and functions are the ones most plugins need, @@@ -497,7 -486,7 +497,7 @@@ use the following hashes, using a page destination file. * `%pagesources` contains the name of the source file for each page. - Also, the %IkiWiki::version variable contains the version number for the + Also, the `%IkiWiki::version` variable contains the version number for the ikiwiki program. ### Library functions