Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.searchEngine.indexCurrentPage
on indexCurrentPage (adrPageTable, siteName, adrStopWords=nil) {
<<Call this script from your finalFilter.
<<This will keep your site's index up-to-date.
<<Whenever you build a page, the index is updated.
if defined (adrPageTable^.requestHeaders) { //is this a dynamic page?
return (false)}; //only index when writing to disk, not during dynamic generation
local (url, title, pageText);
local (adrIndex, adrPreviews);
local (adrPage = adrPageTable^.adrObject);
local (flDynamic = false);
adrIndex = searchEngine.getIndexAddress (siteName);
adrPreviews = searchEngine.getPreviewsAddress (siteName);
if adrStopWords == nil {
adrStopWords = @searchEngine.data.stopWords};
bundle { //from where do we get the page text?
case typeOf (adrPage^) {
wpTextType;
outlineType;
stringType {
true}}
else {
flDynamic = true}; //use the rendered text rather than the text of the page source
if not (html.getPagePref ("regularIndex", adrPage)) {
flDynamic = true}};
<<Set the indexThisPage directive to false to skip a page.
if not (html.getPref ("indexThisPage", adrPageTable)) {
return (false)}; //don't index this page
bundle { //get the text of the page
if flDynamic {
pageText = adrPageTable^.renderedText}
else {
pageText = string (adrPage^)}};
bundle { //get the url and title of the page
url = adrPageTable^.url;
title = adrPageTable^.title};
msg ("Search Engine: Indexing: " + adrPage);
<<Create a preview for this page.
<<This should always be done before adding a page to the index.
searchEngine.createPreview (pageText, title, url, adrPage, adrPreviews, clock.now ());
<<Add the page to the index.
<<It's okay to call this verb if the page has been indexed before.
searchEngine.indexPage (adrPage, url, title, pageText, adrIndex, adrStopWords);
<<Save the guest database containing the index.
searchEngine.saveIndex (siteName, adrIndex);
return (true)}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.