mirror of https://github.com/apache/lucene.git
SIMILE Exhibit support (prototype) - Tada!
Also started adding some CSS. git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@503361 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e86589e75b
commit
c06fe80ce9
|
@ -7,4 +7,21 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
# Pick a unique cookie name to distinguish our session data from others'
|
||||
session :session_key => '_flare_session_id'
|
||||
|
||||
|
||||
def query
|
||||
queries = session[:queries]
|
||||
if queries.nil? || queries.empty?
|
||||
query = "[* TO *]"
|
||||
else
|
||||
query = session[:queries].collect{|q| "#{q[:negative] ? '-' : ''}(#{q[:query]})"}.join(' AND ')
|
||||
end
|
||||
|
||||
query
|
||||
end
|
||||
|
||||
def filters
|
||||
session[:filters].collect {|filter| "#{filter[:negative] ? '-' : ''}#{filter[:field]}:\"#{filter[:value]}\""}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,7 +18,7 @@ class BrowseController < ApplicationController
|
|||
end
|
||||
|
||||
def facet
|
||||
@facets = retrieve_field_facets("#{params[:field]}")
|
||||
@facets = retrieve_field_facets(params[:field_name])
|
||||
end
|
||||
|
||||
def auto_complete_for_search_query
|
||||
|
@ -57,7 +57,7 @@ class BrowseController < ApplicationController
|
|||
end
|
||||
|
||||
def add_filter
|
||||
session[:filters] << {:field => params[:field], :value => params[:value]}
|
||||
session[:filters] << {:field => params[:field_name], :value => params[:value]}
|
||||
redirect_to :action => 'index'
|
||||
end
|
||||
|
||||
|
@ -88,18 +88,4 @@ class BrowseController < ApplicationController
|
|||
results.field_facets(field)
|
||||
end
|
||||
|
||||
def query
|
||||
queries = session[:queries]
|
||||
if queries.nil? || queries.empty?
|
||||
query = "[* TO *]"
|
||||
else
|
||||
query = session[:queries].collect{|q| "#{q[:negative] ? '-' : ''}(#{q[:query]})"}.join(' AND ')
|
||||
end
|
||||
|
||||
query
|
||||
end
|
||||
|
||||
def filters
|
||||
session[:filters].collect {|filter| "#{filter[:negative] ? '-' : ''}#{filter[:field]}:\"#{filter[:value]}\""}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
# (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
class SimileController < ApplicationController
|
||||
def exhibit
|
||||
@info = SOLR.send(Solr::Request::IndexInfo.new) # TODO move this call to only have it called when the index may have changed
|
||||
@facet_fields = @info.field_names.find_all {|v| v =~ /_facet$/}
|
||||
|
||||
# TODO Add paging and sorting
|
||||
req = Solr::Request::Standard.new :query => query,
|
||||
:filter_queries => filters,
|
||||
:facets => {:fields => @facet_fields, :limit => 20 , :mincount => 1, :sort => :count, :debug_query=>true}
|
||||
@data = SOLR.send(req)
|
||||
@data.each {|d| d['label'] = d['title_text']}
|
||||
|
||||
respond_to do |format|
|
||||
puts "format = #{format.inspect}"
|
||||
format.html # renders index.rhtml
|
||||
format.json { render :json => {'items' => @data}.to_json }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,3 +1,3 @@
|
|||
<% @facets.each do |value,count| %>
|
||||
<%= link_to value, :action => 'add_filter', :field => @field, :value => value %> (<%=count%>)
|
||||
<%= link_to value, :action => 'add_filter', :field_name => params[:field_name], :value => value %> (<%=count%>)
|
||||
<% end%>
|
|
@ -23,14 +23,17 @@ Filters:
|
|||
</ul>
|
||||
</div>
|
||||
<h2>facets</h2>
|
||||
<div>
|
||||
|
||||
|
||||
<div class="boxContent">
|
||||
|
||||
<% @facet_fields.each do |field|%>
|
||||
<div>
|
||||
<%=field%>:
|
||||
<h4><%=field%></h4>
|
||||
<ul>
|
||||
<% @response.field_facets(field).each do |k,v| %>
|
||||
<%= link_to "#{k} (#{v})", :action => 'add_filter', :field=>field, :value=>k%>
|
||||
<% end %> <%=link_to "more...", :action => 'facet', :field => field%>
|
||||
</div>
|
||||
<li><%= link_to "#{k} (#{v})", :action => 'add_filter', :field_name=>field, :value=>k%></li>
|
||||
<% end %> <li><%=link_to "more...", :action => 'facet', :field_name => field%></li>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
<h2>results</h2>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<head>
|
||||
<title>Flare: <%=controller.action_name%></title>
|
||||
<%= javascript_include_tag :defaults %>
|
||||
<%= stylesheet_link_tag 'flare'%>
|
||||
</head>
|
||||
<body>
|
||||
<%= yield %>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>MIT Nobel Prize Winners</title>
|
||||
|
||||
<link href="exhibit.json" type="application/json" rel="exhibit/data" />
|
||||
|
||||
<script src="http://static.simile.mit.edu/exhibit/api/exhibit-api.js"
|
||||
type="text/javascript"></script>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 1in;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>SIMILE Exhibit view</h1>
|
||||
<table width="100%">
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<div id="exhibit-control-panel"></div>
|
||||
<div id="exhibit-view-panel"></div>
|
||||
</td>
|
||||
<td width="25%">
|
||||
<div id="exhibit-browse-panel" ex:facets=".medium_facet, .country_facet, .signed_facet, .rating_facet, .language_facet, .genre_facet"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -21,5 +21,6 @@ ActionController::Routing::Routes.draw do |map|
|
|||
|
||||
# Install the default route as the lowest priority.
|
||||
# map.connect ':controller/:action/:id.:format'
|
||||
map.connect ':controller/:action.:format'
|
||||
map.connect ':controller/:action'
|
||||
end
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
body {
|
||||
font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
td {
|
||||
font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
|
||||
font-size: 13px;
|
||||
}
|
||||
a, a:visited {
|
||||
color: #000099;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
color: #0000CC;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#search {
|
||||
background-color: #EFEFDE;
|
||||
padding-top: 30px;
|
||||
padding-left: 30px;
|
||||
padding-bottom: 20px;
|
||||
margin-bottom: 20px;
|
||||
border-bottom-width: 1px;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-color: #CCCCCC;
|
||||
}
|
||||
#sidebar {
|
||||
float: right;
|
||||
width: 339px;
|
||||
font-size:90%;
|
||||
line-height: 18px;
|
||||
margin-left: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#results {
|
||||
margin-right: 380px;
|
||||
}
|
||||
|
||||
.resultsPager {
|
||||
padding: 4px;
|
||||
margin-top: 30px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid #A2C9EF;
|
||||
background-color: #E4F1FD;
|
||||
}
|
||||
|
||||
/* SIDE BAR */
|
||||
|
||||
.box {
|
||||
width:339px;
|
||||
background:#F3F3F3 url(../images/hits_bot.gif) no-repeat left bottom;
|
||||
margin-bottom: 20px;
|
||||
padding:0 0 6px;
|
||||
color:#333;
|
||||
line-height:1.5em;
|
||||
}
|
||||
.box2 {
|
||||
width:100%;
|
||||
background:url(../images/hits_top.gif) no-repeat left top;
|
||||
padding:6px 0 0;
|
||||
}
|
||||
.box3 {
|
||||
background:url(../images/hits_rails.gif) repeat-y;
|
||||
padding:0px;
|
||||
}
|
||||
.boxContent {
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
.box p {
|
||||
margin:0 0 .6em;
|
||||
}
|
||||
.sidebar-title {
|
||||
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
|
||||
margin:0;
|
||||
padding:0 0 .2em;
|
||||
border-bottom:1px dotted #fa0;
|
||||
font-size:115%;
|
||||
line-height:1.5em;
|
||||
color:#333;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.recordAmazon {
|
||||
margin-left: 150px;
|
||||
}
|
||||
.recordAuthor {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.recordBasic {
|
||||
margin-left: 150px;
|
||||
}
|
||||
.recordBookJacket {
|
||||
float: left;
|
||||
margin-right: 20px;
|
||||
}
|
||||
.recordFullText {
|
||||
margin: 30px;
|
||||
padding: 10px;
|
||||
}
|
||||
.recordHoldings {
|
||||
background-color: #EFEFEF;
|
||||
margin: 10px;
|
||||
padding: 10px;
|
||||
border: 1px solid #CCCCCC;
|
||||
}
|
||||
.recordHoldingHead {
|
||||
border-bottom-style: solid;
|
||||
border-bottom-color: #CCCCCC;
|
||||
border-bottom-width: 1px;
|
||||
margin-bottom: 10px;
|
||||
padding: 5px;
|
||||
text-align: left;
|
||||
}
|
||||
.recordHoldingBody {
|
||||
background-color: #EFEFEF;
|
||||
padding: 5px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
.recordImprint {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.recordTitle {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.home {
|
||||
clear: both;
|
||||
width: 640px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.homeSearch {
|
||||
margin-top: 80px;
|
||||
margin-bottom: 20px;
|
||||
background-color: #EFEFDE;
|
||||
padding-top: 30px;
|
||||
padding-left: 30px;
|
||||
padding-bottom: 20px;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #CCCCCC;
|
||||
}
|
||||
|
Loading…
Reference in New Issue