c7211155cab4ec213239cf6979ee4b63a1d96374 max Tue Aug 11 03:07:18 2015 -0700 adding email display during redirect, GET urls, adding onlyDbs/notDbs tags to support hg38, refs #15113. diff --git src/hg/hgTracks/extTools.c src/hg/hgTracks/extTools.c index 50ec9cf..00f512f 100644 --- src/hg/hgTracks/extTools.c +++ src/hg/hgTracks/extTools.c @@ -8,38 +8,43 @@ * See README in this or parent directory for licensing information. */ #include "common.h" #include "dystring.h" #include "hCommon.h" #include "htmshell.h" #include "hash.h" #include "web.h" #include "ra.h" #include "hgTracks.h" #include "extTools.h" #include "hgFind.h" #include "obscure.h" #include "net.h" -static char *getRequiredRaSetting(struct hash *hash, char *name, struct lineFile *lf) -/* Grab a group setting out of the ra hash. errAbort if not found. */ +static char *cloneRaSetting(struct hash *hash, char *name, struct lineFile *lf, bool mustExist) +/* clone a setting out of the ra hash. errAbort if mustExit and not found, otherwise NULL. */ { char *str; if ((str = hashFindVal(hash, name)) == NULL) + { + if (mustExist) errAbort("missing required setting '%s' on line %d in file %s\n", name, lf->lineIx, lf->fileName); -return str; + else + return NULL; + } +return cloneString(str); } struct extTool *readExtToolRa(char *raFileName) /* parse the extTools.ra file. Inspired by trackHub.c:readGroupRa() */ { struct lineFile *lf = udcWrapShortLineFile(raFileName, NULL, 1*1024*1024); struct extTool *list = NULL; //struct hash *ra; struct slPair *raList; while ((raList = raNextStanzAsPairs(lf)) != NULL) { struct extTool *et; AllocVar(et); struct slPair *paramList = NULL; @@ -59,42 +64,53 @@ // hacky way to allow spaces in parameter names and values char *name = replaceChars(paramArr[0], "%20", " "); char *val; if (fCount==2) val = cloneString(paramArr[1]); else val = cloneString(""); val = replaceChars(val, "%20", " "); slPairAdd(¶mList, name, val); } else // add all other name/val pairs to the hash hashAdd(raHash, raPair->name, cloneString(raPair->val)); } - // pull out the normal fields from the hash - et->tool = cloneString(getRequiredRaSetting(raHash, "tool", lf)); - et->shortLabel = cloneString(getRequiredRaSetting(raHash, "shortLabel", lf)); + // pull out the required fields from the hash + et->tool = cloneRaSetting(raHash, "tool", lf, TRUE); + et->shortLabel = cloneRaSetting(raHash, "shortLabel", lf, TRUE); + et->longLabel = cloneRaSetting(raHash, "longLabel", lf, TRUE); + et->url = cloneRaSetting(raHash, "url", lf, TRUE); + et->dbs = NULL; + + // optional fields + et->email = cloneRaSetting(raHash, "email", lf, FALSE); + if (hashFindVal(raHash, "onlyDbs")) + et->dbs = commaSepToSlNames(hashFindVal(raHash, "onlyDbs")); + if (hashFindVal(raHash, "notDbs")) + et->notDbs = commaSepToSlNames(hashFindVal(raHash, "notDbs")); + + char *isHttpGet = hashFindVal(raHash, "isHttpGet"); + if (isHttpGet && \ + (sameString(isHttpGet, "yes") || sameString(isHttpGet, "on") || sameString(isHttpGet, "true"))) + et->isHttpGet = TRUE; + char *maxSize = hashFindVal(raHash, "maxSize"); if (maxSize!=NULL) et->maxSize = sqlUnsignedOrError(maxSize, "Error: maxSize %s for tool %s is not a number", \ maxSize, et->tool); - et->longLabel = cloneString(getRequiredRaSetting(raHash, "longLabel", lf)); - et->url = cloneString(getRequiredRaSetting(raHash, "url", lf)); - et->dbs = NULL; - if (hashFindVal(raHash, "dbs")) - et->dbs = commaSepToSlNames(hashFindVal(raHash, "dbs")); slReverse(¶mList); et->params = paramList; slAddHead(&list, et); freeHashAndVals(&raHash); slPairFree(&raList); } if (list) slReverse(&list); lineFileClose(&lf); return list; } @@ -105,104 +121,118 @@ struct extTool *extTools = readExtToolRa("extTools.ra"); struct extTool *et; for (et = extTools; et != NULL; et = et->next) if (sameWord(et->tool, tool)) break; if (et==NULL) errAbort("No configuration found for tool %s", tool); // construct an invisible CGI form with the given parameters printf("
\n"); if (debug) printf("Target URL: %s", et->url); -printf("
\n"); // a little javascript that clicks the submit button if (!debug) printf("\n"); printf("\n"); }