From c06fe80ce9b7f3e795590fca6e0578abd0bfb8a8 Mon Sep 17 00:00:00 2001 From: Erik Hatcher Date: Sun, 4 Feb 2007 05:44:09 +0000 Subject: [PATCH] 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 --- .../ruby/flare/app/controllers/application.rb | 17 ++ .../app/controllers/browse_controller.rb | 18 +-- .../app/controllers/simile_controller.rb | 32 ++++ .../ruby/flare/app/views/browse/facet.rhtml | 2 +- .../ruby/flare/app/views/browse/index.rhtml | 15 +- .../ruby/flare/app/views/layouts/browse.rhtml | 1 + .../ruby/flare/app/views/simile/exhibit.rhtml | 30 ++++ client/ruby/flare/config/routes.rb | 1 + .../ruby/flare/public/stylesheets/flare.css | 149 ++++++++++++++++++ 9 files changed, 242 insertions(+), 23 deletions(-) create mode 100755 client/ruby/flare/app/controllers/simile_controller.rb create mode 100644 client/ruby/flare/app/views/simile/exhibit.rhtml create mode 100644 client/ruby/flare/public/stylesheets/flare.css diff --git a/client/ruby/flare/app/controllers/application.rb b/client/ruby/flare/app/controllers/application.rb index 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 + end diff --git a/client/ruby/flare/app/controllers/browse_controller.rb b/client/ruby/flare/app/controllers/browse_controller.rb index 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 < 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 diff --git a/client/ruby/flare/app/controllers/simile_controller.rb b/client/ruby/flare/app/controllers/simile_controller.rb new file mode 100755 index 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 +end diff --git a/client/ruby/flare/app/views/browse/facet.rhtml b/client/ruby/flare/app/views/browse/facet.rhtml index 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 file diff --git a/client/ruby/flare/app/views/browse/index.rhtml b/client/ruby/flare/app/views/browse/index.rhtml index 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:

facets

-
+ + +
+ <% @facet_fields.each do |field|%> -
- <%=field%>: +

<%=field%>

+
    <% @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%> -
+
  • <%= link_to "#{k} (#{v})", :action => 'add_filter', :field_name=>field, :value=>k%>
  • + <% end %>
  • <%=link_to "more...", :action => 'facet', :field_name => field%>
  • + <% end %>

    results

    diff --git a/client/ruby/flare/app/views/layouts/browse.rhtml b/client/ruby/flare/app/views/layouts/browse.rhtml index 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 @@ Flare: <%=controller.action_name%> <%= javascript_include_tag :defaults %> + <%= stylesheet_link_tag 'flare'%> <%= yield %> diff --git a/client/ruby/flare/app/views/simile/exhibit.rhtml b/client/ruby/flare/app/views/simile/exhibit.rhtml new file mode 100644 index 00000000000..243971d21cf --- /dev/null +++ b/client/ruby/flare/app/views/simile/exhibit.rhtml @@ -0,0 +1,30 @@ + + + MIT Nobel Prize Winners + + + + + + + + +

    SIMILE Exhibit view

    + + + + + +
    +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/client/ruby/flare/config/routes.rb b/client/ruby/flare/config/routes.rb index 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' end diff --git a/client/ruby/flare/public/stylesheets/flare.css b/client/ruby/flare/public/stylesheets/flare.css new file mode 100644 index 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; +} +