915f56e3f34f66d58bf6573dc4dfddd068bd4090
angie
  Tue Apr 19 13:36:48 2016 -0700
Simplify the generation of hgGateway's dbDbTaxonomy tree info and support mirrors better: new hg.conf setting hgGateway.dbDbTaxonomy enables tree display and specifies relative URL to file.  Instead of dbDbTaxonomy.{hgwdev,rr}.js, there is only one dbDbTaxonomy.js, built from hgcentraltest (hgwdev).  hgGateway.c's HTML output includes JS encoding the set of active genomes+taxIds.  hgGateway.js uses that to prune the tree so it contains only active genomes; now we can use the hgwdev tree on the RR and see only RR species.  Also updated dbDbTaxonomy.js to get the latest hgwdev species as of 4/18/16.
refs #15277

diff --git src/hg/hgGateway/hgGateway.c src/hg/hgGateway/hgGateway.c
index bf309fe..becc9da 100644
--- src/hg/hgGateway/hgGateway.c
+++ src/hg/hgGateway/hgGateway.c
@@ -230,68 +230,87 @@
 if (pix)
     jsonWriteNumber(cj->jw, "pix", pix);
 }
 
 static void doCartJson()
 /* Perform UI commands to update the cart and/or retrieve cart vars & metadata. */
 {
 struct cartJson *cj = cartJsonNew(cart);
 cartJsonRegisterHandler(cj, "setTaxId", setTaxId);
 cartJsonRegisterHandler(cj, "setDb", setDb);
 cartJsonRegisterHandler(cj, "setHubDb", setHubDb);
 cartJsonRegisterHandler(cj, "getUiState", getUiState);
 cartJsonExecute(cj);
 }
 
+static void printActiveGenomes()
+/* Print out JSON for an object mapping each genome that has at least one db with active=1
+ * to its taxId.  */
+{
+struct jsonWrite *jw = jsonWriteNew();
+jsonWriteObjectStart(jw, NULL);
+struct sqlConnection *conn = hConnectCentral();
+char *query = NOSQLINJ "select distinct(genome),taxId from dbDb where active=1 "
+    "and taxId > 1;"; // filter out experimental hgwdev-only stuff with invalid taxIds
+struct sqlResult *sr = sqlGetResult(conn, query);
+char **row;
+while ((row = sqlNextRow(sr)) != NULL)
+    jsonWriteNumber(jw, row[0], atoi(row[1]));
+hDisconnectCentral(&conn);
+jsonWriteObjectEnd(jw);
+puts(jw->dy->string);
+jsonWriteFree(&jw);
+}
+
 static void doMainPage()
 /* Send HTML with javascript to bootstrap the user interface. */
 {
 // Start web page with new banner
 char *db = NULL, *genome = NULL, *clade = NULL;
 getDbGenomeClade(cart, &db, &genome, &clade, oldVars);
 webStartJWest(cart, db, "Genome Browser Gateway");
 
-// Edit the HTML in hgGateway.html (see makefile):
+// The visible page elements are all in ./hgGateway.html, which is transformed into a quoted .h
+// file containing a string constant that we #include and print here (see makefile).
 puts(
 #include "hgGateway.html.h"
 );
 
-// Set global JS variable hgsid
+// Set global JS variables hgsid and activeGenomes
 // We can't just use "var hgsid = " or the other scripts won't see it -- it has to be
 // "window.hgsid = ".
 puts("<script>");
 printf("window.%s = '%s';\n", cartSessionVarName(), cartSessionId(cart));
+puts("window.activeGenomes =");
+printActiveGenomes();
+puts(";");
 puts("</script>");
 
 puts("<script src=\"../js/es5-shim.4.0.3.min.js\"></script>");
 puts("<script src=\"../js/es5-sham.4.0.3.min.js\"></script>");
 puts("<script src=\"../js/lodash.3.10.0.compat.min.js\"></script>");
 puts("<script src=\"../js/cart.js\"></script>");
 
 webIncludeResourceFile("jquery-ui.css");
 jsIncludeFile("jquery-ui.js", NULL);
 jsIncludeFile("jquery.watermarkinput.js", NULL);
 jsIncludeFile("utils.js",NULL);
 
 // Phylogenetic tree .js file, produced by dbDbTaxonomy.pl:
-char *hostCode = (hIsPrivateHost() || hIsPreviewHost()) ? "hgwdev" : "rr";
-
-// Keep using dbDbTaxonomy.rr.js on demo6 for testing.
-if (hHostHasPrefix("hgwdev-demo6"))
-    hostCode = "rr";
-
-printf("<script src=\"../js/dbDbTaxonomy.%s.js\"></script>\n", hostCode);
+char *dbDbTree = cfgOptionDefault("hgGateway.dbDbTaxonomy", NULL);
+if (isNotEmpty(dbDbTree))
+    printf("<script src=\"%s\"></script>\n", dbDbTree);
 
 // Main JS for hgGateway:
 puts("<script src=\"../js/hgGateway.js\"></script>");
 
 webIncludeFile("inc/jWestFooter.html");
 
 webEndJWest();
 }
 
 void doMiddle(struct cart *theCart)
 /* Depending on invocation, either perform a query and print out results
  * or display the main page. */
 {
 cart = theCart;
 if (cgiOptionalString(CARTJSON_COMMAND))