]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/record/authors.tt2
b52aea3a1594d044f8236096d8a0c63b65983b93
[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         graphics = [];
32         FOR subfield IN node.childNodes;
33             NEXT UNLESS subfield.nodeName == "subfield";
34             code = subfield.getAttribute('code');
35             IF code == '4';
36                 relcode = subfield.textContent.substr(0,3);
37                 tlabel = relators.$relcode || label;
38             END;
39             IF code == '6';
40                linked_fields = [subfield.textContent()];
41                target_field = node.getAttribute('tag');
42                get_linked_880s;
43             END;
44             NEXT UNLESS code.match('[a-z]');
45             sf = subfield.textContent | html;
46             term = term _ ' ' _ sf;
47             IF code.match('[acdq]');
48                 sf_raw = subfield.textContent.replace('[#"^$\+\-,\.:;&|\[\]()]', ' ');
49                 qterm = qterm _ ' ' _ sf_raw;
50             END;
51         END;
52         url = mkurl(ctx.opac_root _ '/results', {query => qterm, qtype => 'author'}, ['page', 'expand']);
53         author_type = (tlabel || label) | html;
54         
55         # schema.org changes
56         IF type == 'author';
57             iprop = ' itemprop="accountablePerson"';
58         ELSIF type == 'added';
59             iprop = ' itemprop="contributor"';
60         END;
61         '<a href="' _ url _ '"' _ iprop _ '>' _ term.replace('^\s+', '') _ '</a>';
62         FOREACH link880 IN graphics;
63             diratt = '';
64             IF link880.dir;
65                 diratt = ' dir="' _ link880.dir _ '"';
66             END;
67             ' <span class="graphic880"' _ diratt _ '>';
68             link880.value | html;
69             '</span>';
70         END;
71         ' (' _ author_type _ '). ';
72     END;
73 END;
74 %]
75
76 <div class='rdetail_authors_div'>
77 [%- FOREACH author IN authors;
78     NEXT UNLESS author.xpath; 
79     links = PROCESS build_author_links(
80         xpath=author.xpath, label=author.label, type=author.type
81     );
82     IF links.match('\S') %]
83     <span class='rdetail-author-div'>[% links %]</span>
84     [%- END %]
85 [%- END %]
86 </div>
87
88