From: Sebastian Hammer Date: Thu, 18 Jan 2007 16:21:22 +0000 (+0000) Subject: Dsiplaying sub-records X-Git-Tag: stable.27032007~60 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=bf7d0afdd97bd8cb1ae2d560d40fe4d84b96ef48;p=pazpar2-moved-to-github.git Dsiplaying sub-records --- diff --git a/etc/bibs.pz b/etc/bibs.pz index bafdf1c..fd646dc 100644 --- a/etc/bibs.pz +++ b/etc/bibs.pz @@ -2,7 +2,6 @@ target amicus.nlc-bnc.ca/NL target melvyl.cdlib.org/cdl90 target z3950.loc.gov:7090/voyager target library2.mcmaster.ca/MORRIS -target melvyl.cdlib.org/CDL90 target info.library.mun.ca:2200/innopac target 137.122.27.60:210/innopac target z3950.rlg.org/BIB diff --git a/etc/marc21.xsl b/etc/marc21.xsl index e99b634..047200b 100644 --- a/etc/marc21.xsl +++ b/etc/marc21.xsl @@ -15,7 +15,7 @@ - + diff --git a/src/http_command.c b/src/http_command.c index 86c67d4..40a9a28 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -1,5 +1,5 @@ /* - * $Id: http_command.c,v 1.24 2007-01-17 15:27:34 quinn Exp $ + * $Id: http_command.c,v 1.25 2007-01-18 16:21:23 quinn Exp $ */ #include @@ -307,12 +307,20 @@ 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); + write_metadata(w, service, r->metadata, 1); + wrbuf_puts(w, "\n"); +} + static void cmd_record(struct http_channel *c) { struct http_response *rs = c->response; struct http_request *rq = c->request; struct http_session *s = locate_session(rq, rs); struct record_cluster *rec; + struct record *r; struct conf_service *service = global_parameters.server->service; char *idstr = http_argbyname(rq, "id"); int id; @@ -334,6 +342,8 @@ static void cmd_record(struct http_channel *c) wrbuf_puts(c->wrbuf, "\n"); wrbuf_printf(c->wrbuf, "%d", rec->recid); write_metadata(c->wrbuf, service, rec->metadata, 1); + for (r = rec->records; r; r = r->next) + write_subrecord(r, c->wrbuf, service); wrbuf_puts(c->wrbuf, "\n"); rs->payload = nmem_strdup(c->nmem, wrbuf_buf(c->wrbuf)); http_send_response(c); diff --git a/src/pazpar2.c b/src/pazpar2.c index a0625e1..f23e608 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.42 2007-01-18 14:22:25 quinn Exp $ */ +/* $Id: pazpar2.c,v 1.43 2007-01-18 16:21:23 quinn Exp $ */ #include #include @@ -518,6 +518,7 @@ static struct record *ingest_record(struct client *cl, Z_External *rec) res = nmem_malloc(se->nmem, sizeof(struct record)); res->next = 0; + res->client = cl; res->metadata = nmem_malloc(se->nmem, sizeof(struct record_metadata*) * service->num_metadata); memset(res->metadata, 0, sizeof(struct record_metadata*) * service->num_metadata); @@ -588,11 +589,13 @@ static struct record *ingest_record(struct client *cl, Z_External *rec) newm->next = 0; if (md->type == Metadata_type_generic) { - char *p; - newm->data.text = nmem_strdup(se->nmem, value); - for (p = newm->data.text + strlen(newm->data.text) - 1; - p > newm->data.text && strchr(" ,/.", *p); p--) - *p = '\0'; + char *p, *pe; + for (p = value; *p && isspace(*p); p++) + ; + for (pe = p + strlen(p) - 1; + pe > p && strchr(" ,/.:([", *pe); pe--) + *pe = '\0'; + newm->data.text = nmem_strdup(se->nmem, p); } else if (md->type == Metadata_type_year) diff --git a/www/demo/search.js b/www/demo/search.js index ee5e723..b08450d 100644 --- a/www/demo/search.js +++ b/www/demo/search.js @@ -1,4 +1,4 @@ -/* $Id: search.js,v 1.38 2007-01-17 17:24:44 quinn Exp $ +/* $Id: search.js,v 1.39 2007-01-18 16:21:23 quinn Exp $ * --------------------------------------------------- * Javascript container */ @@ -224,6 +224,14 @@ function displayname(name) return 'Publisher'; else if (name == 'md-url') return 'URL'; + else if (name == 'md-title') + return '@'; + else if (name == 'md-id') + return 'Local ID'; + else if (name == 'recid') + return '@'; + else if (name == 'location') + return '@'; else return name; } @@ -246,7 +254,7 @@ function paint_details_tr(name, dn) var dname = displayname(name); var ln = create_element('b', dname); var tln = document.createElement('td'); - tln.setAttribute('width', 70); + tln.setAttribute('width', 90); tln.setAttribute('valign', 'top'); tln.appendChild(ln); var tr = document.createElement('tr'); @@ -255,17 +263,12 @@ function paint_details_tr(name, dn) return tr; } -function paint_details(body, xml) +function paint_data_elements(target, node) { - // This is some ugly display code. Replace with your own ting o'beauty - clear_cell(body); - //body.appendChild(document.createElement('br')); - var nodes = xml.childNodes[0].childNodes; - var i; - var table = document.createElement('table'); - table.setAttribute('cellpadding', 2); + var nodes = node.childNodes; var dn = 0; var lastname = ''; + var i; for (i = 0; i < nodes.length; i++) { if (nodes[i].nodeType != 1) @@ -273,17 +276,21 @@ function paint_details(body, xml) var name = nodes[i].nodeName; if (name == 'recid' || name == 'md-title') continue; - if (name != lastname) + if (name != lastname && lastname != 'location') { if (dn) { var tr = paint_details_tr(lastname, dn); - table.appendChild(tr); + target.appendChild(tr); } dn = document.createElement('td'); lastname = name; } - + if (name == 'location') + { + target.appendChild(paint_details_tr('Location', paint_subrecord(nodes[i]))); + continue; + } if (!nodes[i].childNodes[0]) continue; var value = nodes[i].childNodes[0].nodeValue; @@ -311,11 +318,29 @@ function paint_details(body, xml) nv = document.createTextNode(value); dn.appendChild(nv); } - if (dn) + if (dn && lastname != 'location') { var tr = paint_details_tr(lastname, dn); - table.appendChild(tr); + target.appendChild(tr); } +} + +function paint_subrecord(node) +{ + var table = document.createElement('table'); + var zurl = node.getAttribute('id'); + var tr = paint_details_tr('Source', document.createTextNode(zurl)); + paint_data_elements(table, node); + table.appendChild(tr); + return table; +} + +function paint_details(body, xml) +{ + clear_cell(body); + var table = document.createElement('table'); + table.setAttribute('cellpadding', 2); + paint_data_elements(table, xml.childNodes[0]); body.appendChild(table); body.style.display = 'inline'; }