Small search changes. Add description field. Also extend dataset format to support an "alsomatch" field. Review: me

This commit is contained in:
rjc%netscape.com 1999-12-22 10:37:21 +00:00
Родитель be113294ea
Коммит 722be8baa1
5 изменённых файлов: 56 добавлений и 0 удалений

Просмотреть файл

@ -229,6 +229,7 @@ private:
static nsIRDFResource *kNC_Child;
static nsIRDFResource *kNC_Data;
static nsIRDFResource *kNC_Name;
static nsIRDFResource *kNC_Description;
static nsIRDFResource *kNC_URL;
static nsIRDFResource *kRDF_InstanceOf;
static nsIRDFResource *kRDF_type;
@ -305,6 +306,7 @@ nsIRDFResource *InternetSearchDataSource::kNC_Ref;
nsIRDFResource *InternetSearchDataSource::kNC_Child;
nsIRDFResource *InternetSearchDataSource::kNC_Data;
nsIRDFResource *InternetSearchDataSource::kNC_Name;
nsIRDFResource *InternetSearchDataSource::kNC_Description;
nsIRDFResource *InternetSearchDataSource::kNC_URL;
nsIRDFResource *InternetSearchDataSource::kRDF_InstanceOf;
nsIRDFResource *InternetSearchDataSource::kRDF_type;
@ -346,6 +348,7 @@ InternetSearchDataSource::InternetSearchDataSource(void)
gRDFService->GetResource(NC_NAMESPACE_URI "child", &kNC_Child);
gRDFService->GetResource(NC_NAMESPACE_URI "data", &kNC_Data);
gRDFService->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name);
gRDFService->GetResource(NC_NAMESPACE_URI "Description", &kNC_Description);
gRDFService->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL);
gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_InstanceOf);
gRDFService->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type);
@ -375,6 +378,7 @@ InternetSearchDataSource::~InternetSearchDataSource (void)
NS_IF_RELEASE(kNC_Child);
NS_IF_RELEASE(kNC_Data);
NS_IF_RELEASE(kNC_Name);
NS_IF_RELEASE(kNC_Description);
NS_IF_RELEASE(kNC_URL);
NS_IF_RELEASE(kRDF_InstanceOf);
NS_IF_RELEASE(kRDF_type);
@ -1147,7 +1151,14 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url)
nsAutoString action;
if (NS_FAILED(rv = GetData(data, "search", "action", action))) continue;
if (shortURL.EqualsIgnoreCase(action))
{
foundEngine = PR_TRUE;
break;
}
// extension for engines which can have multiple "actions"
if (NS_FAILED(rv = GetData(data, "browser", "alsomatch", action))) continue;
if (shortURL.EqualsIgnoreCase(action))
{
foundEngine = PR_TRUE;
@ -1906,6 +1917,18 @@ InternetSearchDataSource::GetSearchEngineList(nsFileSpec nativeDir, PRBool check
mInner->Assert(searchRes, kNC_Name, nameLiteral, PR_TRUE);
}
}
// save description of search engine (if specified)
nsAutoString descValue;
if (NS_SUCCEEDED(rv = GetData(data, "search", "description", descValue)))
{
nsCOMPtr<nsIRDFLiteral> descLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(descValue.GetUnicode(),
getter_AddRefs(descLiteral))))
{
mInner->Assert(searchRes, kNC_Description, descLiteral, PR_TRUE);
}
}
// save icon url (if we have one)
if (iconURL.Length() > 0)

Просмотреть файл

@ -18,3 +18,7 @@
bannerEnd="<!--/AD_TAG-->"
>
</search>
<browser
alsomatch="http://search.netscape.com/search.tmpl"
>

Просмотреть файл

@ -50,6 +50,7 @@
<tree align="horizontal" id="searchengines" border="1" style="height: 90%;" flex="100%" datasources="rdf:internetsearch" ref="NC:SearchEngineRoot">
<treecol id="CheckboxColumn" />
<treecol id="NameColumn" rdf:resource="http://home.netscape.com/NC-rdf#Name" sortActive="true" sortDirection="ascending" />
<treecol id="DescColumn" rdf:resource="http://home.netscape.com/NC-rdf#Description" rdf:resource2="http://home.netscape.com/NC-rdf#Name" />
<template>
<treechildren>
@ -61,6 +62,9 @@
<treecell>
<titledbutton class="iconic" src="rdf:http://home.netscape.com/NC-rdf#Icon" value="rdf:http://home.netscape.com/NC-rdf#Name" align="left" />
</treecell>
<treecell>
<titledbutton value="rdf:http://home.netscape.com/NC-rdf#Description" align="left" />
</treecell>
</treerow>
</treeitem>
</treechildren>
@ -70,6 +74,7 @@
<treerow>
<treecell value="&checkbox.column.label;"/>
<treecell observes="NameColumn" value="&engine.column.label;" resource="http://home.netscape.com/NC-rdf#Name" onclick="return doSort('NameColumn');" sortActive="true" sortDirection="ascending"/>
<treecell observes="DescColumn" value="&description.column.label;" resource="http://home.netscape.com/NC-rdf#Description" resource2="http://home.netscape.com/NC-rdf#Name" onclick="return doSort('DescColumn');" />
</treerow>
</treehead>
</tree>

