]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/record/authors.tt2
448fdf829082b4a79f00698256057a7a256a45ac
[working/Evergreen.git] / Open-ILS / src / templates / opac / parts / record / authors.tt2
1 [%-  
2
3 PROCESS "opac/parts/relators.tt2";
4
5 authors = [
6     {
7         type => 'author', 
8         label => l('Author'),
9         xpath => '//*[@tag="100"]|//*[@tag="110"]|//*[@tag="111"]'
10     }, {
11         type => 'added', 
12         label => l('Added Author'),
13         xpath => '//*[@tag="700"]|//*[@tag="710"]|//*[@tag="711"]'
14     }, {
15         type => 'cast', 
16         label => l('Cast'),
17         xpath => '//*[@tag="508"]'
18     }, {
19         type => 'notes', 
20         label => l('Author Notes: '),
21         xpath => '' # Comes from added content...
22     }
23 ];
24
25 BLOCK build_author_links;
26     FOR node IN ctx.marc_xml.findnodes(xpath);
27         term = '';
28         qterm = '';
29         iprop = '';
30         tlabel = '';
31         FOR subfield IN node.childNodes;
32             NEXT UNLESS subfield.nodeName == "subfield";
33             code = subfield.getAttribute('code');
34             IF code == '4';
35                 relcode = subfield.textContent.substr(0,3);
36                 tlabel = relators.$relcode || label;
37             END;
38             NEXT UNLESS code.match('[a-z]');
39             sf = subfield.textContent | html;
40             term = term _ ' ' _ sf;
41             IF code.match('[acdq]');
42                 sf_raw = subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', ' ');
43                 qterm = qterm _ ' ' _ sf_raw;
44             END;
45         END;
46         url = mkurl(ctx.opac_root _ '/results', {query => qterm, qtype => 'author'}, ['page', 'expand']);
47         author_type = (tlabel || label) | html;
48         
49         # schema.org changes
50         IF type == 'author';
51             iprop = ' itemprop="accountablePerson"';
52         ELSIF type == 'added';
53             iprop = ' itemprop="contributor"';
54         END;
55         '<a href="' _ url _ '"' _ iprop _ '>' _ term.replace('^\s+', '') _ '</a> (' _ author_type _ '). ';
56     END;
57 END;
58 %]
59
60 <div class='rdetail_authors_div'>
61 [%- FOREACH author IN authors;
62     NEXT UNLESS author.xpath; 
63     links = PROCESS build_author_links(
64         xpath=author.xpath, label=author.label, type=author.type
65     );
66     IF links.match('\S') %]
67     <span class='rdetail-author-div'>[% links %]</span>
68     [%- END %]
69 [%- END %]
70 </div>
71
72