ba4333b84dc63534d59b306fea2031d7e8d08fbf
angie
  Thu Jan 14 12:24:50 2016 -0800
Added the capability to substitute $hgsid from the cart in a help file
included by webIncludeHelpFileSubst, for internal links.
Improved the description of hgVai Transcript Status options.
refs #16502

diff --git src/hg/lib/web.c src/hg/lib/web.c
index 297f9b8..e6ba352 100644
--- src/hg/lib/web.c
+++ src/hg/lib/web.c
@@ -1,30 +1,31 @@
 /* Copyright (C) 2014 The Regents of the University of California 
  * See README in this or parent directory for licensing information. */
 
 #include "common.h"
 #include <regex.h>
 #include "hCommon.h"
 #include "obscure.h"
 #include "dnautil.h"
 #include "errAbort.h"
 #include "htmshell.h"
 #include "web.h"
 #include "hPrint.h"
 #include "hdb.h"
 #include "hui.h"
 #include "hgConfig.h"
+#include "hVarSubst.h"
 #include "cheapcgi.h"
 #include "dbDb.h"
 #include "hgColors.h"
 #include "hubConnect.h"
 #include "search.h"
 #include "geoMirror.h"
 #include "trackHub.h"
 #include "versionInfo.h"
 
 #ifndef GBROWSE
 #include "axtInfo.h"
 #include "wikiLink.h"
 #include "googleAnalytics.h"
 #include "jsHelper.h"
 #endif /* GBROWSE */
@@ -882,48 +883,70 @@
 cartSetString(cart, "db", *retDb);
 cartSetString(cart, "org", *retGenome);
 if (gotClade)
     cartSetString(cart, "clade", *retClade);
 }
 
 void getDbAndGenome(struct cart *cart, char **retDb, char **retGenome,
 		    struct hash *oldVars)
 /* Get just the db and genome. */
 {
 char *garbage = NULL;
 getDbGenomeClade(cart, retDb, retGenome, &garbage, oldVars);
 freeMem(garbage);
 }
 
-void webIncludeFile(char *file)
-/* Include an HTML file in a CGI.
+static void webIncludeFileSubst(char *file, struct cart *cart)
+/* Include an HTML file in a CGI.  If cart is non-null, invoke hVarSubstWithCart.
  *   The file path may begin with hDocumentRoot(); if it doesn't, it is
  *   assumed to be relative and hDocumentRoot() will be prepended. */
 {
 char *str = hFileContentsOrWarning(file);
+if (cart != NULL)
+    {
+    char *db = cartString(cart, "db");
+    hVarSubstWithCart("webIncludeFileSubst", cart, NULL, db, &str);
+    }
 puts(str);
 freeMem(str);
 }
 
+void webIncludeFile(char *file)
+/* Include an HTML file in a CGI.
+ *   The file path may begin with hDocumentRoot(); if it doesn't, it is
+ *   assumed to be relative and hDocumentRoot() will be prepended. */
+{
+return webIncludeFileSubst(file, NULL);
+}
+
+void webIncludeHelpFileSubst(char *fileRoot, struct cart *cart, boolean addHorizLine)
+/* Given a help file root name (e.g. "hgPcrResult" or "cutters"),
+ * print out the contents of the file.  If cart is non-NULL, invoke hVarSubstWithCart
+ * before printing.  If addHorizLine, print out an <HR> first. */
+{
+if (addHorizLine)
+    htmlHorizontalLine();
+char *file = hHelpFile(fileRoot);
+webIncludeFileSubst(file, cart);
+}
+
 void webIncludeHelpFile(char *fileRoot, boolean addHorizLine)
 /* Given a help file root name (e.g. "hgPcrResult" or "cutters"),
  * print out the contents of the file.  If addHorizLine, print out an
  * <HR> first. */
 {
-if (addHorizLine)
-    htmlHorizontalLine();
-webIncludeFile(hHelpFile(fileRoot));
+return webIncludeHelpFileSubst(fileRoot, NULL, addHorizLine);
 }
 
 void webPrintLinkTableStart()
 /* Print link table start in our colors. */
 {
 printf("<TABLE><TR><TD BGCOLOR='#" HG_COL_BORDER "'>\n");
 printf("<TABLE CELLSPACING=1 CELLPADDING=3><TR>\n");
 }
 
 void webPrintLinkTableEnd()
 /* Print link table end in our colors. */
 {
 printf("</TR></TABLE>\n");
 printf("</TD></TR></TABLE>\n");
 }