Просмотреть файл

@ -26,6 +26,7 @@
<!ENTITY checkbox.column.label "On">
<!ENTITY engine.column.label "Search Engines">
<!ENTITY description.column.label "Description">
<!ENTITY search.button.label "Search">
<!ENTITY stop.button.label "Stop">

Просмотреть файл

@ -229,6 +229,7 @@ private:
static nsIRDFResource *kNC_Child;
static nsIRDFResource *kNC_Data;
static nsIRDFResource *kNC_Name;
static nsIRDFResource *kNC_Description;
static nsIRDFResource *kNC_URL;
static nsIRDFResource *kRDF_InstanceOf;
static nsIRDFResource *kRDF_type;
@ -305,6 +306,7 @@ nsIRDFResource *InternetSearchDataSource::kNC_Ref;
nsIRDFResource *InternetSearchDataSource::kNC_Child;
nsIRDFResource *InternetSearchDataSource::kNC_Data;
nsIRDFResource *InternetSearchDataSource::kNC_Name;
nsIRDFResource *InternetSearchDataSource::kNC_Description;
nsIRDFResource *InternetSearchDataSource::kNC_URL;
nsIRDFResource *InternetSearchDataSource::kRDF_InstanceOf;
nsIRDFResource *InternetSearchDataSource::kRDF_type;
@ -346,6 +348,7 @@ InternetSearchDataSource::InternetSearchDataSource(void)
gRDFService->GetResource(NC_NAMESPACE_URI "child", &kNC_Child);
gRDFService->GetResource(NC_NAMESPACE_URI "data", &kNC_Data);
gRDFService->GetResource(NC_NAMESPACE_URI "Name", &kNC_Name);
gRDFService->GetResource(NC_NAMESPACE_URI "Description", &kNC_Description);
gRDFService->GetResource(NC_NAMESPACE_URI "URL", &kNC_URL);
gRDFService->GetResource(RDF_NAMESPACE_URI "instanceOf", &kRDF_InstanceOf);
gRDFService->GetResource(RDF_NAMESPACE_URI "type", &kRDF_type);
@ -375,6 +378,7 @@ InternetSearchDataSource::~InternetSearchDataSource (void)
NS_IF_RELEASE(kNC_Child);
NS_IF_RELEASE(kNC_Data);
NS_IF_RELEASE(kNC_Name);
NS_IF_RELEASE(kNC_Description);
NS_IF_RELEASE(kNC_URL);
NS_IF_RELEASE(kRDF_InstanceOf);
NS_IF_RELEASE(kRDF_type);
@ -1147,7 +1151,14 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url)
nsAutoString action;
if (NS_FAILED(rv = GetData(data, "search", "action", action))) continue;
if (shortURL.EqualsIgnoreCase(action))
{
foundEngine = PR_TRUE;
break;
}
// extension for engines which can have multiple "actions"
if (NS_FAILED(rv = GetData(data, "browser", "alsomatch", action))) continue;
if (shortURL.EqualsIgnoreCase(action))
{
foundEngine = PR_TRUE;
@ -1906,6 +1917,18 @@ InternetSearchDataSource::GetSearchEngineList(nsFileSpec nativeDir, PRBool check
mInner->Assert(searchRes, kNC_Name, nameLiteral, PR_TRUE);
}
}
// save description of search engine (if specified)
nsAutoString descValue;
if (NS_SUCCEEDED(rv = GetData(data, "search", "description", descValue)))
{
nsCOMPtr<nsIRDFLiteral> descLiteral;
if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(descValue.GetUnicode(),
getter_AddRefs(descLiteral))))
{
mInner->Assert(searchRes, kNC_Description, descLiteral, PR_TRUE);
}
}
// save icon url (if we have one)
if (iconURL.Length() > 0)