\n");
+
+ struct trackHub *hub = fetchTrackHub(hubInfo);
+ struct hubOutputStructure *hubOut = buildHubSearchOutputStructure(hub, hubSearchResult);
+ if (dyStringIsEmpty(hubOut->descriptionMatch) && (hubOut->genomes == NULL))
+ return; // no detailed search results; hit must have been to hub short label or something
+
+ printf("
\n");
+ printf("
\n");
+ printf("
Search details ...\n
\n");
+ if (isNotEmpty(dyStringContents(hubOut->descriptionMatch)))
+ printf("
\n");
+ }
+}
+
+
+void printHubList(struct slName *hubsToPrint, struct hash *hubLookup, struct hash *searchResultHash)
+/* Print out a list of hubs, possibly along with search hits to those hubs.
+ * hubLookup takes hub URLs to struct hubEntry
+ * searchResultHash takes hub URLs to struct hubSearchText * (list of hits on that hub)
+ */
+{
+int count = 0;
+int udcTimeoutVal = udcCacheTimeout();
+char *udcOldDir = cloneString(udcDefaultDir());
+udcSetDefaultDir("/hive/users/jcasper/hubCrawl/");
+udcSetCacheTimeout(1<<30);
+if (hubsToPrint != NULL)
+ {
+ printHubListHeader();
+
+ if (searchResultHash == NULL) // if not displaying search results, join the hub
s into one table
+ printf("
\n");
+ struct slName *thisHubName = NULL;
+ for (thisHubName = hubsToPrint; thisHubName != NULL; thisHubName = thisHubName->next)
+ {
+ struct hubEntry *hubInfo = (struct hubEntry *) hashFindVal(hubLookup, thisHubName->name);
+ if (hubInfo == NULL)
+ {
+ /* This shouldn't happen often, but maybe the search hits list was built from an outdated
+ * search text file that includes hubs for which no info is available.
+ * Skip this hub. */
+ continue;
+ }
+ struct hubSearchText *searchResult = NULL;
+ if (searchResultHash != NULL)
+ {
+ searchResult = (struct hubSearchText *) hashMustFindVal(searchResultHash, thisHubName->name);
+ }
+ printOutputForHub(hubInfo, searchResult, count);
+ count++;
+ }
+ if (searchResultHash == NULL)
+ printf("
\n");
+ }
+udcSetCacheTimeout(udcTimeoutVal);
+udcSetDefaultDir(udcOldDir);
+if (hubsToPrint != NULL)
+ {
+ /* Write out the list of hubs in a single table inside a div that will be hidden by
+ * javascript. This table is used (before being hidden) to set common column widths for
+ * the individual hub tables when they're split by detailed search results. */
+ printf("
\n");
+ }
+
+jsInline(
+ "function lineUpCols()\n"
+ " {\n"
+ " var tableList = $('table.hubList');\n"
+ " if (tableList.length == 0)\n"
+ " return;\n"
+ " var colWidths = new Array();\n"
+ " var combinedTrackTable = $('#hideThisTable');\n"
+ " for (i=0; i \n");
+
+char *hubSearchTableName = cfgOptionDefault("hubSearchTextTable", "hubSearchText");
+int searchEnabled = sqlTableExists(conn, hubSearchTableName);
+if (searchEnabled)
+ printSearchBox(hubSearchTerms, dbFilter);
+
+struct hash *searchResultHash = NULL;
+struct slName *hubsToPrint = NULL;
+if (searchEnabled && !isEmpty(hubSearchTerms))
+ {
+ printSearchTerms(hubSearchTerms);
+ if (isNotEmpty(cleanSearchTerms))
+ tolowers(cleanSearchTerms);
+ // Forcing checkDescriptions to TRUE right now, but we might want to add this as a
+ // checkbox option for users in the near future.
+ bool checkDescriptions = TRUE;
+ struct hubSearchText *hubSearchResults = getHubSearchResults(conn, hubSearchTableName,
+ cleanSearchTerms, checkDescriptions, lcDbFilter, hubLookup);
+ searchResultHash = newHash(5);
+ struct hubSearchText *hst = hubSearchResults;
+ while (hst != NULL)
+ {
+ struct hubSearchText *nextHst = hst->next;
+ hst->next = NULL;
+ struct hashEl *hubHashEnt = hashLookup(searchResultHash, hst->hubUrl);
+ if (hubHashEnt == NULL)
+ {
+ slNameAddHead(&hubsToPrint, hst->hubUrl);
+ hashAdd(searchResultHash, hst->hubUrl, hst);
+ }
+ else
+ slAddTail(&(hubHashEnt->val), hst);
+ hst = nextHst;
+ }
+ }
+else
+ {
+ // There is no active search, so just add all hubs to the list
+ struct hashEl *hel;
+ struct hashEl *helList;
+ helList = hashElListHash(hubLookup);
+ for (hel = helList; hel != NULL; hel = hel->next)
+ {
+ if (isNotEmpty(lcDbFilter))
+ {
+ struct hubEntry *hubEnt = (struct hubEntry *) hel->val;
+ char *lcDbList = cloneString(hubEnt->dbList);
+ if (isNotEmpty(lcDbList))
+ tolowers(lcDbList);
+ if ((lcDbList == NULL) || (stringIn(lcDbFilter, lcDbList) == NULL))
+ continue;
+ }
+ slNameAddHead(&hubsToPrint, hel->name);
+ }
+ }
+slReverse(&hubsToPrint);
+
+printHubList(hubsToPrint, hubLookup, searchResultHash);
printf("");
-*pHash = publicHash;
-return gotAnyRows;
+return (hubsToPrint != NULL);
}
struct hash *hgHubConnectPublic()
/* Put up the list of public hubs and other controls for the page. */
{
struct hash *retHash = NULL;
struct sqlConnection *conn = hConnectCentral();
char *publicTable = cfgOptionEnvDefault("HGDB_HUB_PUBLIC_TABLE",
hubPublicTableConfVariable, defaultHubPublicTableName);
char *statusTable = cfgOptionEnvDefault("HGDB_HUB_STATUS_TABLE",
hubStatusTableConfVariable, defaultHubStatusTableName);
if (!(sqlTableExists(conn, publicTable) &&
outputPublicTable(conn, publicTable,statusTable, &retHash)) )
{
printf("
\n");
printf("No Public Track Hubs found that match search criteria. ");
printf("
");
}
hDisconnectCentral(&conn);
return retHash;
}
+
static void tryHubOpen(unsigned id)
/* try to open hub, leaks trackHub structure */
{
/* try opening this again to reset error */
struct sqlConnection *conn = hConnectCentral();
struct errCatch *errCatch = errCatchNew();
struct hubConnectStatus *hub = NULL;
if (errCatchStart(errCatch))
hub = hubConnectStatusForId(conn, id);
errCatchEnd(errCatch);
if (errCatch->gotError)
hubUpdateStatus( errCatch->message->string, NULL);
else
hubUpdateStatus(NULL, hub);
errCatchFree(&errCatch);
@@ -556,31 +1089,31 @@
hPrintf("You will be automatically redirected to the gateway page for this hub's default database "
"(%s) in %d seconds.
",
cartSidUrlString(cart),trackHubSkipHubName(database),redirDelay);
struct trackHub *tHub = hub->trackHub;
if (tHub->email != NULL)
{
hPrintf("This hub is provided courtesy of %s. Please contact them with any questions.", tHub->email, tHub->email);
}
hPrintf("
Track data hubs are collections of external tracks that can be imported into the UCSC Genome Browser. "
"Hub tracks show up under the hub's own blue label bar on the main browser page, "
"as well as on the configure page. For more information, see the "
""
"User's Guide."
"To import a public hub click its \"Connect\" button below.
"
"
NOTE: Because Track Hubs are created and maintained by external sources,"
" UCSC is not responsible for their content.
"
);
printf("
\n");
@@ -724,56 +1261,107 @@
puts("");
// this is the form for the reset hub button
printf("");
// this is the form for the search hub button
printf("");
+// this is the form for the search hub button
+printf("");
+
// ... and now the main form
printf("");
printf("
\n");
+
+jsInline(
+"var hubSearchTree = (function() {\n"
+" // Effectively global vars set by init\n"
+" var treeDiv; // Points to div we live in\n"
+"\n"
+" function hubSearchTreeContextMenuHandler (node, callback) {\n"
+" var nodeType = node.li_attr.nodetype;\n"
+" if (nodeType == 'track') {\n"
+" callback({\n"
+" 'openConfig': {\n"
+" 'label' : 'Configure this track',\n"
+" 'action' : function () {window.open(node.li_attr.configlink, '_blank'); }\n"
+" }\n"
+" });\n"
+" }\n"
+" else if (nodeType == 'assembly') {\n"
+" callback({\n"
+" 'openConfig': {\n"
+" 'label' : 'Open this assembly',\n"
+" 'action' : function () {window.open(node.li_attr.assemblylink, '_blank'); }\n"
+" }\n"
+" });\n"
+" }\n"
+" }"
+" function init() {\n"
+" $.jstree.defaults.core.themes.icons = false;\n"
+" $.jstree.defaults.core.themes.dots = true;\n"
+" $.jstree.defaults.contextmenu.show_at_node = false;\n"
+" $.jstree.defaults.contextmenu.items = hubSearchTreeContextMenuHandler\n"
+" treeDiv=$('.hubTdbTree');\n"
+" treeDiv.jstree({\n"
+" 'conditionalselect' : function (node, event) { return false; },\n"
+" 'plugins' : ['conditionalselect', 'contextmenu']\n"
+" });\n"
+" }\n\n"
+" return { init: init};\n\n"
+"}());\n"
+"\n"
+"$(function () {\n"
+" hubSearchTree.init();\n"
+"});\n"
+);
+
cartWebEnd();
}
char *excludeVars[] = {"Submit", "submit", "hc_one_url",
hgHubCheckUrl, hgHubDoClear, hgHubDoDisconnect,hgHubDoRedirect, hgHubDataText,
hgHubConnectRemakeTrackHub, NULL};
int main(int argc, char *argv[])
/* Process command line. */
{
long enteredMainTime = clock1000();
oldVars = hashNew(10);
cgiSpoof(&argc, argv);
cartEmptyShell(doMiddle, hUserCookie(), excludeVars, oldVars);
cgiExitTime("hgHubConnect", enteredMainTime);