09f396b33776cf8466273dfd05ce3d386febb799 braney Thu Jun 5 08:25:27 2014 -0700 some hgHubConnect clean ups diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 5cc6245..952a3b1 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -215,33 +215,33 @@ safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, hub->id); if (cartUsualBoolean(cart, hubName, FALSE)) printf("\n", hub->id); ourCellEnd(); } else { // give people a chance to clear the error ourCellStart(); printf( "\n" + "class=\"hubButton\" type=\"button\" value=\"Check Hub\">\n" , hub->hubUrl); ourCellEnd(); } if (hub->trackHub != NULL) { ourPrintCellLink(hub->trackHub->shortLabel, hub->hubUrl); } else ourPrintCell(""); if (!isEmpty(hub->errorMessage)) printf("ERROR: %s " "Debug\n", hub->errorMessage); else if (hub->trackHub != NULL) @@ -290,114 +290,113 @@ char *trixWords[trixWordCount]; trixWordCount = chopString(hubSearchTerms, " ", trixWords, trixWordCount); struct trixSearchResult *tsList = trixSearch(trix, trixWordCount, trixWords, TRUE); for ( ; tsList != NULL; tsList = tsList->next) hashStore(urlSearchHash, tsList->itemId); return urlSearchHash; } static struct hash *outputPublicTable(struct sqlConnection *conn, char *publicTable, char *statusTable) /* Put up the list of public hubs and other controls for the page. */ { char *trixFile = cfgOptionEnvDefault("HUBSEARCHTRIXFILE", "hubSearchTrixFile", "/gbdb/hubs/public.ix"); char *hubSearchTerms = cartOptionalString(cart, hgHubSearchTerms); +char *cleanSearchTerms = cloneString(hubSearchTerms); boolean haveTrixFile = fileExists(trixFile); struct hash *urlSearchHash = NULL; printf("
\n"); -if (haveTrixFile && !isEmpty(hubSearchTerms)) +// if we have a trix file, draw the search box +if (haveTrixFile) { - strLower(hubSearchTerms); - urlSearchHash = getUrlSearchHash(trixFile, hubSearchTerms); + puts("Enter search terms to find in public track hub description pages:
" + " \n" + "\n"); + puts("

\n"); } // if we have search terms, put out the line telling the user so -if (!isEmpty(hubSearchTerms)) +if (haveTrixFile && !isEmpty(hubSearchTerms)) { - printf("
List restricted by search terms : %s\n", hubSearchTerms); + printf("List restricted by search terms : %s\n", hubSearchTerms); puts("\n"); - printf("
\n"); - } + puts("

\n"); -// if we have a trix file, draw the search box -if (haveTrixFile) - { - puts(" \n" - "\n"); + strLower(cleanSearchTerms); + urlSearchHash = getUrlSearchHash(trixFile, cleanSearchTerms); } +puts("Pressing Connect button will take you to the gateway page with the default assembly for that hub selected.
"); // make sure all the public hubs are in the hubStatus table. addPublicHubsToHubStatus(conn, publicTable, statusTable); -struct hash *publicHash = NULL; +struct hash *publicHash = newHash(5); char query[512]; bool hasDescription = sqlColumnExists(conn, publicTable, "descriptionUrl"); if (hasDescription) sqlSafef(query, sizeof(query), "select p.hubUrl,p.shortLabel,p.longLabel,p.dbList,s.errorMessage,s.id,p.descriptionUrl from %s p,%s s where p.hubUrl = s.hubUrl", publicTable, statusTable); else sqlSafef(query, sizeof(query), "select p.hubUrl,p.shortLabel,p.longLabel,p.dbList,s.errorMessage,s.id from %s p,%s s where p.hubUrl = s.hubUrl", publicTable, statusTable); struct sqlResult *sr = sqlGetResult(conn, query); char **row; int count = 0; boolean gotAnyRows = FALSE; while ((row = sqlNextRow(sr)) != NULL) { ++count; char *url = row[0], *shortLabel = row[1], *longLabel = row[2], *dbList = row[3], *errorMessage = row[4], *descriptionUrl = row[6]; int id = atoi(row[5]); + hashStore(publicHash, url); if ((urlSearchHash != NULL) && (hashLookup(urlSearchHash, url) == NULL)) continue; struct slName *dbListNames = slNameListFromComma(dbList); if (gotAnyRows) webPrintLinkTableNewRow(); else { /* output header */ printf(" " " " " " " " " " " " "\n"); // start first row printf(""); gotAnyRows = TRUE; - - // allocate the hash to store hubUrl's - publicHash = newHash(5); } if ((id != 0) && isEmpty(errorMessage)) { ourCellStart(); char hubName[32]; safef(hubName, sizeof(hubName), "%s%u", hgHubConnectHubVarPrefix, id); if (cartUsualBoolean(cart, hubName, FALSE)) printf("\n", id); else { @@ -406,67 +405,65 @@ // if the name isn't currently loaded, we assume it's a hub if (!hDbExists(name)) { char buffer[512]; safef(buffer, sizeof buffer, "hub_%d_%s", id, name); name = cloneString(buffer); } printf("\n", url,name); + "class=\"hubButton\" type=\"button\" value=\"Connect\">\n", url,name); } ourCellEnd(); } else if (!isEmpty(errorMessage)) { // give user a chance to clear the error ourCellStart(); printf( "" + "class=\"hubButton\" type=\"button\" value=\"Check Hub\">" , url); ourCellEnd(); } else errAbort("cannot get id for hub with url %s\n", url); ourPrintCellLink(shortLabel, url); if (isEmpty(errorMessage)) { if (hasDescription && !isEmpty(descriptionUrl)) ourPrintCellLink(longLabel, descriptionUrl); else ourPrintCell(longLabel); } else printf("", errorMessage); printGenomeList(dbListNames, count); - - hashStore(publicHash, url); } sqlFreeResult(&sr); if (gotAnyRows) printf("
DisplayHub NameDescriptionAssemblies
ERROR: %s " "Debug
\n"); printf("
"); return publicHash; } struct hash *hgHubConnectPublic() /* Put up the list of public hubs and other controls for the page. */ { struct hash *retHash = NULL; @@ -497,34 +494,35 @@ if (errCatchStart(errCatch)) hub = hubConnectStatusForId(conn, id); errCatchEnd(errCatch); if (errCatch->gotError) hubUpdateStatus( errCatch->message->string, NULL); else hubUpdateStatus(NULL, hub); errCatchFree(&errCatch); hDisconnectCentral(&conn); } static void doResetHub(struct cart *theCart) { -char *url = cartOptionalString(cart, hgHubDataText); +char *url = cartOptionalString(cart, hgHubCheckUrl); if (url != NULL) { + udcSetCacheTimeout(1); unsigned id = hubResetError(url); tryHubOpen(id); } else errAbort("must specify url in %s\n", hgHubDataText); } static void doClearHub(struct cart *theCart) { char *url = cartOptionalString(cart, hgHubDataText); printf("
clearing hub %s\n",url);
 if (url != NULL)
     hubClearStatus(url);
 else
@@ -555,31 +553,31 @@
     }
 }
 
 void doMiddle(struct cart *theCart)
 /* Write header and body of html page. */
 {
 cart = theCart;
 
 if (cartVarExists(cart, hgHubDoClear))
     {
     doClearHub(cart);
     cartWebEnd();
     return;
     }
 
-if (cartVarExists(cart, hgHubDoReset))
+if (cartVarExists(cart, hgHubCheckUrl))
     {
     doResetHub(cart);
     }
 
 cartWebStart(cart, NULL, "%s", pageTitle);
 jsIncludeFile("jquery.js", NULL);
 jsIncludeFile("utils.js", NULL);
 jsIncludeFile("jquery-ui.js", NULL);
 
 webIncludeResourceFile("jquery-ui.css");
 
 jsIncludeFile("ajax.js", NULL);
 jsIncludeFile("hgHubConnect.js", NULL);
 jsIncludeFile("jquery.cookie.js", NULL);
 
@@ -624,33 +622,31 @@
 cgiMakeHiddenVar("hubUrl", "");
 cgiMakeHiddenVar("db", "");
 cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on");
 puts("");
 
 // this is the form for the disconnect hub button
 printf("
\n", "../cgi-bin/hgGateway"); cgiMakeHiddenVar("db", "hg19"); cgiMakeHiddenVar("hubId", ""); cgiMakeHiddenVar(hgHubDoDisconnect, "on"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); puts("
"); // this is the form for the reset hub button printf("
\n", "../cgi-bin/hgHubConnect"); -cgiMakeHiddenVar("hubUrl", ""); -cgiMakeHiddenVar(hgHubDoReset, "on"); -cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); +cgiMakeHiddenVar(hgHubCheckUrl, ""); puts("
"); // this is the form for the search hub button printf("
\n", "../cgi-bin/hgHubConnect"); cgiMakeHiddenVar(hgHubSearchTerms, ""); cgiMakeHiddenVar(hgHubDoSearch, "on"); puts("
"); // ... and now the main form printf("
\n", "../cgi-bin/hgGateway"); cartSaveSession(cart); // we have two tabs for the public and unlisted hubs printf("
" "
  • Public Hubs
  • " @@ -665,30 +661,30 @@ char *emailAddress = cfgOptionDefault("hub.emailAddress","genome@soe.ucsc.edu"); printf("" "Contact %s to add a public hub." "\n", emailAddress,emailAddress); printf("
"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); printf("\n"); puts("
"); cartWebEnd(); } char *excludeVars[] = {"Submit", "submit", "hc_one_url", - hgHubDoReset, hgHubDoClear, hgHubDoDisconnect, hgHubDataText, + hgHubCheckUrl, hgHubDoClear, hgHubDoDisconnect, hgHubDataText, hgHubConnectRemakeTrackHub, NULL}; int main(int argc, char *argv[]) /* Process command line. */ { long enteredMainTime = clock1000(); oldVars = hashNew(10); setUdcCacheDir(); cgiSpoof(&argc, argv); cartEmptyShell(doMiddle, hUserCookie(), excludeVars, oldVars); cgiExitTime("hgHubConnect", enteredMainTime); return 0; }