LP#1303544 Trim junk from the ISBN in record summary user/dbs/fix_isbn_extra_junk
authorDan Scott <dscott@laurentian.ca>
Mon, 7 Apr 2014 02:43:08 +0000 (22:43 -0400)
committerDan Scott <dscott@laurentian.ca>
Mon, 7 Apr 2014 02:59:39 +0000 (22:59 -0400)
When asserting that we are publishing an ISBN, move the "(pbk.)"
and similar such matter outside of the schema.org <span property="isbn">
element.

See "The walking dead" in the sample dataset for an example.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/templates/opac/parts/misc_util.tt2
Open-ILS/src/templates/opac/parts/record/summary.tt2

index 63b82b4..c2fe31a 100644 (file)
 
         args.isbns = [];
         FOR isbn IN xml.findnodes('//*[@tag="020"]/*[@code="a"]');
-            args.isbns.push(isbn.textContent);
+            args.isbns.push(isbn.textContent.trim);
         END;
 
         args.upcs = [];
         FOR upc IN xml.findnodes('//*[@tag="024"]/*[@code="a"]');
-            args.upcs.push(upc.textContent);
+            args.upcs.push(upc.textContent.trim);
         END;
         args.upc = args.upcs.0; # use first UPC as the default
 
         args.issns = [];
         FOR sub IN xml.findnodes('//*[@tag="022"]/*[@code="a"]');
-            args.issns.push(sub.textContent);
+            args.issns.push(sub.textContent.trim);
         END;
         args.issn = (args.issns.size) ? args.issn.0 : '';
 
index 4a58bec..fffd158 100644 (file)
@@ -154,10 +154,17 @@ IF num_uris > 0;
 
 <h2 id='rdetail_record_details'>[% l("Record details") %]</h2>
 <ul>
-    [%- IF attrs.isbns.0; FOR isbn IN attrs.isbns %]
+    [%- IF attrs.isbns.0;
+          FOR isbn IN attrs.isbns;
+            isbn_extra = '';
+            IF (matches = isbn.match('^(.+?)(\s.+)$'));
+              isbn = matches.0;
+              isbn_extra = matches.1;
+            END;
+    %]
     <li class='rdetail_isbns'>
         <strong class='rdetail_label'>[% l('ISBN:'); %]</strong>
-        <span class='rdetail_value' property='isbn'>[% isbn | html  %]</span>
+        <span class='rdetail_value' property='isbn'>[% isbn | html  %]</span>[% isbn_extra | html %]
     </li>
         [%- END %]
     [%- END %]