Add a postscan hook.
authorJoey Hess <joey@kodama.kitenet.net>
Thu, 17 Jul 2008 19:16:56 +0000 (15:16 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Thu, 17 Jul 2008 20:17:15 +0000 (16:17 -0400)
* Add a postscan hook.
* search: Use postscan hook, avoid updating index when previewing.

IkiWiki/Plugin/search.pm
IkiWiki/Plugin/skeleton.pm
IkiWiki/Render.pm
debian/changelog
doc/bugs/search_plugin_and_CGI_preview.mdwn
doc/plugins/write.mdwn

index 284f477fae5b32f63f9c9159f06c4af84dea2acd..822b5974eca016a21043b1bf2aba92a3410ea8bc 100644 (file)
@@ -9,7 +9,7 @@ use IkiWiki 2.00;
 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);
 } # }}}
@@ -48,8 +48,6 @@ my $scrubber;
 my $stemmer;
 sub index (@) { #{{{
        my %params=@_;
-       
-       return $params{content} if $IkiWiki::preprocessing{$params{destpage}};
 
        setupfiles();
 
@@ -132,8 +130,6 @@ sub index (@) { #{{{
 
        $doc->add_term($pageterm);
        $db->replace_document_by_term($pageterm, $doc);
-
-       return $params{content};
 } #}}}
 
 sub delete (@) { #{{{
index 17a2162ffc240728f17ec44f149e79c65597705d..1af8e4e9df3b0903cd1341327f606fd4599afcde 100644 (file)
@@ -18,6 +18,7 @@ sub import { #{{{
        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);
@@ -89,6 +90,12 @@ sub sanitize (@) { #{{{
        return $params{content};
 } # }}}
 
+sub postscan (@) { #{{{
+       my %params=@_;
+       
+       debug("skeleton plugin running as postscan");
+} # }}}
+
 sub format (@) { #{{{
        my %params=@_;
        
index 8a79119cd1173beb6a259ee4a3338e7dbbf6045b..fc1bc0c92649d7dca4a7095b57bc0f2be275ce67 100644 (file)
@@ -117,6 +117,10 @@ sub genpage ($$) { #{{{
        });
        
        $content=$template->output;
+       
+       run_hooks(postscan => sub {
+               shift->(page => $page, content => $content);
+       });
 
        run_hooks(format => sub {
                $content=shift->(
index c3a2632c938d11ab12184f2cacdf934cd4f84829..ff907655ec3fc6d7df61bc4894fc3f22e5c7a10e 100644 (file)
@@ -26,6 +26,8 @@ ikiwiki (2.54) UNRELEASED; urgency=low
   * 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
index 71577cd7cd5cb0eff8596b480f4a244ada4e7fc3..eb602cd9d9fd343c0525be5c0e278072be4f3650 100644 (file)
@@ -15,3 +15,5 @@ the problem, of course.
 Making the indexing only happen on a real commit might also speed the
 Preview up a small amount.
 --Chapman Flack
+
+[[tag done]]
index 4dc55e30219667428cff64d57931683cb88ebd71..b4acb237dd8a1f5612e34c136cd95823a152bcde 100644 (file)
@@ -216,6 +216,17 @@ modify the body of a page after it has been fully converted to html.
 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);