Monday, November 08, 2010 at 12:04 AM.

system.verbs.builtins.mainResponder.search.server.htmlSearch

on htmlSearch (adrPageTable, fname, flShowSiteNames=true, altColor="#F5F5DC", feedback=true, indexName=nil, adrFilterCallback=nil) {
	<<Create a search request, call the search script, and return the results.
		<<The searchRequest table should contain:
			<<origSearchString
			<<start
			<<maxHitsPerPage
			<<adrMemberInfo
				<<May be null.
				<<Otherwise, the membership info address for this user.
			<<sitesList
				<<The list of sites to search.
	<<Changes
		<<8/11/02; 2:14:52 AM by JES
			<<New optional parameter, adrFilterCallback, which is the address of a search result filter callback. Passed to mainResponder.search.server.doSearch.
	local (searchRequest, argTable);
	
	new (tableType, @searchRequest);
	new (tableType, @argTable);
	
	<<Parse the search args into a table.
	webserver.parseArgs (adrPageTable^.searchArgs, @argTable);
	
	<<Populate the searchRequest table.
	bundle { //get the search string
		searchRequest.searchString = argTable.q};
	
	bundle { //get the start parameter
		try { //start
			searchRequest.start = string.urlDecode (argTable.s);
			searchRequest.start = number (searchRequest.start)}
		else {
			searchRequest.start = 1}};
	
	bundle { //get max hits per page parameter
		try { //max hits per page
			searchRequest.maxHitsPerPage = string.urlDecode (argTable.m);
			searchRequest.maxHitsPerPage = number (searchRequest.maxHitsPerPage)}
		else {
			searchRequest.maxHitsPerPage = 25}};
	
	searchRequest.fname = fname;
	
	searchRequest.flShowSiteNames = flShowSiteNames;
	searchRequest.altColor = altColor;
	searchRequest.feedback = feedback;
	
	bundle { //get the site
		if defined (argTable.site) {
			searchRequest.site = argTable.site}};
	
	bundle { //get the adrMemberInfo parameter
		searchRequest.adrMemberInfo = nil;
		try {
			searchRequest.adrMemberInfo = adrPageTable^.adrMemberInfo}};
	
	<<Add info to the page table.
	adrPageTable^.searchString = searchRequest.searchString;
	
	if indexName != nil {
		searchRequest.indexName = indexName}
	else {
		searchRequest.indexName = "Index.root"};
	
	local (s = mainResponder.search.server.doSearch (@searchRequest, adrFilterCallback));
	
	return (s)}
<<bundle //test code
	<<htmlSearch (@temp.p, "google")



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.