Apache Solr open-source search software
SIMILE Exhibit support (prototype) - Tada!
Erik Hatcherc06fe80ce9b7
diff --git a/client/ruby/flare/app/controllers/application.rb b/client/ruby/flare/app/controllers/application.rbindex 82e1a6a43eb..540338459a9 100644--- a/client/ruby/flare/app/controllers/application.rb+++ b/client/ruby/flare/app/controllers/application.rb@@ -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+enddiff --git a/client/ruby/flare/app/controllers/browse_controller.rb b/client/ruby/flare/app/controllers/browse_controller.rbindex 1ddb1d3c69d..c8779aae217 100644--- a/client/ruby/flare/app/controllers/browse_controller.rb+++ b/client/ruby/flare/app/controllers/browse_controller.rb@@ -18,7 +18,7 @@ class BrowseController < ApplicationControllerenddef facet- @facets = retrieve_field_facets("#{params[:field]}")+ @facets = retrieve_field_facets(params[:field_name])enddef auto_complete_for_search_query@@ -57,7 +57,7 @@ class BrowseController < ApplicationControllerenddef 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 < ApplicationControllerresults.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]}\""}- endenddiff --git a/client/ruby/flare/app/controllers/simile_controller.rb b/client/ruby/flare/app/controllers/simile_controller.rbnew file mode 100755index 00000000000..4283a9fe651--- /dev/null+++ b/client/ruby/flare/app/controllers/simile_controller.rb@@ -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+enddiff --git a/client/ruby/flare/app/views/browse/facet.rhtml b/client/ruby/flare/app/views/browse/facet.rhtmlindex 3009c7956d9..782981c9d95 100755--- a/client/ruby/flare/app/views/browse/facet.rhtml+++ b/client/ruby/flare/app/views/browse/facet.rhtml@@ -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%>\ No newline at end of filediff --git a/client/ruby/flare/app/views/browse/index.rhtml b/client/ruby/flare/app/views/browse/index.rhtmlindex 4ea7091937f..4535d5e1d91 100644--- a/client/ruby/flare/app/views/browse/index.rhtml+++ b/client/ruby/flare/app/views/browse/index.rhtml@@ -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>diff --git a/client/ruby/flare/app/views/layouts/browse.rhtml b/client/ruby/flare/app/views/layouts/browse.rhtmlindex 2ff55354f89..3e15f35bb93 100755--- a/client/ruby/flare/app/views/layouts/browse.rhtml+++ b/client/ruby/flare/app/views/layouts/browse.rhtml@@ -2,6 +2,7 @@<head><title>Flare: <%=controller.action_name%></title><%= javascript_include_tag :defaults %>+ <%= stylesheet_link_tag 'flare'%></head><body><%= yield %>diff --git a/client/ruby/flare/app/views/simile/exhibit.rhtml b/client/ruby/flare/app/views/simile/exhibit.rhtmlnew file mode 100644index 00000000000..243971d21cf--- /dev/null+++ b/client/ruby/flare/app/views/simile/exhibit.rhtml@@ -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>\ No newline at end of filediff --git a/client/ruby/flare/config/routes.rb b/client/ruby/flare/config/routes.rbindex 5a6dcc3e1d3..7e28db20b89 100644--- a/client/ruby/flare/config/routes.rb+++ b/client/ruby/flare/config/routes.rb@@ -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'enddiff --git a/client/ruby/flare/public/stylesheets/flare.css b/client/ruby/flare/public/stylesheets/flare.cssnew file mode 100644index 00000000000..ff54d54a2d4--- /dev/null+++ b/client/ruby/flare/public/stylesheets/flare.css@@ -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;+}+