]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/parts/record/authors.tt2
TPAC: Fine-grained credits in record details
[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_raw = subfield.textContent;
40             sf = subfield.textContent | html;
41             term = term _ ' ' _ sf;
42             qterm = qterm _ ' ' _ sf_raw;
43         END;
44         url = mkurl(ctx.opac_root _ '/results', {query => qterm, qtype => 'author'}, ['page', 'expand']);
45         author_type = (tlabel || label) | html;
46         
47         # schema.org changes
48         IF type == 'author';
49             iprop = ' itemprop="accountablePerson"';
50         ELSIF type == 'added';
51             iprop = ' itemprop="contributor"';
52         END;
53         '<a href="' _ url _ '"' _ iprop _ '>' _ term.replace('^\s+', '') _ '</a> (' _ author_type _ '). ';
54     END;
55 END;
56 %]
57
58 <div class='rdetail_authors_div'>
59 [%- FOREACH author IN authors;
60     NEXT UNLESS author.xpath; 
61     links = PROCESS build_author_links(
62         xpath=author.xpath, label=author.label, type=author.type
63     );
64     IF links.match('\S') %]
65     <span class='rdetail-author-div'>[% links %]</span>
66     [%- END %]
67 [%- END %]
68 </div>
69
70