+sub filter (@) { #{{{
+ my %params=@_;
+
+ if ($params{page} eq $params{destpage} && $toindex{$params{page}}) {
+ # index page
+ my $db=xapiandb();
+ my $doc=Search::Xapian::Document->new();
+ my $title=$params{page};
+ if (exists $pagestate{$params{page}}{meta} &&
+ exists $pagestate{$params{page}}{meta}{title}) {
+ $title=$pagestate{$params{page}}{meta}{title};
+ }
+
+ # data used by omega
+ $doc->set_data(
+ "url=".urlto($params{page}, "")."\n".
+ "sample=\n". # TODO
+ "caption=$title\n".
+ "modtime=$IkiWiki::pagemtime{$params{page}}\n".
+ "size=".length($params{content})."\n"
+ );
+
+ my $tg = Search::Xapian::TermGenerator->new();
+ $tg->set_stemmer(new Search::Xapian::Stem("english"));
+ $tg->set_document($doc);
+ $tg->index_text($params{page}, 2);
+ $tg->index_text($title, 2);
+ $tg->index_text($params{content}); # TODO html strip; preprocessor too
+
+ my $pageterm=pageterm($params{page});
+ $doc->add_term($pageterm);
+ $db->replace_document_by_term($pageterm, $doc);
+ }
+
+ return $params{content};
+} #}}}
+
+sub delete (@) { #{{{
+ my $db=xapiandb();
+ foreach my $page (@_) {
+ $db->delete_document_by_term(pageterm($page));
+ }