Make unexpanded KWIC metadata fields configurable by request URL

Resolves #275

Change-Id: I432ee8b2d6091012c8fa7138a113527644398e26
diff --git a/templates/match.html.ep b/templates/match.html.ep
index 775008c..4d3cacf 100644
--- a/templates/match.html.ep
+++ b/templates/match.html.ep
@@ -12,14 +12,19 @@
     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 ($show_sigle, $flip) = ('', stash('flip') // 'flip');
-% if ($text_sigle ne (stash('last_sigle') // '')) {
-%   $show_sigle = $text_sigle;
-%   stash(last_sigle => $text_sigle);
+% 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);
 % }  
-  <div class="meta <%= $flip %>"><%= $show_sigle %></div>
+% 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
diff --git a/templates/partial/header.html.ep b/templates/partial/header.html.ep
index 5a2189a..da00042 100644
--- a/templates/partial/header.html.ep
+++ b/templates/partial/header.html.ep
@@ -36,6 +36,9 @@
       %= select_field 'ql', [[loc('QL_poliqarp') => 'poliqarp'], [loc('QL_cosmas2') => 'cosmas2'], [loc('QL_annis') => 'annis'], [loc('QL_cqp') => 'cqp'], [loc('QL_cql') => 'cql'], [loc('QL_fcsql') => 'fcsql']], id => 'ql-field'
     </span>
     <div class="button right">
+      % if (my @vfields = @{$c->req->every_param('vfields') || []}) {
+      %= hidden_field 'vfields' => join(',', @vfields)
+      % }
       % param(cutoff => 1) unless param 'q';
       %= check_box cutoff => 1, id => 'q-cutoff-field', class => 'checkbox'
       <label for="q-cutoff-field" title="<%= loc('glimpse_desc') %>"><span id="glimpse"></span><%= loc('glimpse') %></label>