bb85cad5b5a52f6a5e96f72cbfe681c5c4b863f8
max
Wed Aug 21 22:25:39 2013 -0700
fixing a layout bug, adding cgi param for ensembl to linkout to hgc
diff --git src/hg/hgc/pubs.c src/hg/hgc/pubs.c
index d78f418..dbbeb44 100644
--- src/hg/hgc/pubs.c
+++ src/hg/hgc/pubs.c
@@ -16,42 +16,43 @@
// cgi var to activate debug output
static int pubsDebug = 0;
// global var for printArticleInfo to indicate if article has suppl info
// Most publishers have supp data.
// If they don't have it, we can skip the fileType column in the table
bool pubsHasSupp = TRUE;
// global var for printArticleInfo to indicate if article is elsevier
// If it's elsevier, we print the copyright line
bool pubsIsElsevier = FALSE;
// the article source is used to modify other parts of the page
static char *articleSource;
-// we need the external article PMC Id for yif links
+
+// we need the external article PMC Id for YIF links
static char *extId = NULL;
// section types in mysql table, for all annotations tables
// we note where the hit is located in the document
static char *pubsSecNames[] ={
"header", "abstract",
"intro", "methods",
"results", "discussion",
"conclusions", "ack",
"refs", "unknown" };
-//
+
// whether a checkbox is checked by default, have to correspond to pubsSecNames
static int pubsSecChecked[] ={
1, 1,
1, 1,
1, 1,
1, 0,
0, 1 };
static char *pubsSequenceTable;
/* ------ functions to replace HTML4 tables with HTML5 constructs */
/* Web wrappers incorporating tag, id, and class HTML attributes, to support
* styling and test */
@@ -262,47 +263,55 @@
safef(nameBuf, sizeof(nameBuf), "'%s'", secName);
slAddHead(&names, slNameNew(nameBuf));
}
}
if (names==0)
errAbort("You need to specify at least one article section.");
char *nameListString = slNameListToString(names, ',');
slNameFree(names);
return nameListString;
}
static struct sqlResult *queryMarkerRows(struct sqlConnection *conn, char *markerTable, \
- char *articleTable, char *item, int itemLimit, char *sectionList)
-/* query marker rows from mysql, based on http parameters */
+ char *articleTable, char *item, int itemLimit, char *sectionList, char *artExtIdFilter)
+/* query marker rows from mysql, based on http parameters
+ * optionally filter on sections or just a single article
+ * */
{
char query[4000];
/* Mysql specific setting to make the group_concat function return longer strings */
sqlUpdate(conn, "NOSQLINJ SET SESSION group_concat_max_len = 100000");
+char artFilterSql[4000];
+artFilterSql[0] = 0;
+if (isNotEmpty(artExtIdFilter))
+ safef(artFilterSql, sizeof(artFilterSql), " AND extId='%s' ", artExtIdFilter);
+
// no need to check for illegal characters in sectionList
sqlSafef(query, sizeof(query), "SELECT distinct %s.articleId, url, title, authors, citation, "
"pmid, extId, "
"group_concat(snippet, concat(\" (section: \", section, \")\") SEPARATOR ' (...) ') FROM %s "
"JOIN %s USING (articleId) "
"WHERE markerId='%s' AND section in (%-s) "
+ "%-s"
"GROUP by articleId "
"ORDER BY year DESC "
"LIMIT %d",
- markerTable, markerTable, articleTable, item, sectionList, itemLimit);
+ markerTable, markerTable, articleTable, item, sectionList, artFilterSql, itemLimit);
if (pubsDebug)
printf("%s", query);
struct sqlResult *sr = sqlGetResult(conn, query);
return sr;
}
static void printSectionCheckboxes()
/* show a little form with checkboxes where user can select sections they want to show */
{
// labels to show to user, have to correspond to pubsSecNames
char *secLabels[] ={
@@ -347,66 +356,100 @@
static void printLimitWarning(struct sqlConnection *conn, char *markerTable,
char *item, int itemLimit, char *sectionList)
{
char query[4000];
// no need to check for illegal characters in sectionList
sqlSafef(query, sizeof(query), "SELECT COUNT(*) from %s WHERE markerId='%s' AND section in (%-s) ", markerTable, item, sectionList);
if (sqlNeedQuickNum(conn, query) > itemLimit)
{
printf("This marker is mentioned more than %d times
\n", itemLimit);
printf("The results would take too long to load in your browser and are "
"therefore limited to %d articles.
\n", itemLimit);
}
}
+static void printAddWbr(char *text, int distance)
+/* a crazy hack for firefox/mozilla that is unable to break long words in tables
+ * We need to add a ", snippets);
+ printf("\n");
+ printAddWbr(snippets, 40);
+ printf(" ");
printf("Snippets from Publications:
");
-struct sqlResult *sr = queryMarkerRows(conn, markerTable, articleTable, item, itemLimit, sectionList);
+ }
+struct sqlResult *sr = queryMarkerRows(conn, markerTable, articleTable, item, itemLimit, sectionList, artExtIdFilter);
+
+printf("
", url, title);
printf("%s; ", authors);
printf("%s ", citation);
if (!isEmpty(pmid) && strcmp(pmid, "0")!=0 )
printf(", PMID%s\n", pmid, pmid);
printf("
\n");
if (pubsDebug)
printf("articleId=%s", articleId);
- printf("%s
");
}
+printf("