Fix bug # 28062: now able to again save a search query in bookmarks. Also fix bug # 31208: get full list of categories back. Finally, also fix up some of the search datasets to not use silly redirect urls.

This commit is contained in:
rjc%netscape.com 2000-03-20 01:16:19 +00:00
parent 975a57065b
commit fb09b64bd1
16 changed files with 210 additions and 108 deletions

View File

@ -5,7 +5,7 @@
name="AOL.COM"
description="AOL.COM Search"
method="GET"
action="http://info.netscape.com/fwd/sidb1aol/http://search.aol.com/dirsearch.adp"
action="http://search.aol.com/dirsearch.adp"
routeType = internet
>
@ -20,4 +20,4 @@
resultItemEnd="</I>"
>
</SEARCH>
</SEARCH>

View File

@ -5,7 +5,7 @@
name="CompuServe"
description="Search the Web"
method="GET"
action="http://info.netscape.com/fwd/sidb1csi/http://cissearch.compuserve.com/search/cssearch/cssearch-results.adp"
action="http://cissearch.compuserve.com/search/cssearch/cssearch-results.adp"
>
<INPUT NAME="Type" VALUE="I">

View File

@ -5,7 +5,7 @@
NAME="ICQ"
DESCRIPTION= "ICQ Web Search"
METHOD="GET"
ACTION="http://info.netscape.com/fwd/sidb1icq/http://search.icq.com/dirsearch.adp"
ACTION="http://search.icq.com/dirsearch.adp"
>
<INPUT NAME="query" user>
@ -13,11 +13,11 @@
<INPUT NAME="users" VALUE="1">
<INTERPRET
bannerStart="<td rowspan="2" valign="bottom" width="133">"
bannerStart='<td rowspan="2" valign="bottom" width="133">'
bannerEnd="</a></td>"
resultListStart="ICQ.com Search results"
resultListEnd="<!-- /// Results -->"
resultItemStart="<font face="arial" size="-1">"
resultItemStart='<font face="arial" size="-1">'
resultListEnd="</a></font><br>"
>

View File

@ -1,5 +1,5 @@
# Sherlock Plugin for Netscape Open Directory
# Copyright (c) 1999 Netscape Communications Corp.
# Copyright (c) 2000 Netscape Communications Corp.
# Author - Myron Rosmarin
#
@ -7,7 +7,7 @@
name = "Jobs"
description = "Jobs"
method = "GET"
action = "http://info.netscape.com/fwd/sidb1/http://jobsearch.netscape.monster.com/jobsearch.asp"
action = "http://jobsearch.netscape.monster.com/jobsearch.asp"
>
<INPUT NAME="fn" VALUE="">
@ -22,4 +22,4 @@
resultItemStart = "<TR>"
>
</search>
</search>

View File

@ -15,5 +15,3 @@ ICQ.gif
ICQ.src
NetscapeSearch.gif
NetscapeSearch.src
NetscapeSearchMain.gif
NetscapeSearchMain.src

View File

@ -44,8 +44,6 @@ FILES = \
ICQ.src \
NetscapeSearch.gif \
NetscapeSearch.src \
NetscapeSearchMain.gif \
NetscapeSearchMain.src \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -1,5 +1,5 @@
# Sherlock Plugin for Netscape Open Directory
# Copyright (c) 1999 Netscape Communications Corp.
# Copyright (c) 2000 Netscape Communications Corp.
# Author - Myron Rosmarin
#
@ -7,7 +7,7 @@
name = "Music - Artist"
description = "Music - Artist"
method = "GET"
action = "http://info.netscape.com/fwd/sidb1/http://rollingstone.netscape.com/artist/list.btq"
action = "http://rollingstone.netscape.com/artist/list.btq"
>
<INPUT NAME="s" user>

View File

@ -2,10 +2,10 @@
# Copyright (C)2000 Netscape Communications Corp.
<SEARCH
name=".Netscape"
name="Netscape"
description = "Netscape Search"
method="GET"
action="http://info.netscape.com/fwd/sidb1dnet/http://search.netscape.com/cgi-bin/search"
action="http://search.netscape.com/cgi-bin/search"
>
<INPUT NAME="search" user>

View File

