b312b42ad8c3e89350417bb7b05c9e05a1507281
kate
Thu Jan 27 22:10:20 2011 -0800
Support for genome browser preview site.
1. Changes browser title in CGIs
2. Prints warning text on hgGateway
3. Prints warning text on home page
1. and 2. activated by HTTP_HOST prefix 'genome-preview', or by setting
test.preview=true in hg.conf
diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index 25283ff..75d43e8 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -3025,45 +3025,63 @@
struct slName *hSplitTableNames(char *db, char *rootName)
/* Return a list of all split tables for rootName, or of just rootName if not
* split, or NULL if no such tables exist. */
{
struct hash *hash = NULL;
struct hashEl *hel = NULL;
hash = tableListGetDbHash(db);
hel = hashLookup(hash, rootName);
if (hel == NULL)
return NULL;
else
return slNameCloneList((struct slName *)(hel->val));
}
-boolean hIsPrivateHost()
-/* Return TRUE if this is running on private web-server. */
+boolean hHostHasPrefix(char *prefix)
+/* Return TRUE if this is running on web-server with host name prefix */
{
-static boolean gotIt = FALSE;
-static boolean priv = FALSE;
-if (!gotIt)
+if (prefix == NULL)
+ return FALSE;
+
+return startsWith(prefix, getenv("HTTP_HOST"));
+}
+
+boolean hIsPrivateHost()
+/* Return TRUE if this is running on private (development) web-server.
+ * This was originally genome-test as well as hgwdev, however genome-test
+ * may be repurposed to direct users to the preview site instead of development site. */
{
- char *t = getenv("HTTP_HOST");
- if (t != NULL && (startsWith("genome-test", t) || startsWith("hgwdev", t)))
- priv = TRUE;
- gotIt = TRUE;
+return hHostHasPrefix("hgwdev");
}
-return priv;
+
+boolean hIsPreviewHost()
+/* Return TRUE if this is running on preview web-server. The preview
+ * server is a mirror of the development server provided for public
+ * early access. */
+{
+if (cfgOption("test.preview"))
+ return TRUE;
+return hHostHasPrefix("genome-preview");
}
+char *hBrowserName()
+/* Return browser name based on host name */
+{
+return (hIsPreviewHost() ? "Preview Genome Browser" :
+ (hIsPrivateHost() ? "TEST Genome Browser" : "Genome Browser"));
+}
int hOffsetPastBin(char *db, char *chrom, char *table)
/* Return offset into a row of table that skips past bin
* field if any. */
{
struct hTableInfo *hti = hFindTableInfo(db, chrom, table);
if (hti == NULL)
return 0;
return hti->hasBin;
}
/* Stuff to handle binning - which helps us restrict our
* attention to the parts of database that contain info
* about a particular window on a chromosome. This scheme
* will work without modification for chromosome sizes up
@@ -3558,31 +3576,31 @@
static void dumpFlagStatus(struct trackDb *tdbList, char *tableName, char *label)
/* Look for tdbList for track matching tableName. Print out info on it starting with label. */
{
struct trackDb *tdb = rFindTrack(0, tdbList, tableName);
if (tdb == NULL)
printf("%s: nil
\n", label);
else
printf("%s: treeNodeType %d, composite? %d, supertrack ? %d
\n", label, tdb->treeNodeType, COMPOSITE_NODE(tdb->treeNodeType), SUPERTRACK_NODE(tdb->treeNodeType));
}
#endif /* DEBUG */
struct trackDb *trackDbPolishAfterLinkup(struct trackDb *tdbList, char *db)
/* Do various massaging that can only be done after parent/child
* relationships are established. */
{
-tdbList = pruneEmpties(tdbList, db, hIsPrivateHost(), 0);
+tdbList = pruneEmpties(tdbList, db, hIsPrivateHost() || hIsPreviewHost(), 0);
trackDbContainerMarkup(NULL, tdbList);
rInheritFields(tdbList);
slSort(&tdbList, trackDbCmp);
return tdbList;
}
struct trackDb *hTrackDb(char *db)
/* Load tracks associated with current db.
* Supertracks are loaded as a trackDb, but are not in the returned list,
* but are accessible via the parent pointers of the member tracks. Also,
* the supertrack trackDb subtrack fields are not set here (would be
* incompatible with the returned list)
* Returns list sorted by priority
* NOTE: this result is cached, do not free it !
*/