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 <utime.h> #include <htmlPage.h> #include <signal.h> /* 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("<A HREF=\"http://www.genome.gov/10005107\" TARGET=\"_BLANK\">" "<IMG SRC=\"../images/ENCODE_scaleup_logo.png\" height=50 ALT=\"ENCODE Project at NHGRI\">" "</A>"); puts("<IMG SRC=\"../images/encodeDcc.jpg\" ALT=\"ENCODE Project at UCSC\">"); } else { puts("<IMG SRC=\"../images/title.jpg\">"); } puts("</TH></TR>" "\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("<base href='http://hgwdev-larrym.cse.ucsc.edu/'>\n"); + } + } + else + { + // tolerate missing docRoot (i.e. when running from command line) + // XXXX ???? + } + +#else + if (isGisaid) { printf("<TABLE WIDTH='100%%' class='topBlueBar' BORDER='0' CELLSPACING='0' CELLPADDING='2'><TR>\n"); printf("<TD><A HREF='../index.html' class='topbar'>Home</A></TD>\n"); // Home if (haveBlat) printf("<TD><A HREF='../cgi-bin/hgBlat?command=start' class='topbar'>Blat</A></TD>\n"); // Blat printf("<TD><A HREF='../cgi-bin/gisaidSample' class='topbar'>Sample View</A></TD>\n"); // Subject View printf("<TD><A HREF='../cgi-bin/hgTracks%s' class='topbar'>Sequence View</A></TD>\n",uiState); // Sequence View printf("<TD><A HREF='../cgi-bin/gisaidTable' class='topbar'>Table View</A></TD>\n"); // Table View printf("<TD style='width:95%%'> </TD></TR></TABLE>\n"); // last column squeezes other columns left } else if (isGsid) { printf("<TABLE class='topBlueBar' BORDER='0' CELLSPACING='0' CELLPADDING='2'><TR>\n"); printf("<TD><A HREF='../index.html' class='topbar'>Home</A></TD>\n"); // Home @@ -331,30 +373,32 @@ printf("<TD><A HREF='../goldenPath/help/hgGenomeHelp.html'"); else if (endsWith(scriptName, "hgSession")) printf("<TD><A HREF='../goldenPath/help/hgSessionHelp.html'"); else if (endsWith(scriptName, "pbGateway")) printf("<TD><A HREF='../goldenPath/help/pbTracksHelpFiles/pbTracksHelp.shtml'"); else if (endsWith(scriptName, "hgVisiGene")) printf("<TD><A HREF='../goldenPath/help/hgTracksHelp.html#VisiGeneHelp'"); else printf("<TD><A HREF='../goldenPath/help/hgTracksHelp.html'"); printf(" class='topbar'>Help</A></TD>\n"); } } printf("<TD style='width:95%%'> </TD></TR></TABLE>\n"); // last column squeezes other columns left puts("</TD></TR>\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) "<!-- +++++++++++++++++++++ CONTENT TABLES +++++++++++++++++++ -->" "\n" "<TR><TD COLSPAN=3>\n" " <!--outer table is for border purposes-->\n" " <TABLE WIDTH='100%' BGCOLOR='#" HG_COL_BORDER "' BORDER='0' CELLSPACING='0' CELLPADDING='1'><TR><TD>\n" " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' BORDER='0' CELLSPACING='0' CELLPADDING='0'><TR><TD>\n" " <div class='subheadingBar'><div class='windowSize' id='sectTtl'>" ); htmlTextOut(textOutBuf); puts( " </div></div>\n"