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("\n");
}
}
else
{
// tolerate missing docRoot (i.e. when running from command line)
// XXXX ????
}
#else
if (isGisaid)
{
- printf("
\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("
\n"); // last column squeezes other columns left
+ printf("
\n");
+ // last column squeezes other columns left
puts("\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 @@
""
""
"\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)
"" "\n"
"
\n"
"
"
" \n"
- "
\n"
- "
\n"
+ "
\n"
+ "
\n"
"
"
);
htmlTextOut(textOutBuf);
puts(
"
\n"
- "
\n"
+ "
"
+ "
\n"
"
\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("");
}
void webNewSection(char* format, ...)
/* create a new section on the web page */
{
va_list args;
va_start(args, format);
webEndSection();
puts("
");
puts("");
puts( // TODO: Replace nested tables with CSS (difficulty is that tables are closed elsewhere)
" \n\n"
" \n"
- "
\n"
- "
\n"
+ "
\n"
+ "
\n"
"
"
);
vprintf(format, args);
puts(
"
\n"
- "
\n"
+ "
"
+ "
\n"
"
\n\n"
);
va_end(args);
}
void webEndSectionTables()
/* Finish with section tables (but don't do /BODY /HTML lik
* webEnd does. */
{
webEndSection();
puts("
\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,"\n", link);
else if (style)
dyStringPrintf(wrapped,"\n", link);
else // Will be image, since these are the only three choices allowed
dyStringPrintf(wrapped,"\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);