@ -1,5 +1,5 @@
# Sherlock Plugin for Netscape Open Directory
# Copyright (c) 1999 Netscape Communications Corp.
# Copyright (c) 2000 Netscape Communications Corp.
# Author - Myron Rosmarin
#
@ -7,7 +7,7 @@
name = "Shareware"
description = "Shareware - Netscape"
method = "GET"
action = "http://info.netscape.com/fwd/sidb1/http://sharewaresearch.netscape.com/cgi-bin/search.cgi"
action = "http://sharewaresearch.netscape.com/cgi-bin/search.cgi"
>
<INPUT NAME="keywords" user>

View File

@ -1,5 +1,5 @@
# Sherlock Plugin for Netscape Open Directory
# Copyright (c) 1999 Netscape Communications Corp.
# Copyright (c) 2000 Netscape Communications Corp.
# Author - Myron Rosmarin
#
@ -7,7 +7,7 @@
name = "Tech News"
description = "Tech News"
method = "GET"
action = "http://info.netscape.com/fwd/sidb1/http://technews.netscape.com/news/search/results/1,10199,0-1002,00.html"
action = "http://technews.netscape.com/news/search/results/1,10199,0-1002,00.html"
>
<INPUT NAME="qt" user>

View File

@ -31,10 +31,6 @@
<RDF:Seq about="NC:SearchCategoryRoot">
<RDF:li>
<RDF:Description about="urn:search:category:1">
<NC:title>Internet</NC:title>
</RDF:Description>
<RDF:Description about="urn:search:category:2">
<NC:title>Jobs</NC:title>
</RDF:Description>
@ -51,6 +47,9 @@
<NC:title>Tech News</NC:title>
</RDF:Description>
<RDF:Description about="urn:search:category:1">
<NC:title>Web</NC:title>
</RDF:Description>
</RDF:li>
</RDF:Seq>
@ -100,7 +99,7 @@
</RDF:Description>
<RDF:Description about="NC:SearchCategory?engine=urn:search:engine:4">
<NC:Name>.Netscape</NC:Name>
<NC:Name>Netscape</NC:Name>
</RDF:Description>
<RDF:Description about="NC:SearchCategory?engine=urn:search:engine:5">

View File

@ -41,8 +41,6 @@ FILES=\
ICQ.src \
NetscapeSearch.gif \
NetscapeSearch.src \
NetscapeSearchMain.gif \
NetscapeSearchMain.src \
$(NULL)
install:: $(FILES:/=\)

View File

@ -29,3 +29,4 @@
<!ENTITY engine.column.label "Search Engines">
<!ENTITY checkbox.column.label "Use">
<!ENTITY stop.button.label "Stop">
<!ENTITY savesearch.button.label "Bookmark Search Query">

View File

