added project link
[sgn.git] / mason / genomes / Solanum_lycopersicum / publications.mas
blobfd338357998e8519d59f09a5869f4cc7975b672c
1 <& /util/import_javascript.mas, classes=>["CXGN.Effects"] &>
3 <style type="text/css">
5   td.width {
6     width: 60px;
7     color: #AA0000;
8   }
10   tr.author {
11     visibility: collapse;
12   }
14   .publication {
15     margin-bottom: 0.75em;
16   }
18 </style>
21 <script type="text/javascript">
22 function get_author_elements( id_base ) {
23   return {
24       fewer_link: document.getElementById( "fewer_"   + id_base ),
25       all_link:   document.getElementById( "all_"   + id_base ),
26       authors: document.getElementById( "extra_" + id_base )
27  };
29 function authors_on( id_base ) {
30   var stuff = get_author_elements( id_base );
32   stuff.fewer_link.style.display = "inline";
33   stuff.all_link.style.display   = "none";
34   stuff.authors.style.display    = "inline";
36 function authors_off( id_base ) {
37   var stuff = get_author_elements( id_base );
39   stuff.fewer_link.style.display = "none";
40   stuff.all_link.style.display   = "inline";
41   stuff.authors.style.display    = "none";
44 </script>
46 <& /page/page_title.mas, title => "Tomato Genome Publications" &>
48 <%args>
49   $schema
50 </%args>
51 <%once>
52     use CXGN::Page::FormattingHelpers;
53     use List::MoreUtils qw/uniq/;
54 </%once>
55 <%init>
57 my $pubmed = $schema->resultset('General::Db')
58                     ->find({ name => 'PMID' });
60 ### get all publications from pubprop database, then index them by pub year
61 my @pubs =
62     $schema->resultset('Cv::Cvterm')
63            ->search({name => 'tomato genome publication'})
64            ->search_related('pubprops', {})
65            ->search_related('pub', {}, 
66                             { prefetch => { pub_dbxrefs => 'dbxref' },
67                             }
68                            );
70 # index the publications in a hash by year
71 my %pubs_by_year;
72 for my $pub (@pubs) {
73   push @{ $pubs_by_year{ $pub->pyear } }, $pub;
75 </%init>
77 <&| /page/info_section.mas, title=>'Publications', collapsible => 0, empty_message => 'temporarily unavailable' &>
79 %  # for each year, print out the pubs associated with it
80 %   my @sorted_years =  sort {$b <=> $a} keys %pubs_by_year; 
81 %   for my $year ( @sorted_years ) {
82 %     my $pubs = $pubs_by_year{$year};
83       <&| /page/info_section.mas, title         => $year,
84                                   subtitle      => @$pubs.' publication'.(@$pubs > 1 ? 's' : ''),
85                                   collapsible   => 1,
86                                   collapsed     => ($year == $sorted_years[0] || $year == $sorted_years[1] ? 0 : 1),
87                                   is_subsection => 1,
88          &>
90 %        # render each of the publications for this year
91 %        for my $pub ( @$pubs ) {
92             <& .publication, pub => $pub, pubmed => $pubmed &>
93 %        }
94       </&>
95 %   }
96 </&>
99 % ############ SUBCOMPONENTS #################
100 % # subcomponent that displays a publication
101 <%def .publication >
102 <%args>
103   $pub
104   $pubmed
105 </%args>
107 <%perl>
109     #---getting authors - if the list is too long, only show the first 10,
110     #---the rest of the authors are shown once a link is clicked
111     my @authors = $pub->search_related('pubauthors', {}, { order_by => 'rank' });
112     my $names =
113           join ', ',
114           map $_->givennames." ".$_->surname,
115           grep $_,
116           @authors[ 0..9 ];
118     my $extra_names =
119           join ', ',
120           map $_->givennames." ".$_->surname,
121           grep $_,
122           @authors[ 10..$#authors ];
124     $names .= ', ' if $extra_names;
126 </%perl>
128 <table class="publication">
129 <tr>
130   <td><a style="color:black" 
131   target="_blank" 
132   href="/publication/<% $pub->pub_id %>/view">
133   <b><% $pub->title | h %></b>
134   </a>
135   </td>
136 </tr>
137 <tr>
138   <td>
139     <table>
140       <tr>
141         <td class="width">Author(s):</td>
142         <td><% $names | h %>
143 % if( $extra_names ){
144 %   my $id = $pub->pub_id;
145           <span style="display: none" id="extra_<% $id %>"><% $extra_names |h %></span>
146           <a style="display: none" id="fewer_<% $id %>" href="javascript:authors_off(<% $id %>)">show fewer</a>
147           <a id="all_<% $id %>" href="javascript:authors_on(<% $id %>)">show all</a>
148 %  }
149         </td>
150       </tr>
151       <tr>
152         <td class="width">Journal:</td>
153         <td><% $pub->series_name | h %></td>
154       </tr>
155       <tr>
156         <td class="width">Volume:</td>
157         <td><% $pub->volume | h %></td>
158       </tr>
159 % if( $pub->issue ) {
160       <tr>
161         <td class="width">Issue:</td>
162         <td><% $pub->issue | h %></td>
163       </tr>
164 % }
165       <tr>
166         <td class="width">Pages:</td>
167         <td><% $pub->pages | h %></td>
168       </tr>
169 % if( $pubmed
170 %      and  my $pm_dbx = $pub->search_related('pub_dbxrefs', {})
171 %                            ->search_related('dbxref', { db_id => $pubmed->db_id } )
172 %                            ->first
173 %    ) {
174       <tr>
175         <td class="width">Pubmed:</td>
176         <td><a target="_blank"
177         href="http://www.ncbi.nlm.nih.gov/sites/pubmed/<% $pm_dbx->accession %>">
178         Pubmed ID <% $pm_dbx->accession %>
179         </a>
180         </td>
181       </tr>
182 % }
183     </table>
184   </td>
185 </tr>
186 </table>
188 </%def>