0dab88f8198e8e8d35bbb65673186ad8df1a7f64 max Thu Nov 7 06:49:40 2024 -0800 adding API key section to hgHubConnect, for the "hubtools up" command, refs #34405 diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 2f7c769..d8c7b6c 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -18,31 +18,31 @@ #include "cart.h" #include "dbDb.h" #include "web.h" #include "trackHub.h" #include "hubConnect.h" #include "dystring.h" #include "hPrint.h" #include "jsHelper.h" #include "obscure.h" #include "hgConfig.h" #include "trix.h" #include "net.h" #include "hubSearchText.h" #include "pipeline.h" #include "hubPublic.h" - +#include "wikiLink.h" static boolean measureTiming; struct cart *cart; /* The user's ui state. */ struct hash *oldVars = NULL; static char *pageTitle = "Track Data Hubs"; char *database = NULL; char *organism = NULL; struct hubOutputStructure { struct hubOutputStructure *next; struct dyString *metaTags; struct dyString *descriptionMatch; @@ -403,30 +403,53 @@ jsInlineF("%s", line); pipelineClose(&pl); // the 'false' below prevents a few hub-search specific jstree configuration options jsInline("hubSearchTree.init(false);"); } errCatchEnd(errCatch); if (errCatch->gotError || errCatch->gotWarning) { printf("hubCheck timed out after running for %d minute%s. Please try on a Unix command line", hubCheckTimeout / 60, hubCheckTimeout/60 > 1 ? "s" : ""); ret = 1; } errCatchFree(&errCatch); return ret; } +void printApiKeySection() +{ +puts("
"); +puts("

Hubtools API key

"); +char *userName = wikiLinkUserName(); +char *userId = wikiLinkUserId(); +if (userName==NULL || userId==NULL) + { + char *hgsid = cartSessionId(cart); + char *loginUrl = wikiLinkUserLoginUrlReturning(hgsid, wikiLinkEncodeReturnUrl(hgsid, "hgHubConnect", "#dev")); + printf("
You are not logged in. Please Login now, then this page will show the API key.
", loginUrl); + } +else + { + puts("
To use the hubtools up command, create a file ~/.hubtools.conf and add this line:
"); + puts("
"); + printf("apiKey='%s@%s'", userName, userId); + puts("
"); + } + +puts("
"); // tabSection apiKey +} + void hgHubConnectDeveloperMode() /* Put up the controls for the "Hub Development" Tab, which includes a button to run the * hubCheck utility on a hub and load a hub with the udcTimeout and measureTiming * variables turned on */ { // put out the top of our page char *hubUrl = cartOptionalString(cart, "validateHubUrl"); // the outer div for all the elements in the tab puts("
"); char *hubUrlVal = ""; if (hubUrl != NULL) hubUrlVal = catThreeStrings(" value='", hubUrl, "'"); @@ -495,33 +518,38 @@ { timeLabel = "Hide timings"; timeVal = ""; timeDesc = "Shows loading time in milliseconds for each track, to help debug performance problems."; timeStatus = "ON"; } printf("Show load times: %s  ", timeStatus); printf("", timeVal, timeLabel); printf("
Current setting: %s
\n", timeDesc); puts(""); puts("
"); // margin-left puts(""); // tabSection -puts(""); // #hubDeveloper jsOnEventById("click", "hubValidateButton", "makeIframe(event)"); + +// API Key section +if (cfgOptionBooleanDefault("showHubApiKey", FALSE)) // This should probably not be shown on mirrors, so default to FALSE + printApiKeySection(); +puts(""); // hub developement tab + } void printSearchAndFilterBoxes(int searchEnabled, char *hubSearchTerms, char *dbFilter) /* Create the text boxes for search and database filtering along with the required * javscript */ { printf("
\n", "../cgi-bin/hgHubConnect"); if (searchEnabled) { cgiMakeHiddenVar(hgHubDoSearch, "on"); cgiMakeHiddenVar(hgHubDbFilter, ""); cartSaveSession(cart); printf("The list below can be filtered on words in the hub description pages or by assemblies.
" "Search terms: "