@ -23,8 +23,7 @@
var rootNode = null;
var textArc = null;
var RDF_observer = new Object;
var bunremoveAttributedle = null;
var pref = null;
var pref = null;
// get the click count pref
try {
@ -94,6 +93,10 @@ function SearchPanelStartup()
var categoryList = document.getElementById("categoryList");
if (categoryList)
{
var optionItem = document.createElement("html:option");
optionItem.setAttribute("value", "NC:SearchEngineRoot");
categoryList.appendChild(optionItem);
var internetSearch = Components.classes["component://netscape/rdf/datasource?name=internetsearch"].getService();
if (internetSearch) internetSearch = internetSearch.QueryInterface(Components.interfaces.nsIInternetSearchService);
if (internetSearch)
@ -107,8 +110,6 @@ function SearchPanelStartup()
if (ref) categoryList.setAttribute("ref", ref);
}
}
}
try {
@ -314,7 +315,11 @@ function loadEngines( aCategory )
function SearchPanelShutdown()
{
var tree = document.getElementById("Tree");
if (tree)
{
tree.database.RemoveObserver(RDF_observer);
}
}
function doStop()
@ -670,8 +675,7 @@ function OpenSearch( tabName, forceDialogFlag, aSearchStr, engineURIs )
}
if ( !defaultSearchURL )
defaultSearchURL = "http://info.netscape.com/fwd/sidb1dnet/http://search.netscape.com/cgi-bin/search?search=";
// defaultSearchURL = "http://search.netscape.com/cgi-bin/search?search=";
defaultSearchURL = "http://search.netscape.com/cgi-bin/search?search=";
if( searchMode == 1 || forceDialogFlag )
{
@ -703,13 +707,21 @@ function OpenSearch( tabName, forceDialogFlag, aSearchStr, engineURIs )
if( !engineURIs || ( engineURIs && engineURIs.length <= 1 ) ) {
// not called from sidebar or only one engine selected
if( engineURIs )
{
searchEngineURI = engineURIs[0];
gURL = "internetsearch:engine=" + searchEngineURI + "&text=" + escapedSearchStr;
}
// look up the correct search URL format for the given engine
var searchURL = searchDS.GetInternetSearchURL( searchEngineURI, escapedSearchStr );
if( searchURL )
{
defaultSearchURL = searchURL;
}
else
{
defaultSearchURL = defaultSearchURL + escapedSearchStr;
gURL = "";
}
// load the results page of selected or default engine in the content area
if( defaultSearchURL )
top.content.location.href = defaultSearchURL;
@ -726,6 +738,9 @@ function OpenSearch( tabName, forceDialogFlag, aSearchStr, engineURIs )
searchURL += "engine=" + engineURIs[i];
}
searchURL += ( "&text=" + escapedSearchStr );
gURL = searchURL;
top.content.location.href = "chrome://search/content/internetresults.xul";
setTimeout("checkSearchProgress('" + searchURL + "')", 1000);
}
@ -741,6 +756,43 @@ function switchTab( aPageIndex )
{
var deck = document.getElementById( "advancedDeck" );
deck.setAttribute( "index", aPageIndex );
// decide whether to show/hide/enable/disable save search query button
if (aPageIndex != 0) return(true);
var saveQueryButton = document.getElementById("saveQueryButton");
if (!saveQueryButton) return(true);
var resultsTree = document.getElementById("Tree");
if( !resultsTree) return(false);
var ds = resultsTree.database;
if (!ds) return(false);
var haveSearchRef = false;
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
if (rdf)
{
var source = rdf.GetResource( "NC:LastSearchRoot", true);
var childProperty;
var target;
// look for last search URI
childProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#ref", true);
target = ds.GetTarget(source, childProperty, true);
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (target) target = target.Value;
if (target && target != "")
{
haveSearchRef = true;
}
}
if (haveSearchRef == true)
saveQueryButton.removeAttribute("style", "visibility: collapse");
else saveQueryButton.setAttribute("style", "visibility: collapse");
return(true);
}
@ -967,3 +1019,62 @@ function doContextCmd(cmdName)
compositeDB.DoCommand( selectionArray, cmdResource, argumentsArray );
return(true);
}
function saveSearch()
{
var resultsTree = document.getElementById("Tree");
if( !resultsTree) return(false);
var ds = resultsTree.database;
if (!ds) return(false);
var lastSearchURI="";
var lastSearchText="";
var rdf = Components.classes["component://netscape/rdf/rdf-service"].getService();
if (rdf) rdf = rdf.QueryInterface(Components.interfaces.nsIRDFService);
if (rdf)
{
var source = rdf.GetResource( "NC:LastSearchRoot", true);
var childProperty;
var target;
// look for last search URI
childProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#ref", true);
target = ds.GetTarget(source, childProperty, true);
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (target) target = target.Value;
if (target && target != "")
{
lastSearchURI = target;
}
// look for last search text
childProperty = rdf.GetResource("http://home.netscape.com/NC-rdf#LastText", true);
target = ds.GetTarget(source, childProperty, true);
if (target) target = target.QueryInterface(Components.interfaces.nsIRDFLiteral);
if (target) target = target.Value;
if (target && target != "")
{
lastSearchText = unescape(target);
}
}
dump("Bookmark search Name: '" + lastSearchText + "'\n");
dump("Bookmark search URL: '" + lastSearchURI + "'\n");
if ((lastSearchURI == null) || (lastSearchURI == "")) return(false);
if ((lastSearchText == null) || (lastSearchText == "")) return(false);
var bmks = Components.classes["component://netscape/browser/bookmarks-service"].getService();
if (bmks) bmks = bmks.QueryInterface(Components.interfaces.nsIBookmarksService);
var textNode = document.getElementById("sidebar-search-text");
if( !textNode ) return(false);
var searchTitle = "Internet Search: '" + lastSearchText + "'"; // using " + gSites;
if (bmks) bmks.AddBookmark(lastSearchURI, searchTitle);
return(true);
}

View File

