981ef07d25e4560559dae28d3e316913569944d7 tdreszer Fri Jul 6 17:51:06 2012 -0700 Next batch of many checkins as dictated by Jim. Formatting space after if and limiting lines to 100 chars. Changes limited to lines last touched by tdreszer (git blame) so as not to ruin history. None of these changes should affect executables in any way. diff --git src/hg/lib/web.c src/hg/lib/web.c index 53187d4..80b8818 100644 --- src/hg/lib/web.c +++ src/hg/lib/web.c @@ -149,33 +149,33 @@ /* Preamble. */ dnaUtilOpen(); if (withHttpHeader) puts("Content-type:text/html\n"); if (withHtmlHeader) { char *newString, *ptr1, *ptr2; char *browserVersion; if (btIE == cgiClientBrowser(&browserVersion, NULL, NULL) && *browserVersion < '8') puts(""); else - puts(""); + puts(""); // Strict would be nice since it fixes atleast one IE problem (use of :hover CSS pseudoclass) - //puts(""); puts( "" "\n" "" "\n" ); printf("\t%s\n", headerText); printf("\t" "\n" "\t" "\n" "\t" "\n" "\t" "\n" "\t" ); /* we need to take any HTML formatting out of the titlebar string */ newString = cloneString(textOutBuf); for(ptr1=newString, ptr2=textOutBuf; *ptr2 ; ptr2++) @@ -252,149 +252,168 @@ } 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 + 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"); 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 + printf("<TD><A HREF='../cgi-bin/hgBlat?command=start' class='topbar'>Blat</A></TD>\n"); + printf("<TD><A HREF='../cgi-bin/gisaidSample' class='topbar'>Sample View</A></TD>\n"); + printf("<TD><A HREF='../cgi-bin/hgTracks%s' class='topbar'>Sequence View</A></TD>\n",uiState); + printf("<TD><A HREF='../cgi-bin/gisaidTable' class='topbar'>Table View</A></TD>\n"); + 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 + printf("<TD><A HREF='../index.html' class='topbar'>Home</A></TD>\n"); if (haveBlat) - printf("<TD ALIGN=CENTER><A HREF='../cgi-bin/hgBlat?command=start' class='topbar'>Blat</A></TD>\n"); // Blat - printf("<TD><A HREF='../cgi-bin/gsidSubj' class='topbar'>Subject 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/gsidTable' class='topbar'>Table View</A></TD>\n"); // Table View + printf("<TD ALIGN=CENTER><A HREF='../cgi-bin/hgBlat?command=start' " + "class='topbar'>Blat</A></TD>\n"); + printf("<TD><A HREF='../cgi-bin/gsidSubj' class='topbar'>Subject View</A></TD>\n"); + printf("<TD><A HREF='../cgi-bin/hgTracks%s' class='topbar'>Sequence View</A></TD>\n",uiState); + printf("<TD><A HREF='../cgi-bin/gsidTable' class='topbar'>Table View</A></TD>\n"); if (endsWith(scriptName, "hgBlat")) - printf("<TD><A HREF='/goldenPath/help/gsidTutorial.html#BLAT' TARGET=_blank class='topbar'>Help</A></TD>\n"); // Help + printf("<TD><A HREF='/goldenPath/help/gsidTutorial.html#BLAT' TARGET=_blank " + "class='topbar'>Help</A></TD>\n"); else - printf("<TD><A HREF='/goldenPath/help/sequenceViewHelp.html' TARGET=_blank class='topbar'>Help</A></TD>\n"); // Help - printf("<TD style='width:95%%'> </TD></TR></TABLE>\n"); // last column squeezes other columns left + printf("<TD><A HREF='/goldenPath/help/sequenceViewHelp.html' TARGET=_blank " + "class='topbar'>Help</A></TD>\n"); + printf("<TD style='width:95%%'> </TD></TR></TABLE>\n"); + // last column squeezes other columns left } else if (dbIsFound) { - puts("<!-- +++++++++++++++++++++ HOTLINKS BAR +++++++++++++++++++ -->\n<TR><TD COLSPAN=3 HEIGHT=40>"); + puts("<!-- +++++++++++++++++++++ HOTLINKS BAR +++++++++++++++++++ -->\n" + "<TR><TD COLSPAN=3 HEIGHT=40>"); puts("<TABLE class='topBlueBar' BORDER='0' CELLSPACING='0' CELLPADDING='2'><TR>"); if (isEncode) printf("<TD><A HREF='../encode/' class='topbar'>Home</A></TD>\n"); else { printf("<TD><A HREF='../index.html%s' class='topbar'>Home</A></TD>\n", uiState); if (isGsid) - printf("<TD><A HREF='../cgi-bin/gsidSubj%s' class='topbar'>Subject View</A></TD>\n",uiState); + printf("<TD><A HREF='../cgi-bin/gsidSubj%s' class='topbar'>Subject View</A></TD>\n", + uiState); else - printf("<TD><A HREF='../cgi-bin/hgGateway%s' class='topbar'>Genomes</A></TD>\n",uiState); + printf("<TD><A HREF='../cgi-bin/hgGateway%s' class='topbar'>Genomes</A></TD>\n", + uiState); if (endsWith(scriptName, "hgTracks") || endsWith(scriptName, "hgGene") || endsWith(scriptName, "hgTables") || endsWith(scriptName, "hgTrackUi") || endsWith(scriptName, "hgSession") || endsWith(scriptName, "hgCustom") || endsWith(scriptName, "hgHubConnect") || endsWith(scriptName, "hgc") || endsWith(scriptName, "hgPal")) - printf("<TD><A HREF='../cgi-bin/hgTracks%s&hgTracksConfigPage=notSet&%s=0' class='topbar'>Genome Browser</A></TD>\n",uiState,TRACK_SEARCH); + printf("<TD><A HREF='../cgi-bin/hgTracks%s&hgTracksConfigPage=notSet&%s=0' " + "class='topbar'>Genome Browser</A></TD>\n",uiState,TRACK_SEARCH); if (haveBlat && !endsWith(scriptName, "hgBlat")) - printf("<TD><A HREF='../cgi-bin/hgBlat?command=start%s%s' class='topbar'>Blat</A></TD>\n",theCart ? "&" : "", uiState+1 ); + printf("<TD><A HREF='../cgi-bin/hgBlat?command=start%s%s' " + "class='topbar'>Blat</A></TD>\n",theCart ? "&" : "", uiState+1 ); } if (!isGsid && !hIsCgbServer()) // disable TB for both GSID and CGB servers { char *table = (theCart == NULL ? NULL : (endsWith(scriptName, "hgGene") ? cartOptionalString(theCart, "hgg_type") : cartOptionalString(theCart, "g"))); if (table && theCart && (endsWith(scriptName, "hgc") || endsWith(scriptName, "hgTrackUi") || endsWith(scriptName, "hgGene"))) { struct trackDb *tdb = hTrackDbForTrack(db, table); if (tdb != NULL) - printf("<TD><A HREF='../cgi-bin/hgTables%s&hgta_doMainPage=1&hgta_group=%s&hgta_track=%s&hgta_table=%s' class='topbar'>", + printf("<TD><A HREF='../cgi-bin/hgTables%s&hgta_doMainPage=1&hgta_group=%s" + "&hgta_track=%s&hgta_table=%s' class='topbar'>", uiState, tdb->grp, tdb->track, tdb->table); else - printf("<TD><A HREF='../cgi-bin/hgTables%s&hgta_doMainPage=1' class='topbar'>", uiState); + printf("<TD><A HREF='../cgi-bin/hgTables%s&hgta_doMainPage=1' class='topbar'>", + uiState); trackDbFree(&tdb); } else printf("<TD><A HREF='../cgi-bin/hgTables%s%shgta_doMainPage=1' class='topbar'>", uiState, theCart ? "&" : "?" ); printf("Tables</A></TD>\n"); } - if (!endsWith(scriptName, "hgNear") && db != NULL && hgNearOk(db)) // possible to make this conditional: if (db != NULL && hgNearOk(db)) + if (!endsWith(scriptName, "hgNear") && db != NULL && hgNearOk(db)) { if (isGsid) - printf("<TD><A HREF='../cgi-bin/gsidTable%s' class='topbar'>Table View</A></TD>\n",uiState); + printf("<TD><A HREF='../cgi-bin/gsidTable%s' class='topbar'>Table View</A></TD>\n", + uiState); else - printf("<TD><A HREF='../cgi-bin/hgNear%s' class='topbar'>Gene Sorter</A></TD>\n",uiState); + printf("<TD><A HREF='../cgi-bin/hgNear%s' class='topbar'>Gene Sorter</A></TD>\n", + uiState); } if ((!endsWith(scriptName, "hgPcr")) && (db == NULL || hgPcrOk(db))) printf("<TD><A HREF='../cgi-bin/hgPcr%s' class='topbar'>PCR</A></TD>\n",uiState); if (endsWith(scriptName, "hgGenome")) - printf("<TD><A HREF='../cgi-bin/hgGenome%s&hgGenome_doPsOutput=on' class='topbar'>PDF/PS</A></TD>\n",uiState); + printf("<TD><A HREF='../cgi-bin/hgGenome%s&hgGenome_doPsOutput=on' class='topbar'>" + "PDF/PS</A></TD>\n",uiState); if (endsWith(scriptName, "hgHeatmap")) - printf("<TD><A HREF='../cgi-bin/hgHeatmap%s&hgHeatmap_doPsOutput=on' class='topbar'>PDF/PS</A></TD>\n",uiState); + printf("<TD><A HREF='../cgi-bin/hgHeatmap%s&hgHeatmap_doPsOutput=on' class='topbar'>" + "PDF/PS</A></TD>\n",uiState); #ifndef GBROWSE if (wikiLinkEnabled() && !endsWith(scriptName, "hgSession")) - printf("<TD><A HREF='../cgi-bin/hgSession%s%shgS_doMainPage=1' class='topbar'>Session</A></TD>\n",uiState, theCart ? "&" : "?" ); + printf("<TD><A HREF='../cgi-bin/hgSession%s%shgS_doMainPage=1' class='topbar'>" + "Session</A></TD>\n",uiState, theCart ? "&" : "?" ); #endif /* GBROWSE */ if (!isGsid) printf("<TD><A HREF='../FAQ/' class='topbar'>FAQ</A></TD>"); if (!isGsid) { if (endsWith(scriptName, "hgBlat")) printf("<TD><A HREF='../goldenPath/help/hgTracksHelp.html#BLATAlign'"); else if (endsWith(scriptName, "hgHubConnect")) printf("<TD><A HREF='../goldenPath/help/hgTrackHubHelp.html'"); else if (endsWith(scriptName, "hgText")) printf("<TD><A HREF='../goldenPath/help/hgTextHelp.html'"); else if (endsWith(scriptName, "hgNear")) printf("<TD><A HREF='../goldenPath/help/hgNearHelp.html'"); else if (endsWith(scriptName, "hgTables")) printf("<TD><A HREF='../goldenPath/help/hgTablesHelp.html'"); else if (endsWith(scriptName, "hgGenome")) 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 + printf("<TD style='width:95%%'> </TD></TR></TABLE>\n"); + // last column squeezes other columns left puts("</TD></TR>\n"); #endif if (endsWith(scriptName, "hgGateway") && geoMirrorEnabled()) { // Show an opt-out alert if user is on a host to which user has been automatically redirected (just once, right after they have been redirected) char *source = cgiOptionalString("source"); char *redirect = cgiOptionalString("redirect"); if (source != NULL && redirect != NULL && sameString(redirect, "auto")) { char *domain = cgiServerName(); char *port = cgiServerPort(); // We don't bother maintaining stuff in request URI, because it may contain items like hgsid and other host specific values int newUriSize = 2048; @@ -427,39 +446,42 @@ "</ul>" "</div>" "</TD></TR>\n" , domain, newUri, source ); } } 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" "<div id=firstSection>" " <!--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" + " <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" - " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' CELLPADDING=0><TR><TH HEIGHT=10></TH></TR>\n" + " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' CELLPADDING=0>" + "<TR><TH HEIGHT=10></TH></TR>\n" " <TR><TD WIDTH=10> </TD><TD>\n\n" ); }; webPushErrHandlers(); /* set the flag */ webHeadAlreadyOutputed = TRUE; } /* static void webStartWrapperDetailedInternal() */ void webStartWrapperDetailedArgs(struct cart *theCart, char *db, char *headerText, char *format, va_list args, boolean withHttpHeader, boolean withLogo, boolean skipSectionHeader, boolean withHtmlHeader) /* output a CGI and HTML header with the given title in printf format */ { char textOutBuf[1024]; va_list argscp; @@ -541,40 +563,43 @@ puts("</div>"); } void webNewSection(char* format, ...) /* create a new section on the web page */ { va_list args; va_start(args, format); webEndSection(); puts("<div>"); puts("<!-- +++++++++++++++++++++ START NEW SECTION +++++++++++++++++++ -->"); puts( // TODO: Replace nested tables with CSS (difficulty is that tables are closed elsewhere) "<BR>\n\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" + " <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' class='windowSize'>" ); vprintf(format, args); puts( " </div>\n" - " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' CELLPADDING=0><TR><TH HEIGHT=10></TH></TR>\n" + " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' CELLPADDING=0>" + "<TR><TH HEIGHT=10></TH></TR>\n" " <TR><TD WIDTH=10> </TD><TD>\n\n" ); va_end(args); } void webEndSectionTables() /* Finish with section tables (but don't do /BODY /HTML lik * webEnd does. */ { webEndSection(); puts("</TD></TR></TABLE>\n"); } void webEnd() @@ -1336,56 +1361,62 @@ // a) flushes user's web browser cache when the user visits a GB site whose version has changed since their last visit; // b) enforces the requirement that static files are the same version as the CGIs (something that often fails to happen in mirrors). // (see notes in redmine #3170). // // In dev trees we use mtime to create a pseudo-version; this forces web browsers to reload css/js file when it changes, // so we don't get odd behavior that can be caused by caching of mis-matched javascript and style files in dev trees. // // In either case, the actual file has to have been previously created by running make in the appropriate directory (kent/src/hg/js // or kent/src/hg/htdocs/style). { char baseName[PATH_LEN]; char extension[FILEEXT_LEN]; splitPath(fileName, NULL, baseName, extension); boolean js = sameString(".js",extension); boolean style = !js && sameString(".css",extension); -boolean image = !js && !style && (sameString(".png",extension) || sameString(".jpg",extension) || sameString(".gif",extension)); +boolean image = !js + && !style + && ( sameString(".png",extension) + || sameString(".jpg",extension) + || sameString(".gif",extension)); if(!js && !style) // && !image) NOTE: This code has not been tested on images but should work. errAbort("webTimeStampedLinkToResource: unknown resource type for %s.\n", fileName); // Build and verify directory char *dirName = ""; if (js) dirName = cfgOptionDefault("browser.javaScriptDir", "js"); else if (style) dirName = cfgOptionDefault("browser.styleDir","style"); else if (image) dirName = cfgOptionDefault("browser.styleImagesDir","style/images"); struct dyString *fullDirName = NULL; char *docRoot = hDocumentRoot(); if(docRoot != NULL) fullDirName = dyStringCreate("%s/%s", docRoot, dirName); else // tolerate missing docRoot (i.e. when running from command line) fullDirName = dyStringCreate("%s", dirName); if(!fileExists(dyStringContents(fullDirName))) - errAbort("webTimeStampedLinkToResource: dir: %s doesn't exist.\n", dyStringContents(fullDirName)); + errAbort("webTimeStampedLinkToResource: dir: %s doesn't exist.\n", + dyStringContents(fullDirName)); // build and verify real path to file struct dyString *realFileName = dyStringCreate("%s/%s", dyStringContents(fullDirName), fileName); if(!fileExists(dyStringContents(realFileName))) - errAbort("webTimeStampedLinkToResource: file: %s doesn't exist.\n", dyStringContents(realFileName)); + errAbort("webTimeStampedLinkToResource: file: %s doesn't exist.\n", + dyStringContents(realFileName)); // build and verify link path including timestamp in the form of dir/baseName + timeStamp or CGI Version + ext long mtime = fileModTime(dyStringContents(realFileName)); struct dyString *linkWithTimestamp; if(hIsPreviewHost() || hIsPrivateHost()) linkWithTimestamp = dyStringCreate("%s/%s-%ld%s", dyStringContents(fullDirName), baseName, mtime, extension); else linkWithTimestamp = dyStringCreate("%s/%s-v%s%s", dyStringContents(fullDirName), baseName, CGI_VERSION, extension); if(!fileExists(dyStringContents(linkWithTimestamp))) errAbort("Cannot find correct version of file '%s'; this is due to an installation error\n\nError details: %s does not exist", fileName, dyStringContents(linkWithTimestamp)); // Free up all that extra memory dyStringFree(&realFileName); @@ -1403,46 +1434,46 @@ struct dyString *wrapped = dyStringNew(0); if (js) dyStringPrintf(wrapped,"<script type='text/javascript' SRC='/%s'></script>\n", link); else if (style) dyStringPrintf(wrapped,"<LINK rel='STYLESHEET' href='/%s' TYPE='text/css' />\n", link); else // Will be image, since these are the only three choices allowed dyStringPrintf(wrapped,"<IMG src='/%s' />\n", link); freeMem(link); link = dyStringCannibalize(&wrapped); } return link; } char *webTimeStampedLinkToResourceOnFirstCall(char *fileName, boolean wrapInHtml) -// If this is the first call, will -// Return full path of timestamped link to the requested resource file (js, or css). Free after use. +// If this is the first call, will return full path of timestamped link to the requested +// resource file (js, or css). Free after use. // else returns NULL. Useful to ensure multiple references to the same resource file are not made // NOTE: png, jpg and gif should also be supported but are untested. { static struct hash *includedResourceFiles = NULL; if(!includedResourceFiles) includedResourceFiles = newHash(0); if(hashLookup(includedResourceFiles, fileName)) return NULL; char * link = webTimeStampedLinkToResource(fileName,wrapInHtml); if (link) - hashAdd(includedResourceFiles, fileName, NULL); // Don't hash link, because memory will be freed by caller!!! -return link; + hashAdd(includedResourceFiles, fileName, NULL); // Don't hash link, because +return link; // memory will be freed by caller!!! } boolean webIncludeResourcePrintToFile(FILE * toFile, char *fileName) // Converts fileName to web Resource link and prints the html reference // This only prints and returns TRUE on first call for this resource. // Passing in NULL as the file pointer results in hPrintf call // The reference will be to a link with timestamp. { char *link = webTimeStampedLinkToResourceOnFirstCall(fileName,TRUE); if (link) { if (toFile == NULL) hPrintf("%s",link); else fprintf(toFile,"%s",link);