aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2010-07-30 16:05:07 +0200
committerintrigeri <intrigeri@boum.org>2010-07-30 16:14:23 +0200
commit25447bccae0439ea56da7a788482a4807c7c459d (patch)
tree21d63415d77cc97890a493b035a083970fb09b84
parent1fe87a0808ee4d19d97956d48447644c69334f8a (diff)
downloadikiwiki-25447bccae0439ea56da7a788482a4807c7c459d.tar
ikiwiki-25447bccae0439ea56da7a788482a4807c7c459d.tar.gz
Added a rescan hook.
This is needed for the po plugin vs. e.g. meta titles. In order to get rid of the ugly "rebuilding all pages to fix meta titles" thing, Joey suggested to make "po, at scan time, re-run the scan hooks, passing them modified content (either converted from po to mdwn or with the escaped stuff cheaply de-escaped)". This would unfortunately not work, as the meta plugin gathers its data using the preprocess hook in scan mode: it would overwrite with buggy data the correct data we would have forced it to gather in po's scan hook. We then need a hook that runs *after* the preprocess hook has been run in scan mode, but *before* any page rendering is started. Hence this one.
-rw-r--r--IkiWiki/Plugin/skeleton.pm.example7
-rw-r--r--IkiWiki/Render.pm8
-rw-r--r--doc/plugins/write.mdwn11
3 files changed, 26 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example
index a57a2c8fe..708d92830 100644
--- a/IkiWiki/Plugin/skeleton.pm.example
+++ b/IkiWiki/Plugin/skeleton.pm.example
@@ -18,6 +18,7 @@ sub import {
hook(type => "filter", id => "skeleton", call => \&filter);
hook(type => "linkify", id => "skeleton", call => \&linkify);
hook(type => "scan", id => "skeleton", call => \&scan);
+ hook(type => "rescan", id => "skeleton", call => \&rescan);
hook(type => "htmlize", id => "skeleton", call => \&htmlize);
hook(type => "sanitize", id => "skeleton", call => \&sanitize);
hook(type => "indexhtml", id => "skeleton", call => \&indexhtml);
@@ -104,6 +105,12 @@ sub scan (@) {
debug("skeleton plugin running as scan");
}
+sub rescan (@) {
+ my %params=@_;
+
+ debug("skeleton plugin running as rescan");
+}
+
sub htmlize (@) {
my %params=@_;
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index a653ab2da..5ce802317 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -183,6 +183,14 @@ sub scan ($) {
# Preprocess in scan-only mode.
preprocess($page, $page, $content, 1);
+
+ run_hooks(rescan => sub {
+ shift->(
+ page => $page,
+ content => $content,
+ );
+ });
+
}
else {
will_render($file, $file, 1);
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index 10b4df835..335320394 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -194,6 +194,17 @@ them to `%links`. Present in IkiWiki 2.40 and later.
The function is passed named parameters "page" and "content". Its return
value is ignored.
+### rescan
+
+ hook(type => "rescan", id => "foo", call => \&scan);
+
+This hook is called after the scan hook has been run, as well as the
+preprocess hook in scan mode. It is used to collect additional
+metadata that depends on a first scan to have been performed already.
+
+The function is passed named parameters "page" and "content". Its return
+value is ignored.
+
### filter
hook(type => "filter", id => "foo", call => \&filter);