e77dcca9b1bffc335f2843c8cfce67119b3d039d braney Wed Nov 30 16:25:50 2011 -0800 allow specifying different names for the hubPublic and hubStatus tables (#6162) diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 974226f..b67b64f 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -206,37 +206,36 @@ ourCellStart(); printf( "" , hub->id); ourCellEnd(); } printf("\n"); printf(""); } -void hgHubConnectPublic() +static boolean outputPublicTable(struct sqlConnection *conn, char *publicTable) /* Put up the list of public hubs and other controls for the page. */ { -struct sqlConnection *conn = hConnectCentral(); char query[512]; safef(query, sizeof(query), "select hubUrl,shortLabel,longLabel,dbList from %s", - hubPublicTableName); + publicTable); struct sqlResult *sr = sqlGetResult(conn, query); char **row; boolean gotAnyRows = FALSE; while ((row = sqlNextRow(sr)) != NULL) { char *url = row[0], *shortLabel = row[1], *longLabel = row[2], *dbList = row[3]; if (gotAnyRows) webPrintLinkTableNewRow(); else { /* output header */ printf("
\n"); printf(" " @@ -285,39 +284,48 @@ if (isEmpty(errorMessage)) ourPrintCell(longLabel); else printf("", errorMessage); ourPrintCell(removeLastComma(dbList)); ourPrintCell(url); } sqlFreeResult(&sr); if (gotAnyRows) { printf("
ERROR: %s " "Debug
\n"); + printf("
"); } -else +return gotAnyRows; +} + + +void hgHubConnectPublic() +/* Put up the list of public hubs and other controls for the page. */ +{ +struct sqlConnection *conn = hConnectCentral(); +char *publicTable = cfgOptionEnvDefault("HGDB_HUB_PUBLIC_TABLE", + "hubPublicTableName", defaultHubPublicTableName); +if (!(sqlTableExists(conn, publicTable) && outputPublicTable(conn, publicTable) )) { printf("
\n"); printf("No Public Track Hubs for this genome assembly
"); - } - printf("
"); - + } hDisconnectCentral(&conn); } 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);