90782cab70bd2f2ee992b0a7f95b656c56fdbba1 braney Mon Jun 3 15:34:47 2019 -0700 order public hubs by shortLabel diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c index f89faa8..99b2af4 100644 --- src/hg/hgHubConnect/hgHubConnect.c +++ src/hg/hgHubConnect/hgHubConnect.c @@ -1198,88 +1198,99 @@ struct genomeOutputStructure *genomeOut = hubOut->genomes; if (genomeOut != NULL) { printf("
  • %d Matching Assembl%s\n
  • \n"); } printf("\n"); } } +int hubEntryCmp(const void *va, const void *vb) +/* Compare to sort based on shortLabel */ +{ +const struct hubEntry *a = *((struct hubEntry **)va); +const struct hubEntry *b = *((struct hubEntry **)vb); + +return strcasecmp(a->shortLabel, b->shortLabel); +} + void printHubList(struct slName *hubsToPrint, struct hash *hubLookup, struct hash *searchResultHash) /* Print out a list of hubs, possibly along with search hits to those hubs. * hubLookup takes hub URLs to struct hubEntry * searchResultHash takes hub URLs to struct hubSearchText * (list of hits on that hub) */ { int count = 0; int udcTimeoutVal = udcCacheTimeout(); char *udcOldDir = cloneString(udcDefaultDir()); char *searchUdcDir = cfgOptionDefault("hgHubConnect.cacheDir", udcOldDir); udcSetDefaultDir(searchUdcDir); udcSetCacheTimeout(1<<30); +struct hubEntry *hubList = NULL; +struct hubEntry *hubInfo; if (hubsToPrint != NULL) { printHubListHeader(); if (searchResultHash == NULL) // if not displaying search results, join the hub s into one table printf("\n"); struct slName *thisHubName = NULL; for (thisHubName = hubsToPrint; thisHubName != NULL; thisHubName = thisHubName->next) { struct hubEntry *hubInfo = (struct hubEntry *) hashFindVal(hubLookup, thisHubName->name); if (hubInfo == NULL) { /* This shouldn't happen often, but maybe the search hits list was built from an outdated * search text file that includes hubs for which no info is available. * Skip this hub. */ continue; } + slAddHead(&hubList, hubInfo); + } + slSort(&hubList, hubEntryCmp); + + for (hubInfo = hubList; hubInfo != NULL; hubInfo = hubInfo->next) + { struct hubSearchText *searchResult = NULL; if (searchResultHash != NULL) { - searchResult = (struct hubSearchText *) hashMustFindVal(searchResultHash, thisHubName->name); + searchResult = (struct hubSearchText *) hashMustFindVal(searchResultHash, hubInfo->hubUrl); } printOutputForHub(hubInfo, searchResult, count); count++; } if (searchResultHash == NULL) printf("
    \n"); } udcSetCacheTimeout(udcTimeoutVal); udcSetDefaultDir(udcOldDir); if (hubsToPrint != NULL) { /* Write out the list of hubs in a single table inside a div that will be hidden by * javascript. This table is used (before being hidden) to set common column widths for * the individual hub tables when they're split by detailed search results. */ printf("
    \n"); printf("\n"); - struct slName *thisHubName = NULL; - for (thisHubName = hubsToPrint; thisHubName != NULL; thisHubName = thisHubName->next) + for (hubInfo = hubList; hubInfo != NULL; hubInfo = hubInfo->next) { - struct hubEntry *hubInfo = (struct hubEntry *) hashFindVal(hubLookup, thisHubName->name); - if (hubInfo == NULL) - { - continue; - } printOutputForHub(hubInfo, NULL, count); count++; } printf("
    \n"); printf("
    \n"); } jsInline( "function lineUpCols()\n" " {\n" " var tableList = $('table.hubList');\n" " if (tableList.length == 0)\n" " return;\n" " var colWidths = new Array();\n" " var combinedTrackTable = $('#hideThisTable');\n" " for (i=0; i