23b67b422f361ca443b8a05d1b9223c91f47bf30
max
  Tue Nov 30 07:10:28 2021 -0800
fixing hgHubCheck bug found by Galt, refs #28566

diff --git src/hg/hgHubConnect/hgHubConnect.c src/hg/hgHubConnect/hgHubConnect.c
index 58f118d..b2ad100 100644
--- src/hg/hgHubConnect/hgHubConnect.c
+++ src/hg/hgHubConnect/hgHubConnect.c
@@ -429,85 +429,85 @@
 puts("For information on making track hubs, see the following pages: \n "
     "<ul>\n"
     "<li><a href='../goldenPath/help/hubQuickStart.html' style='color:#121E9A' target=_blank>Quick Start Guide</a></li>\n"
     "<li><a href=\"../goldenPath/help/hgTrackHubHelp.html\" style='color:#121E9A' TARGET=_blank>Track Hub User's Guide</a></li>\n"
     "<li><a href=\"../goldenPath/help/hgTrackHubHelp#Hosting\" style='color:#121E9A' target=_blank>Where to host your track hub</a></li>\n"
     "<li><a href=\"../goldenPath/help/trackDb/trackDbHub.html\" style='color:#121E9A' target=_blank>Track Hub Settings Reference</a></li>\n"
     "</ul>\n"
     "<BR>You may also <a href='../contacts.html' style='color:#121E9A'>contact us</a> if you have any "
     "issues or questions on hub development.");
 puts("</div>"); // .tabSection
 
 puts("<div class='tabSection'>");
 puts("<h4>Check a hub for errors</h4>");
 printf("<label for=\"validateHubUrl\"><b>Hub URL:</b></label>");
 printf("<input id='validateHubUrl' name='validateHubUrl' class='hubField' "
-       "placeholder='e.g. https://genome.ucsc.edu/goldenPath/help/examples/hubDirectory/hub.txt' "
        "type='text' size='65'%s>\n", hubUrlVal);
 printf("<button type='button' id='hubValidateButton'>Check</button>\n");
+printf("&nbsp;&nbsp<span style='font-size:90%%' class='link' id='loadSampleHub'>Load Example URL</span>\n");
 
 puts("<div class='help'>Use the URL bar above to check a hub for errors. This will "
         "validate the hub's configuration files, including hub.txt, "
         "genomes.txt and trackDb.txt. "
     "It will also present a  hierarchical tree of tracks with any errors in red. A hub "
     "with no errors still shows the tree which can be used to explore the track hierarchy. "
     "Hub error checking will always refresh the files and never use our remote file cache (see below)."
     "</div>\n "
 );
 puts("</div>"); // .tabSection
 
 puts("<div class='tabSection'>");
 puts("<h4>Enable Genome Browser debugging modes</h4>");
 puts("<div class='help'>These apply to all connected hubs. By default, caching is activated and track load times are not shown, but you can change these settings while developing your hub:</div>");
 puts("<div style='margin-left: 15px'>");
 puts("<FORM ACTION='hgHubConnect#hubDeveloper' METHOD='POST' NAME='debugForm'>");
 
 // output the udcTimeout button
 char *noCacheLabel = "Inactive, never cache";
 char *timeout = "5";
 char *cacheStatus = "ON";
-char *description = "The current status always caches contents at UCSC. This means that data access is faster, but you cannot see the effect of changes to your files on the Genome Browser for at least 5 minutes.";
+char *description = "Always cache contents at UCSC. This means that data access is faster, but you cannot see the effect of changes to your files on the Genome Browser for at least 5 minutes.";
 if (cartNonemptyString(cart, "udcTimeout")) 
     {
     noCacheLabel = "Active, always cache";
     timeout = "";
     cacheStatus = "OFF";
-    description = "The current status does not cache contents at UCSC and always load them from the source server. This means that data access is slower, but you can see the effect of changes to your files immediately on the Genome Browser.";
+    description = "Do not cache contents at UCSC and always load them from the source server. This means that data access is slower, but you can see the effect of changes to your files immediately on the Genome Browser.";
     }
 printf("<b style='font-size:90%%'>File caching: %s</b> &nbsp;", cacheStatus);
 printf("<button type='submit' name='udcTimeout' value='%s'>Change to: %s</button>", timeout, noCacheLabel);
 
-printf("<div class='help'>%s<br>", description);
-puts("For custom tracks, this affects only the remote formats (bigBed, bigWig, tabix, BAM, CRAM, etc), not text files (BED, PSL, etc), which are stored at UCSC.</div>");
+printf("<div class='help'>Current setting: %s<br>", description);
+puts("For custom tracks, this affects only the remote formats (bigBed, bigWig, VCF+tabix, BAM, CRAM, bigPsl, HiC, etc), not text files (BED, VCF, PSL, etc), which are stored at UCSC.</div>");
 
 // output the measureTiming button
 char *timeLabel = "Show timings";
 char *timeVal = "on";
 char *timeDesc = "Show no timing measurements.";
 char *timeStatus = "OFF";
 if (cartNonemptyString(cart, "measureTiming")) 
     {
         timeLabel = "Hide timings";
         timeVal = "";
         timeDesc = "Shows loading time in milliseconds for each track, to help debug performance problems.";
         timeStatus = "ON";
     }
 
