af505de858be1957547715140d750852a9734b20
max
  Mon Apr 30 10:16:29 2012 -0700
adding themes to browser: config option and background image overwrite
diff --git src/hg/lib/cart.c src/hg/lib/cart.c
index 6ef9098..8156ef0 100644
--- src/hg/lib/cart.c
+++ src/hg/lib/cart.c
@@ -1562,30 +1562,50 @@
 {
 struct cart *cart;
 char titlePlus[128];
 char *proteinID;
 pushWarnHandler(cartEarlyWarningHandler);
 cart = cartAndCookie(cookieName, exclude, oldVars);
 proteinID = cartOptionalString(cart, "proteinID");
 safef(titlePlus, sizeof(titlePlus), "Protein %s - %s", proteinID, title);
 popWarnHandler();
 htmStart(stdout, titlePlus);
 cartWarnCatcher(doMiddle, cart, htmlVaWarn);
 cartCheckout(&cart);
 cartFooter();
 }
 
+void setBackgroundFromCart(struct cart *cart) 
+/* if 'theme' set in cart: overwrite background with the one from defined for this theme */
+{
+printf("trying to reset background ");
+char *cartTheme = cartOptionalString(cart, "theme");
+if (cartTheme==NULL)
+    return;
+printf("found theme");
+char * themeKey = stringCopy
+char *themeDefLine = cfgOption(cartTheme);
+if (themeDefLine == NULL)
+    return;
+printf("found theme line ");
+char * background = cloneString(themeDefLine);
+chopSuffixAt(background, ',');
+printf("background set to %s", background);
+htmlSetBackground(background);
+freeMem(background);
+}
+
 void cartHtmlShellWithHead(char *head, char *title, void (*doMiddle)(struct cart *cart),
 	char *cookieName, char **exclude, struct hash *oldVars)
 /* Load cart from cookie and session cgi variable.  Write web-page
  * preamble including head and title, call doMiddle with cart, and write end of web-page.
  * Exclude may be NULL.  If it exists it's a comma-separated list of
  * variables that you don't want to save in the cart between
  * invocations of the cgi-script. */
 {
 struct cart *cart;
 char *db, *org, *pos, *clade=NULL;
 char titlePlus[128];
 char extra[128];
 pushWarnHandler(cartEarlyWarningHandler);
 cart = cartAndCookie(cookieName, exclude, oldVars);
 getDbAndGenome(cart, &db, &org, oldVars);
@@ -1596,30 +1616,31 @@
     {
     struct hashEl *oldpos = hashLookup(oldVars, positionCgiName);
     if(oldpos != NULL && differentString(pos,oldpos->val))
         cartSetString(cart,"lastPosition",oldpos->val);
     }
 *extra = 0;
 if (pos == NULL && org != NULL)
     safef(titlePlus,sizeof(titlePlus), "%s%s - %s",org, extra, title );
 else if (pos != NULL && org == NULL)
     safef(titlePlus,sizeof(titlePlus), "%s - %s",pos, title );
 else if (pos == NULL && org == NULL)
     safef(titlePlus,sizeof(titlePlus), "%s", title );
 else
     safef(titlePlus,sizeof(titlePlus), "%s%s %s - %s",org, extra,pos, title );
 popWarnHandler();
+setBackgroundFromCart(cart);
 htmStartWithHead(stdout, head, titlePlus);
 cartWarnCatcher(doMiddle, cart, htmlVaWarn);
 cartCheckout(&cart);
 cartFooter();
 }
 
 void cartHtmlShell(char *title, void (*doMiddle)(struct cart *cart),
 	char *cookieName, char **exclude, struct hash *oldVars)
 /* Load cart from cookie and session cgi variable.  Write web-page
  * preamble, call doMiddle with cart, and write end of web-page.
  * Exclude may be NULL.  If it exists it's a comma-separated list of
  * variables that you don't want to save in the cart between
  * invocations of the cgi-script. */
 {
 cartHtmlShellWithHead("", title, doMiddle, cookieName, exclude, oldVars);