You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by eh...@apache.org on 2014/12/27 02:11:48 UTC

svn commit: r1648030 - in /lucene/dev/trunk/solr/contrib/velocity/src/resources: ./ velocity/

Author: ehatcher
Date: Sat Dec 27 01:11:47 2014
New Revision: 1648030

URL: http://svn.apache.org/r1648030
Log:
SOLR-6779: add trimmed /browse templates to Velocity contrib JAR, making them available to any VrW using system

Added:
    lucene/dev/trunk/solr/contrib/velocity/src/resources/
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/VM_global_library.vm
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/_default.vm
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/browse.vm
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/debug.vm
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/error.vm
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/facets.vm
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/footer.vm
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/head.vm
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/hit.vm
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/layout.vm
    lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/results_list.vm

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/VM_global_library.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/VM_global_library.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/VM_global_library.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/VM_global_library.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,82 @@
+#**
+ *  Global macros used by other templates.
+ *  This file must be named VM_global_library.vm
+ *  in order for Velocity to find it.
+ *#
+
+#macro(param $key)$request.params.get($key)#end
+
+#macro(url_root)/solr#end
+
+## TODO: s/url_for_solr/url_for_core/ and s/url_root/url_for_solr/
+#macro(core_name)$request.core.name#end
+#macro(url_for_solr)#{url_root}#if($request.core.name != "")/$request.core.name#end#end
+#macro(url_for_home)#url_for_solr/browse#end
+
+#macro(q)&q=$!{esc.url($params.get('q'))}#end
+
+#macro(fqs $p)#foreach($fq in $p)#if($velocityCount>1)&#{end}fq=$esc.url($fq)#end#end
+
+#macro(debug)#if($request.params.get('debugQuery'))&debugQuery=true#end#end ## TODO: leverage actual debug mode setting, or at least also support debug=all/query/etc
+
+#macro(sort $p)#if($p)#foreach($s in $p)&sort=$esc.url($s)#end#end#end
+
+#macro(lensNoQ)?#if($request.params.getParams('fq') and $list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end#sort($request.params.getParams('sort'))#debug#end
+#macro(lens)#lensNoQ#q#end
+
+#macro(url_for_lens)#{url_for_home}#lens#end
+
+#macro(url_for_start $start)#url_for_home#lens&start=$start#end
+
+#macro(url_for_filters $p)#url_for_home?#q#if($list.size($p) > 0)&#fqs($p)#end#debug#end
+
+#macro(url_for_nested_facet_query $field)#url_for_home#lens&fq=$esc.url($field)#end
+
+## TODO: convert to use {!raw f=$field}$value (with escaping of course)
+#macro(url_for_facet_filter $field $value)#url_for_home#lens&fq=#if($value!=$null)$esc.url($field):%22$esc.url($value)%22#else-$esc.url($field):[*+TO+*]#end#end
+
+#macro(url_for_facet_date_filter $field $value)#url_for_home#lens&fq=$esc.url($field):$esc.url($value)#end
+
+#macro(url_for_facet_range_filter $field $value)#url_for_home#lens&fq=$esc.url($field):$esc.url($value)#end
+
+
+#macro(link_to_previous_page $text)
+  #if($page.current_page_number > 1)
+    #set($prev_start = $page.start - $page.results_per_page)
+    <a class="prev-page" href="#url_for_start($prev_start)">$text</a>
+  #end
+#end
+
+#macro(link_to_next_page $text)
+  #if($page.current_page_number < $page.page_count)
+    #set($next_start = $page.start + $page.results_per_page)
+    <a class="next-page" href="#url_for_start($next_start)">$text</a>
+  #end
+#end
+
+#macro(link_to_page $page_number $text)
+  #if($page_number == $page.current_page_number)
+    $text
+  #else
+    #if($page_number <= $page.page_count)
+      #set($page_start = $page_number * $page.results_per_page - $page.results_per_page)
+      <a class="page" href="#url_for_start($page_start)">$text</a>
+    #end
+  #end
+#end
+
+
+#macro(field $f)
+  #if($response.response.highlighting.get($docId).get($f).get(0))
+    #set($pad = "")
+    #foreach($v in $response.response.highlighting.get($docId).get($f))
+$pad$v##
+      #set($pad = " ... ")
+    #end
+  #else
+    #foreach($v in $doc.getFieldValues($f))
+$v##
+    #end
+  #end
+#end  
+

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/_default.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/_default.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/_default.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/_default.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,14 @@
+<h1>Request</h1>
+<ul>
+  <li>context.path = $request.context.path</li>
+  <li>params.qt = $!request.params.qt</li>
+</ul>
+
+<pre>
+  $esc.html($request)
+</pre>
+
+<h1>Response</h1>
+<pre>
+  $esc.html($response)
+</pre>

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/browse.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/browse.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/browse.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/browse.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,71 @@
+#set($params = $request.params)
+
+## Show Error Message, if any
+<div class="error">
+  #parse("error.vm")
+</div>
+
+<div class="query-box">
+  <form id="query-form" action="#{url_for_home}" method="GET">
+    Find:
+    <input type="text" id="q" name="q" value="$!esc.html($params.get('q'))"/>
+    <input type="submit"/>
+
+    #if($request.params.get('debugQuery'))
+      <input type="hidden" name="debug" value="true"/>
+    #end
+    #foreach($fq in $request.params.getParams('fq'))
+      <input type="hidden" name="fq" id="allFQs" value="$esc.html($fq)"/>
+    #end
+
+    <div class="constraints">
+      #foreach($fq in $params.getParams('fq'))
+        #set($previous_fq_count=$velocityCount - 1)
+        #if($fq != '')
+          &gt;
+          <a href="#url_for_filters($request.params.getParams('fq').subList(0,$previous_fq_count))">$fq</a>
+        #end
+      #end
+    </div>
+
+    <div class="parsed_query_header">
+      #if($request.params.get('debugQuery'))
+        <a href="#" onclick='jQuery(this).siblings("div").toggle(); return false;'>toggle parsed query</a>
+        <div class="parsed_query" style="display:none">$response.response.debug.parsedquery</div>
+      #end
+    </div>
+
+  </form>
+</div>
+
+<div class="facets">
+  #parse("facets.vm")
+</div>
+
+<div class="pagination">
+  <span>
+    <span class="results-found">$page.results_found</span>
+    results found in
+    ${response.responseHeader.QTime} ms
+  </span>
+
+  Page <span class="page-num">$page.current_page_number</span>
+    of <span class="page-count">$page.page_count</span>
+</div>
+
+## Render Results, actual matching docs
+<div class="results">
+  #parse("results_list.vm")
+</div>
+
+<div class="pagination">
+  #link_to_previous_page("previous")
+
+  <span class="results-found">$page.results_found</span>
+  results found.
+
+  Page <span class="page-num">$page.current_page_number</span>
+    of <span class="page-count">$page.page_count</span>
+
+  #link_to_next_page("next")
+</div>

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/debug.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/debug.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/debug.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/debug.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,26 @@
+#**
+ *  Show Debugging Information, if enabled
+ *#
+
+#if( $params.getBool("debugQuery",false) )
+  <a href="#" onclick='jQuery(this).siblings("pre").toggle(); return false;'>toggle explain</a>
+
+  <pre style="display:none">
+    $response.getExplainMap().get($doc.getFirstValue('id'))
+  </pre>
+
+  <a href="#" onclick='jQuery(this).siblings("pre2").toggle(); return false;'>toggle all fields</a>
+
+  <pre2 style="display:none">
+    #foreach($fieldname in $doc.fieldNames)
+      <br>
+        <span class="field-name">$fieldname :</span>
+        <span>
+          #foreach($value in $doc.getFieldValues($fieldname))
+            $esc.html($value)
+          #end
+        </span>
+      </br>
+    #end
+  </pre2>
+#end

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/error.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/error.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/error.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/error.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,11 @@
+#**
+ *  Show Error Message, if any
+ *#
+
+## Show Error Message, if any
+## Usually rendered inside div class=error
+
+#if( $response.response.error.code )
+  <h1>ERROR $response.response.error.code</h1>
+  $response.response.error.msg
+#end

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/facets.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/facets.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/facets.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/facets.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,20 @@
+#**
+ *  Display facets based on field values
+ *  e.g.: fields specified by &facet.field=
+ *#
+
+#if($response.facetFields.size() > 0)
+  <h2>Field Facets</h2>
+
+  #foreach($field in $response.facetFields)
+    ## Hide facets without value
+    #if($field.values.size() > 0)
+      <span class="facet-field">$field.name</span>
+      <ul>
+        #foreach($facet in $field.values)
+          <li><a href="#url_for_facet_filter($field.name, $facet.name)">#if($facet.name!=$null)$facet.name#else<em>missing</em>#end</a> ($facet.count)</li>
+        #end
+      </ul>
+    #end  ## end if > 0
+  #end    ## end for each facet field
+#end      ## end if response has facet fields

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/footer.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/footer.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/footer.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/footer.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,19 @@
+<hr/>
+<div>
+  <span>Options:</span>
+
+  #if($request.params.get('debugQuery'))
+    <a href="#url_for_home?#q#if($list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end">
+      disable debug</a>
+  #else
+    <a href="#url_for_lens&debug=true&fl=*,score">enable debug</a>
+  #end
+  -
+  <a href="#url_for_lens&wt=xml#if($request.params.get('debugQuery'))&debug=true#end">XML results</a>
+
+</div>
+
+<div>
+  <a href="http://lucene.apache.org/solr">Solr Home Page</a>
+</div>
+

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/head.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/head.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/head.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/head.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,196 @@
+#**
+ *  Provide elements for the <head> section of the HTML document
+ *#
+
+  <title>Solr browse: #core_name</title>
+  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
+
+  <script type="text/javascript" src="#{url_root}/js/lib/jquery-1.7.2.min.js"></script>
+
+  <style>
+    #admin{
+      text-align: right;
+      vertical-align: top;
+    }
+
+    #head{
+      width: 100%;
+    }
+    .array-field {
+      border: 2px solid #474747;
+      background: #FFE9D8;
+      padding: 5px;
+      margin: 5px;
+    }
+
+    .array-field-list li {
+      list-style: circle;
+      margin-left: 20px;
+    }
+
+    .parsed_query_header {
+      font-family: Helvetica, Arial, sans-serif;
+      font-size: 10pt;
+      font-weight: bold;
+    }
+
+    .parsed_query {
+      font-family: Courier, Courier New, monospaced;
+      font-size: 10pt;
+      font-weight: normal;
+    }
+
+    body {
+      font-family: Helvetica, Arial, sans-serif;
+      font-size: 10pt;
+    }
+
+    a {
+      color: #43a4b1;
+    }
+
+    .facets {
+      float: left;
+      margin: 5px;
+      margin-top: 0px;
+      width: 185px;
+      padding: 5px;
+      top: -20px;
+      position: relative;
+    }
+
+    .facets h2 {
+      background: #EA897E;
+      padding: 2px 5px;
+    }
+
+    .facets ul {
+      list-style: none;
+      margin: 0;
+      margin-bottom: 5px;
+      margin-top: 5px;
+      padding-left: 10px;
+    }
+
+    .facets ul li {
+      color: #999;
+      padding: 2px;
+    }
+
+    .facet-field {
+      font-weight: bold;
+    }
+
+    .highlight {
+      color: white;
+      background-color: gray;
+      border: 1px black solid;
+    }
+
+    .highlight-box {
+      margin-left: 15px;
+    }
+
+    .field-name {
+      font-weight: bold;
+    }
+
+    .highlighted-facet-field {
+      background: white;
+    }
+
+    .constraints {
+      margin-top: 10px;
+    }
+
+    #query-form{
+      width: 80%;
+    }
+
+    .query-box, .constraints {
+      padding: 5px;
+      margin: 5px;
+      font-weight: normal;
+      font-size: 24px;
+      letter-spacing: 0.08em;
+    }
+
+    .query-box #q {
+      margin-left: 8px;
+      width: 60%;
+      height: 50px;
+      border: 1px solid #999;
+      font-size: 1em;
+      padding: 0.4em;
+    }
+
+    .query-box {
+
+    }
+
+    .query-box .inputs{
+      left: 180px;
+      position: relative;
+
+    }
+
+    #logo {
+      margin: 10px;
+      border-style: none;
+    }
+
+    .pagination {
+      padding-left: 33%;
+      background: #eee;
+      margin: 5px;
+      margin-left: 210px;
+      padding-top: 5px;
+      padding-bottom: 5px;
+    }
+
+    .result-document {
+      border: 1px solid #999;
+      padding: 5px;
+      margin: 5px;
+      margin-left: 210px;
+      margin-bottom: 15px;
+    }
+
+    .result-document div{
+      padding: 5px;
+    }
+
+    .result-title{
+      width:60%;
+    }
+
+    .result-body{
+      background: #ddd;
+    }
+
+    .mlt{
+
+    }
+
+    .result-document:nth-child(2n+1) {
+      background-color: #eee;
+    }
+
+
+    .selected-facet-field {
+      font-weight: bold;
+    }
+
+    li.show {
+      list-style: disc;
+    }
+
+    .error {
+      color: white;
+      background-color: red;
+      left: 210px;
+      width:80%;
+      position: relative;
+
+    }
+  </style>

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/hit.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/hit.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/hit.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/hit.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,24 @@
+#set($docId = $doc.getFieldValue('id'))
+
+<div class="result-document">
+
+  <table>
+    #foreach( $fieldName in $doc.fieldNames )
+      #foreach( $value in $doc.getFieldValues($fieldName) )
+        <tr>
+          <th align="right" valign="top">
+            #if( $foreach.count == 1 )
+              $fieldName:
+            #end
+          </th>
+
+          <td align="left" valign="top">
+            $esc.html($value) <br/>
+          </td>
+        </tr>
+      #end
+    #end
+  </table>
+
+
+</div>

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/layout.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/layout.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/layout.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/layout.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,19 @@
+<html>
+<head>
+  #parse("head.vm")
+</head>
+  <body>
+    <div id="admin"><a href="#url_root/#/#core_name">Solr Admin</a></div>
+    <div id="head">
+      <a href="#url_for_home#if($request.params.get('debugQuery'))?debugQuery=true#end"><img src="#{url_root}/img/solr.svg" id="logo"/></a>
+    </div>
+
+    <div id="content">
+      $content
+    </div>
+
+    <div id="footer">
+      #parse("footer.vm")
+    </div>
+  </body>
+</html>

Added: lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/results_list.vm
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/results_list.vm?rev=1648030&view=auto
==============================================================================
--- lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/results_list.vm (added)
+++ lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/results_list.vm Sat Dec 27 01:11:47 2014
@@ -0,0 +1,3 @@
+#foreach($doc in $response.results)
+  #parse("hit.vm")
+#end