* Add a postscan hook.
* search: Use postscan hook, avoid updating index when previewing.
sub import { #{{{
hook(type => "checkconfig", id => "search", call => \&checkconfig);
hook(type => "pagetemplate", id => "search", call => \&pagetemplate);
- hook(type => "sanitize", id => "search", call => \&index);
+ hook(type => "postscan", id => "search", call => \&index);
hook(type => "delete", id => "search", call => \&delete);
hook(type => "cgi", id => "search", call => \&cgi);
} # }}}
my $stemmer;
sub index (@) { #{{{
my %params=@_;
-
- return $params{content} if $IkiWiki::preprocessing{$params{destpage}};
setupfiles();
$doc->add_term($pageterm);
$db->replace_document_by_term($pageterm, $doc);
-
- return $params{content};
} #}}}
sub delete (@) { #{{{
hook(type => "scan", id => "skeleton", call => \&scan);
hook(type => "htmlize", id => "skeleton", call => \&htmlize);
hook(type => "sanitize", id => "skeleton", call => \&sanitize);
+ hook(type => "postscan", id => "skeleton", call => \&postscan);
hook(type => "format", id => "skeleton", call => \&format);
hook(type => "pagetemplate", id => "skeleton", call => \&pagetemplate);
hook(type => "templatefile", id => "skeleton", call => \&templatefile);
return $params{content};
} # }}}
+sub postscan (@) { #{{{
+ my %params=@_;
+
+ debug("skeleton plugin running as postscan");
+} # }}}
+
sub format (@) { #{{{
my %params=@_;
});
$content=$template->output;
+
+ run_hooks(postscan => sub {
+ shift->(page => $page, content => $content);
+ });
run_hooks(format => sub {
$content=shift->(
* smileys: Some fixes for escaped smileys.
* smileys: Note that smileys need to be double-escaped for the escaping to
work. Markdown removes one level of escaping.
+ * Add a postscan hook.
+ * search: Use postscan hook, avoid updating index when previewing.
[ Simon McVittie ]
* meta, inline: Support guid options, to allow forcing a particular url or
Making the indexing only happen on a real commit might also speed the
Preview up a small amount.
--Chapman Flack
+
+[[tag done]]
The function is passed named parameters: "page", "destpage", and "content",
and should return the sanitized content.
+### postscan
+
+ hook(type => "postscan", id => "foo", call => \&postscan);
+
+This hook is called once the full page body is available (but before the
+format hook). The most common use is to update search indexes. Added in
+ikiwiki 2.54.
+
+The function is passed named parameters "page" and "content". Its return
+value is ignored.
+
### format
hook(type => "format", id => "foo", call => \&format);