@ -46,7 +46,7 @@
<box align="horizontal" class="spaced">
<html:input id="sidebar-search-text" flex="1" onkeyup="if (event.which == 13) { return doSearch(); }" />
<titledbutton id="searchbutton" value="&search.button.label;" onclick="return doSearch();" class="dialog toolbar-non-iconic"/>
<titledbutton id="stopbutton" value="&stop.button.label;" onclick="return doStop();" class="dialog toolbar-non-iconic" style="display:none;"/>
<titledbutton id="stopbutton" align="left" src="resource:/res/rdf/loading.gif" value="&stop.button.label;" onclick="return doStop();" class="dialog toolbar-non-iconic" style="display:none;"/>
</box>
<box align="horizontal" class="spaced">
<html:label for="">&within.label;</html:label>
@ -61,7 +61,6 @@
</rule>
</template>
<html:select id="categoryList" template="categoryTemplate" ref="NC:SearchCategoryRoot" datasources="rdf:null"
sortResource="http://home.netscape.com/NC-rdf#title" sortDirection="ascending"
onmousedown="return switchTab(1);"
onchange="return chooseCategory(this)" >
<html:option value="NC:SearchEngineRoot" >&allengines.label;</html:option>
@ -122,6 +121,13 @@
<treecol rdf:resource="http://home.netscape.com/NC-rdf#PageRank" rdf:resource2="http://home.netscape.com/NC-rdf#Name" />
</tree>
<box align="horizontal">
<spring flex="1" />
<titledbutton id="saveQueryButton" value="&savesearch.button.label;" onclick="return saveSearch();" class="dialog toolbar-non-iconic"/>
<spring flex="1" />
</box>
</box>
<!-- advanced panel -->

View File

