Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.searchEngine.init
on init (adrUserTable=@user.searchEngine) {
<<Set up a table of preferences.
<<When you want to set up additional preferences tables,
<<call this script with one parameter, the address of a prefs table.
local (adrPrefs, adrStrings, adrDefaults);
if not defined (adrUserTable^) {
new (tableType, adrUserTable)};
if not defined (user.searchEngine.indexesFolder) {
local (f);
f = frontier.getProgramPath ();
f = file.folderFromPath (f);
f = f + "Search Engine" + file.getPathChar ();
if not file.exists (f) {
file.newFolder (f)};
user.searchEngine.indexesFolder = f};
bundle { //set up prefs
adrPrefs = @adrUserTable^.prefs;
if not defined (adrPrefs^) {
new (tableType, adrPrefs)};
if not defined (adrPrefs^.hitsPerPageList) {
adrPrefs^.hitsPerPageList = {10, 25, 50, 100}};
if not defined (adrPrefs^.formOnResultsPage) {
adrPrefs^.formOnResultsPage = true};
if not defined (adrPrefs^.booleanPopup) {
adrPrefs^.booleanPopup = true};
if not defined (adrPrefs^.matchesPopup) {
adrPrefs^.matchesPopup = true};
if not defined (adrPrefs^.cacheResults) {
adrPrefs^.cacheResults = true};
if not defined (adrPrefs^.stopWords) {
adrPrefs^.stopWords = @searchEngine.data.stopWords};
if not defined (adrPrefs^.logSearches) {
adrPrefs^.logSearches = true}};
bundle { //set up defaults
adrDefaults = @adrPrefs^.defaults;
if not defined (adrDefaults^) {
new (tableType, adrDefaults)};
if not defined (adrDefaults^.hitsPerPage) {
adrDefaults^.hitsPerPage = 10};
if not defined (adrDefaults^.searchType) {
adrDefaults^.searchType = "and"}};
bundle { //set up strings
adrStrings = @adrPrefs^.strings;
if not defined (adrStrings^) {
new (tableType, adrStrings)};
if not defined (adrStrings^.searchingFor) {
adrStrings^.searchingFor = "Searching for: <b><<searchstring>></b>"};
if not defined (adrStrings^.nothingFound) {
adrStrings^.nothingFound = "Nothing found."};
if not defined (adrStrings^.matchesFound) {
adrStrings^.matchesFound = "<<start>> to <<end>> of <<totalHits>> total matches found."};
if not defined (adrStrings^.oneMatchFound) {
adrStrings^.oneMatchFound = "1 match found."};
if not defined (adrStrings^.moreMatches) {
adrStrings^.moreMatches = "More matches..."};
if not defined (adrStrings^.searchTips) {
local (s = "");
wp.newTextObject (s, @adrStrings^.searchTips)}};
bundle { //register new People Suite service
people.newService ("SearchEngineDeveloper")};
return (true)};
init ()
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.