8fca283c4625a81c19eb71e87582e831771f03f6 chmalee Tue Mar 28 15:49:39 2023 -0700 Make single position search coming from hgGateway go directly to hgTracks before drawing any html, refs Max email diff --git src/hg/hgSearch/hgSearch.c src/hg/hgSearch/hgSearch.c index ec7655c..6996ed1 100644 --- src/hg/hgSearch/hgSearch.c +++ src/hg/hgSearch/hgSearch.c @@ -603,69 +603,66 @@ doMainPage(); return; } initGenbankTableNames(db); hashTracksAndGroups(cart, db); struct searchCategory *allCategories = getAllCategories(cart, db, hgFindGroupHash); struct jsonElement *categsJsonElement = jsonElementFromSearchCategory(allCategories, db); struct cartJson *cj = cartJsonNew(cart); // since we are coming directly from hgTracks/hgGateway (or a URL manipulation), // if the search would normally be a singlePos, like a chromosome name or HGVS search, // we can just go directly there. But if we aren't a singlePos, we need to show // the results page boolean doRedirect = TRUE; measureTiming = cartUsualBoolean(cart, "measureTiming", FALSE); -(void)doQuery(cj->jw, db, allCategories, doRedirect, userSearch, measureTiming); -/* This is an option to do an automatic redirect but I'm commenting it - * out for now, as this page suggests the refresh option is not helpful - * for visually impaired users: - * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta - * For now the client javascript can handle the redirect +struct hgPositions *hgp = doQuery(cj->jw, db, allCategories, doRedirect, userSearch, measureTiming); +// Since we are coming from another CGI or a URL manip, go directly to hgTracks +// if we resolve to a single position if (hgp && hgp->singlePos) { char newPosBuf[128]; safef(newPosBuf, sizeof(newPosBuf), "%s:%d-%d", hgp->singlePos->chrom, hgp->singlePos->chromStart+1, hgp->singlePos->chromEnd); cartSetString(cj->cart, "position", newPosBuf); if (hgp->singlePos->highlight) cartSetString(cj->cart, "addHighlight", hgp->singlePos->highlight); puts("Content-type:text/html\n"); puts("\n\n"); - hPrintf("\n", db, newPosBuf); + printf("\n", db, newPosBuf); puts("\n"); } else -*/ + { dyStringPrintf(cj->jw->dy, ", \"db\": '%s'", db); dyStringPrintf(cj->jw->dy, ", \"categs\": "); jsonDyStringPrint(cj->jw->dy, categsJsonElement, NULL,-1); dyStringPrintf(cj->jw->dy, ", \"trackGroups\": "); jsonDyStringPrint(cj->jw->dy, makeTrackGroupsJson(db), NULL, -1); dyStringPrintf(cj->jw->dy, ", \"genomes\": "); jsonDyStringPrint(cj->jw->dy, getGenomes(), NULL, -1); // Now we need to actually spit out the page + json webStartGbNoBanner(cart, db, "Search Disambiguation"); printMainPageIncludes(); jsInlineF("var hgsid='%s';\n", cartSessionId(cart)); jsInline("var cartJson = {"); jsInline(cj->jw->dy->string); jsInline("};\n"); jsInline("hgSearch.init();\n"); webEndGb(); } +} /* End do commands */ void doMiddle(struct cart *theCart) /* Set up globals and make web page */ { cart = theCart; if (cgiOptionalString(CARTJSON_COMMAND)) doCartJson(); else if (cgiOptionalString("search")) // we got here from: // 1. changing the URL arguments // 2. a back button reload // regardless, we can just put up the whole page with search results already // included in the returned json