DEV-41358: Added support for search categories.

You can now specify a search category for all web-based searches,
e.g., "all" (default), "people", "places", "events", "groups", "wiki",
"destinations", "classifieds". Specifying a category will add the
relevant subdir to the search URL, as specified by the search team.
master
Martin Reddy 2009-10-20 14:07:50 +00:00
parent 2180706f4c
commit eb620735fc
7 changed files with 52 additions and 15 deletions

View File

@ -198,7 +198,7 @@ bool LLEventNotification::handleResponse(const LLSD& notification, const LLSD& r
break;
}
case 1:
LLFloaterReg::showInstance("search", LLSD().insert("panel", "event").insert("id", S32(getEventID())));
LLFloaterReg::showInstance("search", LLSD().insert("category", "events").insert("id", S32(getEventID())));
break;
case 2:
break;

View File

@ -40,6 +40,17 @@ LLFloaterSearch::LLFloaterSearch(const LLSD& key) :
LLFloater(key),
mBrowser(NULL)
{
// declare a map that transforms a category name into
// the URL suffix that is used to search that category
mCategoryPaths = LLSD::emptyMap();
mCategoryPaths["all"] = "search";
mCategoryPaths["people"] = "search/people";
mCategoryPaths["places"] = "search/places";
mCategoryPaths["events"] = "search/events";
mCategoryPaths["groups"] = "search/groups";
mCategoryPaths["wiki"] = "search/wiki";
mCategoryPaths["destinations"] = "destinations";
mCategoryPaths["classifieds"] = "classifieds";
}
BOOL LLFloaterSearch::postBuild()
@ -79,13 +90,33 @@ void LLFloaterSearch::handleMediaEvent(LLPluginClassMedia *self, EMediaEvent eve
void LLFloaterSearch::search(const LLSD &key)
{
if (mBrowser)
if (! mBrowser)
{
std::string query = getString("search_url");
if (key.has("id"))
{
query += std::string("?q=") + key["id"].asString();
}
mBrowser->navigateTo(query);
return;
}
// get the URL for the search page
std::string url = getString("search_url");
if (! LLStringUtil::endsWith(url, "/"))
{
url += "/";
}
// work out the subdir to use based on the requested category
std::string category = key.has("category") ? key["category"].asString() : "";
if (mCategoryPaths.has(category))
{
url += mCategoryPaths[category].asString();
}
else
{
url += mCategoryPaths["all"].asString();
}
// append the search query string
std::string search_text = key.has("id") ? key["id"].asString() : "";
url += std::string("?q=") + search_text;
// and load the URL in the web view
mBrowser->navigateTo(url);
}

View File

@ -56,9 +56,14 @@ public:
LLFloaterSearch(const LLSD& key);
/// show the search floater with a new search
/// see search() for details on the key parameter.
/*virtual*/ void onOpen(const LLSD& key);
/// perform a search with the specific search term
/// perform a search with the specific search term.
/// The key should be a map that can contain the following keys:
/// - "id": specifies the text phrase to search for
/// - "category": one of "all" (default), "people", "places",
/// "events", "groups", "wiki", "destinations", "classifieds"
void search(const LLSD &key);
private:
@ -68,6 +73,7 @@ private:
/*virtual*/ void handleMediaEvent(LLPluginClassMedia *self, EMediaEvent event);
LLMediaCtrl *mBrowser;
LLSD mCategoryPaths;
};
#endif // LL_LLFLOATERSEARCH_H

View File

@ -112,7 +112,7 @@ LLGroupHandler gGroupHandler;
// static
void LLGroupActions::search()
{
LLFloaterReg::showInstance("search", LLSD().insert("panel", "group"));
LLFloaterReg::showInstance("search", LLSD().insert("category", "groups"));
}
// static

View File

@ -535,7 +535,7 @@ void LLNavigationBar::handleLoginComplete()
void LLNavigationBar::invokeSearch(std::string search_text)
{
LLFloaterReg::showInstance("search", LLSD().insert("panel", "all").insert("id", LLSD(search_text)));
LLFloaterReg::showInstance("search", LLSD().insert("category", "all").insert("id", LLSD(search_text)));
}
void LLNavigationBar::clearHistoryCache()

View File

@ -1897,20 +1897,20 @@ BOOL LLWorldMapView::handleDoubleClick( S32 x, S32 y, MASK mask )
id.toString(uuid_str);
uuid_str = uuid_str.substr(28);
sscanf(uuid_str.c_str(), "%X", &event_id);
LLFloaterReg::showInstance("search", LLSD().insert("panel", "event").insert("id", event_id));
LLFloaterReg::showInstance("search", LLSD().insert("category", "events").insert("id", event_id));
break;
}
case MAP_ITEM_LAND_FOR_SALE:
case MAP_ITEM_LAND_FOR_SALE_ADULT:
{
LLFloaterReg::hideInstance("world_map");
LLFloaterReg::showInstance("search", LLSD().insert("panel", "land").insert("id", id));
LLFloaterReg::showInstance("search", LLSD().insert("category", "destinations").insert("id", id));
break;
}
case MAP_ITEM_CLASSIFIED:
{
LLFloaterReg::hideInstance("world_map");
LLFloaterReg::showInstance("search", LLSD().insert("panel", "classified").insert("id", id));
LLFloaterReg::showInstance("search", LLSD().insert("category", "classifieds").insert("id", id));
break;
}
default:

View File

@ -13,7 +13,7 @@
width="620">
<floater.string
name="search_url">
http://eniac21.lindenlab.com:10001/viewer/search/
http://eniac21.lindenlab.com:10001/viewer
</floater.string>
<floater.string
name="loading_text">