6b6ecc50247ef843cd2ad6d29f8dcd63ac87f54d
max
Sat Sep 7 14:32:22 2013 -0700
various small changes to pubs tracks to be able to show bing.com crawl results
diff --git src/hg/hgc/pubs.c src/hg/hgc/pubs.c
index 07a6a9e..208f8fa 100644
--- src/hg/hgc/pubs.c
+++ src/hg/hgc/pubs.c
@@ -43,32 +43,32 @@
"refs", "supplement", "unknown" };
// labels to show to user, have to correspond to pubsSecNames
static char *secLabels[] ={
"Title", "Abstract",
"Introduction", "Methods",
"Results", "Discussion",
"Conclusions", "Acknowledgements",
"References", "Supplement", "Undetermined section (e.g. for a brief communication)" };
// 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 };
+ 1, 1,
+ 1, 1, 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 */
/* Suffix -S for "function accepts style parameter"
* Suffix -C for "function accepts class parameter"
* Suffix -CI for "function accepts class and id parameter"
*
* Some functions are commented out because they are not yet used.
*/
@@ -430,47 +430,64 @@
/* print a two-line description of article */
char *articleId = row[0];
char *url = row[1];
char *title = row[2];
char *authors = row[3];
char *citation = row[4];
char *year = row[5];
char *pmid = row[6];
url = mangleUrl(url);
printf("%s
", url, title);
// cut author string at 40 chars, like scholar
printf("");
if (strlen(authors)>40)
{
authors[60] = 0;
- printf("%s... - ", authors);
+ printf("%s... ", authors);
}
-else
- printf("%s - ", authors);
+else if (!isEmpty(authors))
+ printf("%s ", authors);
// first word of citation is journal name
char *words[10];
-chopCommas(citation, words);
-char *journal = words[0];
+int wordCount = chopCommas(citation, words);
+char *journal = NULL;
+if (wordCount!=0)
+ journal = words[0];
-printf("%s - %s ", year, journal);
+// optional: print the little gray line with author, journal, year info
+bool didPrint = FALSE;
+printf("");
+if (year!=NULL && differentWord(year, "0"))
+ {
+ printf("%s", year);
+ didPrint = TRUE;
+ }
+if (!isEmpty(journal))
+ {
+ printf(" - %s ", journal);
+ didPrint = TRUE;
+ }
if (!isEmpty(pmid) && strcmp(pmid, "0")!=0 )
+ {
printf(", PMID%s\n", pmid, pmid);
-printf("\n");
-
-printf("\n");
+ didPrint = TRUE;
+ }
+printf("\n");
+if (didPrint)
printf("
\n");
+
if (pubsDebug)
printf("articleId=%s", articleId);
return articleId;
}
static void printSnippets(struct sqlResult *srSnip)
{
char **snipRow;
struct hash *doneSnips = newHash(0); // avoid printing a sentence twice
int snipCount = 0;
struct slPair *secSnips = NULL;
// add all pairs to the list, remove duplicated snippets (ignore all lowercase chars)
while ((snipRow = sqlNextRow(srSnip)) != NULL)
@@ -567,30 +584,38 @@
}
static char *urlToLogoUrl(char *pubsArticleTable, char *articleId, char *urlOrig)
/* return a string with relative path of logo for publisher given the url of
* fulltext or a table/articleId, has to be freed
*/
{
struct sqlConnection *conn = hAllocConn(database);
char *pubCode = NULL;
if (hHasField("hgFixed", pubsArticleTable, "publisher"))
{
char query[4000];
sqlSafef(query, sizeof(query), "SELECT publisher from %s where articleId=%s",
pubsArticleTable, articleId);
pubCode = sqlQuickString(conn, query);
+ // if no publisher is specified, we use the source (e.g. bing, pmc, elsevier, etc)
+ // to find the logo
+ if (isEmpty(pubCode))
+ {
+ sqlSafef(query, sizeof(query), "SELECT source from %s where articleId=%s",
+ pubsArticleTable, articleId);
+ pubCode = sqlQuickString(conn, query);
+ }
}
else
{
// get top-level domain url if not publisher field
char url[1024];
memcpy(url, urlOrig, sizeof(url));
char *slashParts[20];
// split http://www.sgi.com/test -> to [http:,www.sgi.com,test]
int partCount = chopString(url, "/", slashParts, ArraySize(slashParts));
if (partCount<3)
return NULL;
// split www.sgi.com to [www,sgi,com]
char *dotParts[20];
partCount = chopString(slashParts[1], ".", dotParts, ArraySize(dotParts));
if (partCount<3)
@@ -647,31 +672,30 @@
// authors title
printf("
%s
\n", authors); // // logo of publisher char *logoUrl = urlToLogoUrl(pubsArticleTable, articleId, url); if (logoUrl) printf("%s", cit); if (strlen(pmid)!=0 && strcmp(pmid, "0")) printf(", PMID%s\n", pmid, pmid); printf("
\n"); printf("%s
\n", abstract); if (pubsIsElsevier) printf("Copyright 2012 Elsevier B.V. All rights reserved.
"); sqlFreeResult(&sr); return articleId; } static struct hash *getSeqIdHash(struct sqlConnection *conn, char *trackTable, \ char *articleId, char *item, char *seqName, int start)