@ -1840,6 +1840,8 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url, PRBool *sea
nsAutoString data;
nsCOMPtr<nsIRDFResource> engine;
nsCOMPtr<nsISimpleEnumerator> arcs;
nsAutoString engineURI;
if (NS_SUCCEEDED(rv = mInner->GetTargets(kNC_SearchEngineRoot, kNC_Child,
PR_TRUE, getter_AddRefs(arcs))))
{
@ -1855,6 +1857,13 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url, PRBool *sea
engine = do_QueryInterface(arc);
if (!engine) continue;
const char *uri = nsnull;
engine->GetValueConst(&uri);
if (uri)
{
engineURI = uri;
}
if (NS_FAILED(rv = FindData(engine, data))) continue;
if (data.Length() < 1) continue;
@ -1908,9 +1917,25 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url, PRBool *sea
}
if (searchText.Length() < 1) return(NS_RDF_NO_VALUE);
// forget about any previous search results
ClearResults();
// remember the text of the last search
RememberLastSearchText(searchText.GetUnicode());
// construct the search query uri
engineURI.Insert("internetsearch:engine=", 0);
engineURI += "&text=";
engineURI += searchText;
// remember the last search query
const PRUnichar *uriUni = engineURI.GetUnicode();
nsCOMPtr<nsIRDFLiteral> uriLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(uriUni, getter_AddRefs(uriLiteral))))
{
rv = mInner->Assert(kNC_LastSearchRoot, kNC_Ref, uriLiteral, PR_TRUE);
}
#ifdef DEBUG_SEARCH_OUTPUT
char *engineMatch = searchText.ToNewCString();
if (engineMatch)
@ -1921,9 +1946,6 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url, PRBool *sea
}
#endif
// forget about any previous search results
ClearResults();
// do the search
DoSearch(nsnull, engine, searchURL, nsAutoString(""));
@ -1938,28 +1960,41 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url, PRBool *sea
NS_IMETHODIMP
InternetSearchDataSource::ClearResults(void)
{
if (mInner)
if (!mInner) return(NS_ERROR_UNEXPECTED);
// forget any nodes under the last search root
nsresult rv;
nsCOMPtr<nsISimpleEnumerator> arcs;
if (NS_SUCCEEDED(rv = mInner->GetTargets(kNC_LastSearchRoot, kNC_Child, PR_TRUE, getter_AddRefs(arcs))))
{
nsresult rv;
nsCOMPtr<nsISimpleEnumerator> arcs;
if (NS_SUCCEEDED(rv = mInner->GetTargets(kNC_LastSearchRoot, kNC_Child, PR_TRUE, getter_AddRefs(arcs))))
PRBool hasMore = PR_TRUE;
while (hasMore == PR_TRUE)
{
PRBool hasMore = PR_TRUE;
while (hasMore == PR_TRUE)
if (NS_FAILED(arcs->HasMoreElements(&hasMore)) || (hasMore == PR_FALSE))
break;
nsCOMPtr<nsISupports> arc;
if (NS_FAILED(arcs->GetNext(getter_AddRefs(arc))))
break;
nsCOMPtr<nsIRDFResource> child = do_QueryInterface(arc);
if (child)
{
if (NS_FAILED(arcs->HasMoreElements(&hasMore)) || (hasMore == PR_FALSE))
break;
nsCOMPtr<nsISupports> arc;
if (NS_FAILED(arcs->GetNext(getter_AddRefs(arc))))
break;
nsCOMPtr<nsIRDFResource> child = do_QueryInterface(arc);
if (child)
{
mInner->Unassert(kNC_LastSearchRoot, kNC_Child, child);
}
mInner->Unassert(kNC_LastSearchRoot, kNC_Child, child);
}
}
}
// forget the last search query
nsCOMPtr<nsIRDFNode> lastTarget;
if (NS_SUCCEEDED(rv = mInner->GetTarget(kNC_LastSearchRoot, kNC_Ref,
PR_TRUE, getter_AddRefs(lastTarget))) && (rv != NS_RDF_NO_VALUE))
{
nsCOMPtr<nsIRDFLiteral> lastLiteral = do_QueryInterface(lastTarget);
if (lastLiteral)
{
rv = mInner->Unassert(kNC_LastSearchRoot, kNC_Ref, lastLiteral);
}
}
return(NS_OK);
}
@ -2090,64 +2125,20 @@ InternetSearchDataSource::BeginSearchRequest(nsIRDFResource *source, PRBool doNe
if (uri.Find("internetsearch:") != 0)
return(NS_ERROR_FAILURE);
// remember the last search query
nsCOMPtr<nsIRDFDataSource> localstore;
rv = gRDFService->GetDataSource("rdf:local-store", getter_AddRefs(localstore));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIRDFNode> lastTarget;
if (NS_SUCCEEDED(rv = localstore->GetTarget(kNC_LastSearchRoot, kNC_Ref,
PR_TRUE, getter_AddRefs(lastTarget))))
{
if (rv != NS_RDF_NO_VALUE)
{
#ifdef DEBUG_SEARCH_OUTPUT
nsCOMPtr<nsIRDFLiteral> lastLit = do_QueryInterface(lastTarget);
if (lastLit)
{
const PRUnichar *lastUni = nsnull;
lastLit->GetValueConst(&lastUni);
nsAutoString lastStr(lastUni);
char *lastC = lastStr.ToNewCString();
if (lastC)
{
printf("\nLast Search: '%s'\n", lastC);
nsCRT::free(lastC);
lastC = nsnull;
}
}
#endif
rv = localstore->Unassert(kNC_LastSearchRoot, kNC_Ref, lastTarget);
}
}
if (uri.Length() > 0)
{
const PRUnichar *uriUni = uri.GetUnicode();
nsCOMPtr<nsIRDFLiteral> uriLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(uriUni, getter_AddRefs(uriLiteral))))
{
rv = localstore->Assert(kNC_LastSearchRoot, kNC_Ref, uriLiteral, PR_TRUE);
}
}
// XXX Currently, need to flush localstore as its being leaked
// and thus never written out to disk otherwise
// gotta love the name "remoteLocalStore"
nsCOMPtr<nsIRDFRemoteDataSource> remoteLocalStore = do_QueryInterface(localstore);
if (remoteLocalStore)
{
remoteLocalStore->Flush();
}
}
// forget about any previous search results
ClearResults();
// forget about any previous search sites
ClearResultSearchSites();
// remember the last search query
const PRUnichar *uriUni = uri.GetUnicode();
nsCOMPtr<nsIRDFLiteral> uriLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(uriUni, getter_AddRefs(uriLiteral))))
{
rv = mInner->Assert(kNC_LastSearchRoot, kNC_Ref, uriLiteral, PR_TRUE);
}
uri.Cut(0, strlen("internetsearch:"));
nsVoidArray *engineArray = new nsVoidArray;