blob: 4d3cacfb9ebb663970fa901fbd2649544f78055b [file] [log] [blame]
% use Mojo::JSON qw/encode_json/;
% my $match = stash('match') || {};
% my %match_data = %$match;
% delete @match_data{qw/snippet startMore endMore field/};
% my $text_sigle = $match->{textSigle} // join('/', $match->{corpusID}, $match->{docID}, $match->{textID});
% my $id = $text_sigle . '#' . $match->{matchID};
% # Legacy:
% my $layer_infos = $match->{layerInfos} // $match->{layerInfo} // 'cnx/c=spans corenlp/ne=tokens corenlp/p=tokens mate/l=tokens mate/m=tokens mate/p=tokens opennlp/p=tokens tt/l=tokens tt/p=tokens xip/c=spans';
<li data-match-id="<%= $match->{matchID} %>"
data-text-sigle="<%= $text_sigle %>"
data-available-info="<%= $layer_infos %>"
data-info="<%== b(encode_json(\%match_data))->decode->xml_escape %>"
id="<%= $id %>"<% if (current_route eq 'match') { %> class="active"<% } =%>>
%# This should be done using JavaScript
% my @vfields_fields = @{stash('vfields_fields')};
% my $is_new = ($text_sigle ne (stash('last_text_sigle') // ''));
% my $flip = stash('flip') // 'flip';
% if ($is_new) {
% stash(last_text_sigle => $text_sigle);
% $flip = $flip eq 'flip' ? 'flop' : 'flip';
% stash(flip => $flip);
% }
% foreach my $field (@vfields_fields) {
% my $info = match_field($match, $field);
% my $val = ($is_new && defined $info->{raw} && $info->{raw} ne '') ? $info->{html} : '';
<div class="meta <%= $flip %><%= $info->{type} ? " type-" . $info->{type} : '' %>"><% if ($val ne '') { %><span><%== $val %></span><% } %></div>
% }
<div class="match-main">
<div class="match-wrap">
%# --- Snippet
<div class="snippet<%= $match->{startMore} ? ' startMore' : '' %><%= $match->{endMore} ? ' endMore' : '' %>"><%== $match->{snippet} %></div>
</div>
</div>
%# -- Reference string
<p class="ref">\
<% if ($match->{title}) { %><strong><%= $match->{title} %></strong><% }; %>\
<%= $match->{author} ? ' ' . loc('by') . ' ' . $match->{author} : '' %>\
% if ($match->{pubDate} || ($match->{pages} && ref $match->{pages} eq 'ARRAY')) {
(\
% if ($match->{pubDate}) {
<time datetime="<%= $match->{pubDate} %>"><%= $match->{pubDate} %></time>\
% };
% if ($match->{pages}) {
% if ($match->{pubDate}) {
, \
% };
% if (@{$match->{pages}} == 1) {
<span class="pages"><%=loc 'page_sg' %> <%= $match->{pages}->[0] %></span>\
% } else {
<span class="pages"><%=loc 'page_pl' %> <%= $match->{pages}->[0] %>&ndash;<%= $match->{pages}->[-1] %></span>\
% };
% };
) \
% };
<span class="sigle">[<%= $text_sigle %>]</span> \
</p>
</li>