-printf("<b style='font-size:90%%'>Load times: %s</b> &nbsp;", timeStatus);
+printf("<b style='font-size:90%%'>Show load times: %s</b> &nbsp;", timeStatus);
 printf("<button type='submit' name='measureTiming' value='%s'>Change to: %s</button>", timeVal, timeLabel);
 
-printf("<div class='help'>%s</div>", timeDesc);
+printf("<div class='help'>Current setting: %s</div>", timeDesc);
 
 puts("</div>"); // margin-left
 puts("</div>"); // tabSection
 puts("</div>"); // #hubDeveloper
 
 jsOnEventById("click", "hubValidateButton", "makeIframe(event)");
 }
 
 void printSearchAndFilterBoxes(int searchEnabled, char *hubSearchTerms, char *dbFilter)
 /* Create the text boxes for search and database filtering along with the required
  * javscript */
 {
 printf("<FORM ACTION=\"%s\" NAME=\"searchHubForm\">\n",  "../cgi-bin/hgHubConnect");
 if (searchEnabled)
     {
@@ -1519,74 +1519,73 @@
 	return;
 	}
     }
 
 if (cartVarExists(cart, hgHubDoHubCheck))
     {
     // we aren't calling cartWebStart so we need to push 3 error handlers:
     webPushErrHandlers();
     pushWarnHandler(blankWarn);
     puts("<html>");
     puts("<body>");
     puts("<link rel='stylesheet' href='../style/HGStyle.css' type='text/css'>");
     printIncludes();
 
     jsInline("trackData = [];\n");
-    char *hubUrl = cartOptionalString(cart, "validateHubUrl");
+    char *hubUrl = cgiOptionalString("validateHubUrl");
     jsInline("document.body.style.margin = 0;\n");
     // simulate the look and feel of a dialog window with a blue bar at the top
     puts("<div id='titlebar' style='background: #D9E4F8; border: 1px outset #000088; padding: 10px'>"
         "<span id='title' style='font-weight: bold; margin: .2em 0 .1em; color: #000088'>Hub Check</span>"
         "<a href='#' id='windowX' style='float: right' class='ui-dialog-titlebar-close ui-corner-all ui-state-hover' role='button'>"
         "<span class='ui-icon ui-icon-closethick'>close</span></a></div>");
 
     puts("<div id='content' style='margin:10px; padding: 2px'>");
     jsOnEventByIdF("click", "windowX", "closeIframe()");
     if (isEmpty(hubUrl))
         printf("Please wait, loading and checking hub, this can take 15 seconds to 5 minutes.");
     else
         {
         puts("<p><button id='reloadButton'>Check again</button>");
         puts("&nbsp;&nbsp;<button id='closeButton'>Close this window</button></p>");
         jsOnEventByIdF("click", "reloadButton", "reloadIframe()");
         jsOnEventByIdF("click", "closeButton", "closeIframe()");
+        jsInline("document.onkeydown = function(evt) { if (evt.keyCode===27) { closeIframe() } };");
 
         printf("<div>Finished checking %s</div>", hubUrl);
         doValidateNewHub(hubUrl);
+        puts("<hr>");
         puts("<p>Our command line tool <a target=_blank href='https://hgdownload.soe.ucsc.edu/downloads.html#utilities_downloads'>hubCheck</a> "
                 "can be used to obtain the same output from a Unix command line.</p>");
+        puts("<p>To download the hubCheck tool for Linux, run these commands"
+             " (replace 'linux' with 'macOSX' on a x86 Mac):<br>"
+                "<pre>wget http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/hubCheck\n"
+                "chmod a+x hubCheck\n"
+                "hubCheck https://genome.ucsc.edu/goldenPath/help/examples/hubDirectory/hub.txt</pre></p>");
+        puts("<p>You can use the 'Esc' key to close this window.</p>");
         }
     puts("</div>"); // margin 10px
     puts("</div>"); // ui-dialog-titlebar
     puts("</div>"); // ui-dialog
     cartWebEnd();
     return;
     }
 
 cartWebStart(cart, NULL, "%s", pageTitle);
 
 printIncludes();
 
-if (cartVarExists(cart, hgHubDoHubCheck))
-    {
-    jsInline("trackData = [];\n");
-    char *hubUrl = cartOptionalString(cart, "validateHubUrl");
-    doValidateNewHub(hubUrl);
-    cartWebEnd();
-    return;
-    }
-
 // this variable is used by hub search and hub validate, initialize here so we don't
 // overwrite it unintentionally depending on which path the CGI takes
 jsInline("trackData = [];\n");
 
 getDbAndGenome(cart, &database, &organism, oldVars);
 
 char *survey = cfgOptionEnv("HGDB_HUB_SURVEY", "hubSurvey");
 char *surveyLabel = cfgOptionEnv("HGDB_HUB_SURVEY_LABEL", "hubSurveyLabel");
 
 if (survey && differentWord(survey, "off"))
     hPrintf("<span style='background-color:yellow;'><A HREF='%s' TARGET=_BLANK><EM><B>%s</EM></B></A></span>\n", survey, surveyLabel ? surveyLabel : "Take survey");
 hPutc('\n');
 
 // grab all the hubs that are listed in the cart
 struct hubConnectStatus *hubList =  hubConnectStatusListFromCartAll(cart);