73e5371ccf1a3061286242055b03cc8f0d1c456f larrym Fri Oct 28 20:09:25 2011 -0700 add NEW_MENUS code to experiment with using jabico derived menus (see redmine #5245) diff --git src/hg/lib/web.c src/hg/lib/web.c index f8d9ecb..22e42b1 100644 --- src/hg/lib/web.c +++ src/hg/lib/web.c @@ -7,30 +7,31 @@ #include "htmshell.h" #include "web.h" #include "hPrint.h" #include "hdb.h" #include "hui.h" #include "hgConfig.h" #include "cheapcgi.h" #include "dbDb.h" #include "hgColors.h" #include "hubConnect.h" #include "search.h" #ifndef GBROWSE #include "axtInfo.h" #include "wikiLink.h" #include "googleAnalytics.h" +#include "jsHelper.h" #endif /* GBROWSE */ #include "errabort.h" // FIXME tmp hack to try to find source of popWarnHandler underflows in browse /* phoneHome business */ #include #include #include /* phoneHome business */ static char const rcsid[] = "$Id: web.c,v 1.173 2010/05/20 03:14:17 kent Exp $"; /* flag that tell if the CGI header has already been outputed */ boolean webHeadAlreadyOutputed = FALSE; /* flag that tell if text CGI header hsa been outputed */ boolean webInTextMode = FALSE; static char *dbCgiName = "db"; @@ -82,41 +83,47 @@ /* set a style to add to the header */ { extraStyle = style; } void webStartText() /* output the head for a text page */ { /*printf("Content-Type: text/plain\n\n");*/ webHeadAlreadyOutputed = TRUE; webInTextMode = TRUE; webPushErrHandlers(); } +// NEW_MENUS is used to experiment with using jabico derived menus (see redmine #5245) +// curently only used in larrym's tree +// #define NEW_MENUS + static void webStartWrapperDetailedInternal(struct cart *theCart, char *db, char *headerText, char *textOutBuf, boolean withHttpHeader, boolean withLogo, boolean skipSectionHeader, boolean withHtmlHeader) /* output a CGI and HTML header with the given title in printf format */ { char uiState[256]; char *scriptName = cgiScriptName(); boolean isEncode = FALSE; +#ifndef NEW_MENUS boolean isGsid = hIsGsidServer(); boolean isGisaid = hIsGisaidServer(); +#endif if (theCart) { char *theGenome = NULL; char *genomeEnc = NULL; getDbAndGenome(theCart, &db, &theGenome, NULL); genomeEnc = cgiEncode(theGenome); safef(uiState, sizeof(uiState), "?%s=%s&%s=%s&%s=%u", orgCgiName, genomeEnc, dbCgiName, db, cartSessionVarName(), cartSessionId(theCart)); } else { @@ -208,30 +215,65 @@ { puts("" "\"ENCODE" ""); puts("\"ENCODE"); } else { puts(""); } puts("" "\n" "" "\n" ); } /* Put up the hot links bar. */ + +#ifdef NEW_MENUS + + char *docRoot = hDocumentRoot(); + jsIncludeFile("jquery.js", NULL); + if(docRoot != NULL) + { + struct dyString *file = dyStringCreate("%s/%s", docRoot, "NavBar.html"); + FILE *fd = fopen(dyStringContents(file), "r"); + if(fd == NULL) + // fail some other way (e.g. HTTP 500)? + errAbort("Couldn't open header file '%s' for reading", dyStringContents(file)); + else + { + char buf[4096]; + while(TRUE) + { + size_t n = fread(buf, 1, sizeof(buf), fd); + if(n) + fwrite(buf, 1, n, stdout); + else + break; + } + fclose(fd); + printf("\n"); + } + } + else + { + // tolerate missing docRoot (i.e. when running from command line) + // XXXX ???? + } + +#else + if (isGisaid) { printf("\n"); printf("\n"); // Home if (haveBlat) printf("\n"); // Blat printf("\n"); // Subject View printf("\n",uiState); // Sequence View printf("\n"); // Table View printf("
HomeBlatSample ViewSequence ViewTable View 
\n"); // last column squeezes other columns left } else if (isGsid) { printf("\n"); printf("\n"); // Home @@ -331,30 +373,32 @@ printf("\n"); } } printf("
HomeHelp 
\n"); // last column squeezes other columns left puts("\n"); +#endif + if(!skipSectionHeader) /* this HTML must be in calling code if skipSectionHeader is TRUE */ { puts( // TODO: Replace nested tables with CSS (difficulty is that tables are closed elsewhere) "" "\n" "\n" " \n" "
\n" "
\n" "
" ); htmlTextOut(textOutBuf); puts( "
\n"