From d68d25526816d40048ca47ad360304bce162b659 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 28 Mar 2012 18:41:47 -0400 Subject: [PATCH] Added a "changes" hook. Renamed the "change" hook to "rendered", but the old hook name is called for now for back-compat. --- IkiWiki/Plugin/inline.pm | 2 +- IkiWiki/Plugin/pinger.pm | 2 +- IkiWiki/Plugin/po.pm | 4 ++-- IkiWiki/Plugin/rsync.pm | 2 +- IkiWiki/Plugin/skeleton.pm.example | 13 ++++++++++--- IkiWiki/Plugin/transient.pm | 4 ++-- IkiWiki/Render.pm | 7 ++++++- debian/changelog | 5 ++++- doc/plugins/write.mdwn | 19 +++++++++++++++---- 9 files changed, 42 insertions(+), 16 deletions(-) diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 62910972f..3b49152f4 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -26,7 +26,7 @@ sub import { # Hook to change to do pinging since it's called late. # This ensures each page only pings once and prevents slow # pings interrupting page builds. - hook(type => "change", id => "inline", call => \&IkiWiki::pingurl); + hook(type => "rendered", id => "inline", call => \&IkiWiki::pingurl); } sub getopt () { diff --git a/IkiWiki/Plugin/pinger.pm b/IkiWiki/Plugin/pinger.pm index ea4f3e0dc..588f7a42a 100644 --- a/IkiWiki/Plugin/pinger.pm +++ b/IkiWiki/Plugin/pinger.pm @@ -13,7 +13,7 @@ sub import { hook(type => "needsbuild", id => "pinger", call => \&needsbuild); hook(type => "preprocess", id => "ping", call => \&preprocess); hook(type => "delete", id => "pinger", call => \&ping); - hook(type => "change", id => "pinger", call => \&ping); + hook(type => "rendered", id => "pinger", call => \&ping); } sub getsetup () { diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 287b5aa11..26c6463da 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -47,7 +47,7 @@ sub import { hook(type => "pagetemplate", id => "po", call => \&pagetemplate, last => 1); hook(type => "rename", id => "po", call => \&renamepages, first => 1); hook(type => "delete", id => "po", call => \&mydelete); - hook(type => "change", id => "po", call => \&change); + hook(type => "rendered", id => "po", call => \&rendered); hook(type => "checkcontent", id => "po", call => \&checkcontent); hook(type => "canremove", id => "po", call => \&canremove); hook(type => "canrename", id => "po", call => \&canrename); @@ -427,7 +427,7 @@ sub mydelete (@) { map { deletetranslations($_) } grep istranslatablefile($_), @deleted; } -sub change (@) { +sub rendered (@) { my @rendered=@_; my $updated_po_files=0; diff --git a/IkiWiki/Plugin/rsync.pm b/IkiWiki/Plugin/rsync.pm index e38801e4a..1b85ea000 100644 --- a/IkiWiki/Plugin/rsync.pm +++ b/IkiWiki/Plugin/rsync.pm @@ -7,7 +7,7 @@ use IkiWiki 3.00; sub import { hook(type => "getsetup", id => "rsync", call => \&getsetup); - hook(type => "change", id => "rsync", call => \&postrefresh); + hook(type => "rendered", id => "rsync", call => \&postrefresh); hook(type => "delete", id => "rsync", call => \&postrefresh); } diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example index 7974d5e53..956c52201 100644 --- a/IkiWiki/Plugin/skeleton.pm.example +++ b/IkiWiki/Plugin/skeleton.pm.example @@ -26,7 +26,8 @@ sub import { hook(type => "templatefile", id => "skeleton", call => \&templatefile); hook(type => "pageactions", id => "skeleton", call => \&pageactions); hook(type => "delete", id => "skeleton", call => \&delete); - hook(type => "change", id => "skeleton", call => \&change); + hook(type => "rendered", id => "skeleton", call => \&rendered); + hook(type => "changes", id => "skeleton", call => \&changes); hook(type => "cgi", id => "skeleton", call => \&cgi); hook(type => "auth", id => "skeleton", call => \&auth); hook(type => "sessioncgi", id => "skeleton", call => \&sessioncgi); @@ -167,10 +168,16 @@ sub delete (@) { debug("skeleton plugin told that files were deleted: @files"); } -sub change (@) { +sub rendered (@) { my @files=@_; - debug("skeleton plugin told that changed files were rendered: @files"); + debug("skeleton plugin told that files were rendered: @files"); +} + +sub changes (@) { + my @files=@_; + + debug("skeleton plugin told that files were changed: @files"); } sub cgi ($) { diff --git a/IkiWiki/Plugin/transient.pm b/IkiWiki/Plugin/transient.pm index c0ad5fc11..4ea4317d4 100644 --- a/IkiWiki/Plugin/transient.pm +++ b/IkiWiki/Plugin/transient.pm @@ -8,7 +8,7 @@ use IkiWiki 3.00; sub import { hook(type => "getsetup", id => "transient", call => \&getsetup); hook(type => "checkconfig", id => "transient", call => \&checkconfig); - hook(type => "change", id => "transient", call => \&change); + hook(type => "rendered", id => "transient", call => \&rendered); } sub getsetup () { @@ -33,7 +33,7 @@ sub checkconfig () { } } -sub change (@) { +sub rendered (@) { foreach my $file (@_) { # If the corresponding file exists in the transient underlay # and isn't actually being used, we can get rid of it. diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index adb39a983..98aab8204 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -829,8 +829,13 @@ sub refresh () { run_hooks(delete => sub { shift->(@$del, @$internal_del) }); } if (%rendered) { - run_hooks(change => sub { shift->(keys %rendered) }); + run_hooks(rendered => sub { shift->(keys %rendered) }); + run_hooks(change => sub { shift->(keys %rendered) }); # back-compat } + run_hooks(difference => sub { + shift->(@$new, @$changed, @$del, + @$internal_new, @$internal_changed, @$internal_del); + }); } sub clean_rendered { diff --git a/debian/changelog b/debian/changelog index 90e619cd1..861679b4e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,7 +5,10 @@ ikiwiki (3.20120204) UNRELEASED; urgency=low them. * meta: Export author information in html tag. Closes: #664779 Thanks, Martin Michlmayr - * changemail: New plugin, sends emails about changed pages. + * notifyemail: New plugin, sends email notifications about new and + changed pages. + * Added a "changes" hook. Renamed the "change" hook to "rendered", but + the old hook name is called for now for back-compat. -- Joey Hess Wed, 21 Mar 2012 14:33:14 -0400 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index cc5f6e5ed..4c66e51f8 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -376,17 +376,28 @@ the second is a log message resembling hook(type => "delete", id => "foo", call => \&delete); -Each time a page or pages is removed from the wiki, the referenced function +After a page or pages is removed from the wiki, the referenced function is called, and passed the names of the source files that were removed. -### change +### rendered - hook(type => "change", id => "foo", call => \&render); + hook(type => "rendered", id => "foo", call => \&rendered); -Each time ikiwiki renders a change or addition (but not deletion) to the +After ikiwiki renders a change or addition (but not deletion) to the wiki, the referenced function is called, and passed the names of the source files that were rendered. +(This hook used to be called "change", but that was not accurate. +For now, plugins using the old hook name will still work.) + +### changes + + hook(type => "changes", id => "foo", call => \&changes); + +After ikiwiki renders changes to the wiki, the referenced function is +called, and passed the names of the source files that were added, modified, +or deleted. + ### cgi hook(type => "cgi", id => "foo", call => \&cgi); -- 2.44.0