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