a4483154d95553e15038edd7703dc2d6eb87437d max Tue Sep 4 03:44:42 2018 -0700 making assembly links clickable in hgHubConnect, refs #22012 diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index 996e864..679c23e 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -135,52 +135,65 @@ static char *removeLastComma(char *string) { if (string != NULL) { int len = strlen(string); if ( string[len - 1] == ',') string[len - 1] = 0; else if (len > 2 && endsWith(string,", ")) string[len - 2] = 0; } return string; } #define GENLISTWIDTH 40 -static void printGenomeList(struct slName *genomes, int row) +static void printGenomeList(char *hubUrl, struct slName *genomes, int row) /* print supported assembly names from sl list */ { /* List of associated genomes. */ struct dyString *dy = newDyString(100); struct dyString *dyShort = newDyString(100); char *trimmedName = NULL; -for(; genomes; genomes = genomes->next) +int charCount = 0; +struct slName *genome = genomes; +for(; genome; genome = genome->next) { - trimmedName = trackHubSkipHubName(genomes->name); + trimmedName = trackHubSkipHubName(genome->name); dyStringPrintf(dy,"%s, ", trimmedName); if (dyShort->stringSize == 0 || (dyShort->stringSize+strlen(trimmedName)<=GENLISTWIDTH)) dyStringPrintf(dyShort,"%s, ", trimmedName); + charCount += strlen(trimmedName); } char *genomesString = removeLastComma( dyStringCannibalize(&dy)); char *genomesShort = removeLastComma( dyStringCannibalize(&dyShort)); char tempHtml[1024+strlen(genomesString)+strlen(genomesShort)]; if (strlen(genomesShort) > GENLISTWIDTH) // If even the first element is too long, truncate it. genomesShort[GENLISTWIDTH] = 0; if (strlen(genomesShort)==strlen(genomesString)) { - safef(tempHtml, sizeof tempHtml, "%s", genomesString); + struct dyString *tempHtmlSrc = newDyString(1000); + genome = genomes; + for(; genome; genome = genome->next) + { + trimmedName = trackHubSkipHubName(genome->name); + dyStringPrintf(tempHtmlSrc,"<a href='hgTracks?hubUrl=%s&genome=%s'>%s</a>" , hubUrl, genome->name, trimmedName); + if (genome->next) + dyStringPrintf(tempHtmlSrc,", "); + + } + safef(tempHtml, sizeof tempHtml, "%s", dyStringCannibalize(&tempHtmlSrc)); } else { char id[256]; safef(tempHtml, sizeof tempHtml, "<span id=Short%d>[+] %s...</span>" "<span id=Full%d style=\"display:none\">[-]<br>%s</span>" , row, genomesShort , row, genomesString); safef(id, sizeof id, "Short%d", row); jsOnEventByIdF("click", id, "document.getElementById('Short%d').style.display='none';" "document.getElementById('Full%d').style.display='inline';" "return false;" @@ -197,31 +210,31 @@ } static void printGenomes(struct trackHub *thub, int row) /* print supported assembly names from trackHub */ { /* List of associated genomes. */ struct trackHubGenome *genomes = thub->genomeList; struct slName *list = NULL, *el; for(; genomes; genomes = genomes->next) { el = slNameNew(genomes->name); slAddHead(&list, el); } slReverse(&list); -printGenomeList(list, row); +printGenomeList(thub->url, list, row); } static void hgHubConnectUnlisted(struct hubConnectStatus *hubList, struct hash *publicHash) /* Put up the list of unlisted hubs and other controls for the page. */ /* uses publicHash to distingusih public hubs from unlisted ones */ /* NOTE: Destroys hubList */ { // put out the top of our page printf("<div id=\"unlistedHubs\" class=\"hubList\"> \n" "<table id=\"unlistedHubsTable\"> \n" "<thead><tr> \n" "<th colspan=\"6\" id=\"addHubBar\"><label for=\"hubUrl\">URL:</label> \n" "<input name=\"hubText\" id=\"hubUrl\" class=\"hubField\" " @@ -638,31 +651,31 @@ ourCellStart(); printf("<span class=\"hubError\">ERROR: %s </span>" "<a href=\"../goldenPath/help/hgTrackHubHelp.html#Debug\">Debug Help</a>", hubInfo->errorMessage); safef(jsId, sizeof jsId, "hubClearButton%d", count); printf( "<input name=\"hubClearButton\" id='%s' " "class=\"hubButton\" type=\"button\" value=\"Retry Hub\">" , jsId); jsOnEventByIdF("click", jsId, "document.resetHubForm.elements['hubCheckUrl'].value='%s';" "document.resetHubForm.submit();return true;", hubInfo->hubUrl); ourCellEnd(); } -printGenomeList(dbListNames, count); +printGenomeList(hubInfo->hubUrl, dbListNames, count); printf("</tr>\n"); } void printSearchOutputForTrack(struct tdbOutputStructure *tdbOut) /* Write out a <li> entry for a search hit on a track, along with a nested * <ul> for any included hits to subtracks */ { printf("<li configLink='%s' nodeType='track'>\n", dyStringContents(tdbOut->configUrl)); printf("%s", dyStringContents(tdbOut->shortLabel)); if (tdbOut->childCount > 0) printf(" (%d subtrack%s)", tdbOut->childCount, tdbOut->childCount==1?"":"s"); if (isNotEmpty(dyStringContents(tdbOut->metaTags))) { printf("<br><span class='descriptionMatch'><em>Metadata: %s</em></span>\n", dyStringContents(tdbOut->metaTags));