From aabc654ef7b6c5a6740e95b9580223726a86e43a Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Thu, 18 Jan 2007 18:11:19 +0000 Subject: [PATCH] Extended simpletarget model with target names. Added names to target facet and detailed display. --- etc/bibs.pz | 21 ++++++++++----------- src/http_command.c | 8 +++++--- src/pazpar2.c | 18 ++++++++++++++---- src/pazpar2.h | 4 +++- www/demo/search.js | 9 +++++++-- 5 files changed, 39 insertions(+), 21 deletions(-) diff --git a/etc/bibs.pz b/etc/bibs.pz index fd646dc..c148bd8 100644 --- a/etc/bibs.pz +++ b/etc/bibs.pz @@ -1,11 +1,10 @@ -target amicus.nlc-bnc.ca/NL -target melvyl.cdlib.org/cdl90 -target z3950.loc.gov:7090/voyager -target library2.mcmaster.ca/MORRIS -target info.library.mun.ca:2200/innopac -target 137.122.27.60:210/innopac -target z3950.rlg.org/BIB -target 141.117.13.11:210/innopac -target siris-libraries.si.edu -target tpldynix.torontopubliclibrary.ca:210/server -target sirsi.library.utoronto.ca:2200/UNICORN +target amicus.nlc-bnc.ca/NL;National Libray of Canada +target melvyl.cdlib.org/cdl90;MELVYL +target z3950.loc.gov:7090/voyager;Library of Congress +target library2.mcmaster.ca/MORRIS;McMaster University +target info.library.mun.ca:2200/innopac;Memorial University +target 137.122.27.60:210/innopac;University of Ottowa +target z3950.rlg.org/BIB;RLG +target 141.117.13.11:210/innopac;Ryerson University +target tpldynix.torontopubliclibrary.ca:210/server;Toronto Public +target sirsi.library.utoronto.ca:2200/UNICORN;University of Toronto diff --git a/src/http_command.c b/src/http_command.c index 40a9a28..f304e61 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,5 +1,5 @@ /* - * $Id: http_command.c,v 1.25 2007-01-18 16:21:23 quinn Exp $ + * $Id: http_command.c,v 1.26 2007-01-18 18:11:19 quinn Exp $ */ #include @@ -168,7 +168,7 @@ static void targets_termlist(WRBUF wrbuf, struct session *se, int num) for (i = 0; i < count && i < num && ht[i].hits > 0; i++) { wrbuf_puts(wrbuf, "\n\n"); - wrbuf_printf(wrbuf, "%s\n", ht[i].id); + wrbuf_printf(wrbuf, "%s\n", ht[i].name); wrbuf_printf(wrbuf, "%d\n", ht[i].hits); wrbuf_printf(wrbuf, "%s\n", ht[i].state); wrbuf_printf(wrbuf, "%d\n", ht[i].diagnostic); @@ -309,7 +309,9 @@ static void write_metadata(WRBUF w, struct conf_service *service, static void write_subrecord(struct record *r, WRBUF w, struct conf_service *service) { - wrbuf_printf(w, "\n", r->client->database->url); + wrbuf_printf(w, "\n", + r->client->database->url, + r->client->database->name ? r->client->database->name : ""); write_metadata(w, service, r->metadata, 1); wrbuf_puts(w, "\n"); } diff --git a/src/pazpar2.c b/src/pazpar2.c index f23e608..3a696c6 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.43 2007-01-18 16:21:23 quinn Exp $ */ +/* $Id: pazpar2.c,v 1.44 2007-01-18 18:11:19 quinn Exp $ */ #include #include @@ -1060,19 +1060,24 @@ void load_simpletargets(const char *fn) while (fgets(line, 255, f)) { char *url, *db; + char *name; struct host *host; struct database *database; if (strncmp(line, "target ", 7)) continue; + line[strlen(line) - 1] = '\0'; + + if ((name = strchr(line, ';'))) + *(name++) = '\0'; + url = line + 7; - url[strlen(url) - 1] = '\0'; - yaz_log(YLOG_DEBUG, "Target: %s", url); if ((db = strchr(url, '/'))) *(db++) = '\0'; else db = "Default"; + yaz_log(YLOG_LOG, "Target: %s, '%s'", url, db); for (host = hosts; host; host = host->next) if (!strcmp(url, host->hostport)) break; @@ -1125,6 +1130,10 @@ void load_simpletargets(const char *fn) strcpy(database->url, url); strcat(database->url, "/"); strcat(database->url, db); + if (name) + database->name = xstrdup(name); + else + database->name = 0; database->databases = xmalloc(2 * sizeof(char *)); database->databases[0] = xstrdup(db); @@ -1363,7 +1372,8 @@ struct hitsbytarget *hitsbytarget(struct session *se, int *count) *count = 0; for (cl = se->clients; cl; cl = cl->next) { - strcpy(res[*count].id, cl->database->host->hostport); + res[*count].id = cl->database->url; + res[*count].name = cl->database->name; res[*count].hits = cl->hits; res[*count].records = cl->records; res[*count].diagnostic = cl->diagnostic; diff --git a/src/pazpar2.h b/src/pazpar2.h index 85ebd58..ec54751 100644 --- a/src/pazpar2.h +++ b/src/pazpar2.h @@ -66,6 +66,7 @@ struct host { struct database { struct host *host; char *url; + char *name; char **databases; int errors; struct conf_queryprofile *qprofile; @@ -165,7 +166,8 @@ struct statistics { }; struct hitsbytarget { - char id[256]; + char *id; + char *name; int hits; int diagnostic; int records; diff --git a/www/demo/search.js b/www/demo/search.js index 6762753..b7b280b 100644 --- a/www/demo/search.js +++ b/www/demo/search.js @@ -1,4 +1,4 @@ -/* $Id: search.js,v 1.41 2007-01-18 17:42:39 quinn Exp $ +/* $Id: search.js,v 1.42 2007-01-18 18:11:19 quinn Exp $ * --------------------------------------------------- * Javascript container */ @@ -329,7 +329,12 @@ function paint_subrecord(node) { var table = document.createElement('table'); var zurl = node.getAttribute('id'); - var tr = paint_details_tr('Source', document.createTextNode(zurl)); + var name = node.getAttribute('name'); + var tr; + if (name) + tr = paint_details_tr('Source', document.createTextNode(name)); + else + tr = paint_details_tr('Source', document.createTextNode(zurl)); table.appendChild(tr); paint_data_elements(table, node); return table; -- 1.7.10.4