Add SIMILE Exhibit view of the currently filtered set, as proof-of-concept.

Adjusted CSS, improved UI dramatically, even including a logo in the header.



git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@503379 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2007-02-04 09:42:05 +00:00
parent 32d4ad8b3b
commit 7dec1958a4
7 changed files with 67 additions and 53 deletions

View File

@ -13,20 +13,23 @@
class SimileController < ApplicationController class SimileController < ApplicationController
def exhibit def exhibit
# TODO this code was copied from BrowseController#index, and is here only as a quick and dirty prototype.
# TODO figuring out where these calls cleanly belong is the key.
@info = SOLR.send(Solr::Request::IndexInfo.new) # TODO move this call to only have it called when the index may have changed @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$/} @facet_fields = @info.field_names.find_all {|v| v =~ /_facet$/}
# TODO Add paging and sorting
req = Solr::Request::Standard.new :query => query, req = Solr::Request::Standard.new :query => query,
:filter_queries => filters, :filter_queries => filters,
:facets => {:fields => @facet_fields, :limit => 20 , :mincount => 1, :sort => :count, :debug_query=>true} :facets => {:fields => @facet_fields, :limit => 20 , :mincount => 1, :sort => :count, :debug_query=>true}
@data = SOLR.send(req) @data = SOLR.send(req)
# Exhibit seems to require a label attribute to be happy
@data.each {|d| d['label'] = d['title_text']} @data.each {|d| d['label'] = d['title_text']}
respond_to do |format| respond_to do |format|
puts "format = #{format.inspect}" format.html # renders exhibit.rhtml
format.html # renders index.rhtml format.json { render :json => {'items' => @data}.to_json } # Exhibit seems to require data to be in a 'items' Hash
format.json { render :json => {'items' => @data}.to_json }
end end
end end
end end

View File

@ -1,50 +1,57 @@
<% form_tag(:action=>'add_query') do %> <div id="sidebar"><div class="boxContent">
Query: <%= text_field_with_auto_complete :search, :query %> <% form_tag(:action=>'add_query') do %>
<% end %> <%= text_field_with_auto_complete :search, :query %>
<%=link_to 'clear constraints', :action => 'clear'%> <%=submit_tag "search"%>
<div> <% end %>
Queries:
<ul>
<% session[:queries].each_with_index do |q,i| %>
<li><%=link_to q[:negative] ? "-" : '+', :action => :invert_query, :index => i%> <%=q[:query]%> <%=link_to "remove", :action => :remove_query, :index => i %></li>
<% end %>
</ul>
</div>
<div>
Filters:
<ul>
<% session[:filters].each_with_index do |filter, i| %>
<li>
<%=link_to filter[:negative] ? "-" : "+", :action => :invert_filter, :index => i%>
<%=filter[:field]%>:<%=filter[:value]%>
<%=link_to "remove", :action => :remove_filter, :index => i %>
</li>
<% end %>
</ul>
</div>
<h2>facets</h2> <h2>facets</h2>
<div class="boxContent">
<% @facet_fields.each do |field|%> <% @facet_fields.each do |field|%>
<h4><%=field%></h4> <h4><%=link_to field, :action => 'facet', :field_name => field%></h4>
<ul> <ul>
<% @response.field_facets(field).each do |k,v| %> <% @response.field_facets(field).each do |k,v| %>
<li><%= link_to "#{k} (#{v})", :action => 'add_filter', :field_name=>field, :value=>k%></li> <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> <% end %>
</ul> </ul>
<% end %> <% end %>
</div> </div>
<h2>results</h2>
<div>
Found: <%=@response.total_hits%>
<ul>
<% @response.each do |doc| %>
<li><%= debug doc%></li>
<% end %>
</ul>
</div> </div>
<h3>index info</h3><%=debug @info %>
<h3>search/facet response header</h3><%=debug @response.data['responseHeader']%> <div>
Queries:
<% session[:queries].each_with_index do |q,i| %>
<%=link_to q[:negative] ? "-" : '+', :action => :invert_query, :index => i%> <%=q[:query]%> <%=link_to image_tag("x-close.gif"), :action => :remove_query, :index => i %>
<% end %>
</div>
<div>
Filters:
<% session[:filters].each_with_index do |filter, i| %>
<%=link_to filter[:negative] ? "-" : "+", :action => :invert_filter, :index => i%>
<%=filter[:field]%>:<%=filter[:value]%>
<%=link_to image_tag("x-close.gif"), :action => :remove_filter, :index => i %>
<% end %>
<div><%=link_to 'clear constraints', :action => 'clear'%></div>
</div>
<div>Results <strong>1-<%=[@response.total_hits,10].min%></strong> of <strong><%=@response.total_hits%></strong></div>
<div id="results"><table cellpadding="10">
<% display_fields = [:title, :author, :pages, :rating]; @response.each do |doc| %>
<tr valign="top">
<td>
<table>
<% display_fields.each do |f|%>
<tr><th><%=f.to_s%></th><td><%=doc["#{f.to_s}_text"] %><%=doc["#{f.to_s}_facet"] %></td></tr>
<% end %>
</table>
</td>
</tr>
<% end %>
</table>
</div>
<!-- <h3>index info</h3><%=debug @info %>
<h3>search/facet response header</h3><%=debug @response.data['responseHeader']%> -->

View File

@ -1,10 +1,15 @@
<html> <html>
<head> <head>
<title>Flare: <%=controller.action_name%></title> <title>Solr Flare: <%=controller.action_name%></title>
<%= javascript_include_tag :defaults %> <%= javascript_include_tag :defaults %>
<%= stylesheet_link_tag 'flare'%> <%= stylesheet_link_tag 'flare'%>
</head> </head>
<body> <body>
<%= yield %> <div>
<div id="header">
<a href="http://lucene.apache.org/solr"><%=image_tag "http://lucene.apache.org/solr/images/solr.png"%></a> <a href="http://wiki.apache.org/solr/Flare">Flare</a>
</div>
<%= yield %>
</div>
</body> </body>
</html> </html>

View File

@ -1,17 +1,11 @@
<html> <html>
<head> <head>
<title>MIT Nobel Prize Winners</title> <title>SIMILE Exhibit view</title>
<link href="exhibit.json" type="application/json" rel="exhibit/data" /> <link href="exhibit.json" type="application/json" rel="exhibit/data" />
<script src="http://static.simile.mit.edu/exhibit/api/exhibit-api.js" <script src="http://static.simile.mit.edu/exhibit/api/exhibit-api.js"
type="text/javascript"></script> type="text/javascript"></script>
<style>
body {
margin: 1in;
}
</style>
</head> </head>
<body> <body>
<h1>SIMILE Exhibit view</h1> <h1>SIMILE Exhibit view</h1>
@ -22,7 +16,7 @@
<div id="exhibit-view-panel"></div> <div id="exhibit-view-panel"></div>
</td> </td>
<td width="25%"> <td width="25%">
<div id="exhibit-browse-panel" ex:facets=".medium_facet, .country_facet, .signed_facet, .rating_facet, .language_facet, .genre_facet"></div> <div id="exhibit-browse-panel" ex:facets=".genre_facet, .medium_facet, .country_facet, .signed_facet, .rating_facet, .language_facet"></div>
</td> </td>
</tr> </tr>
</table> </table>

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 B

View File

@ -4,6 +4,11 @@ body {
margin: 0px; margin: 0px;
} }
#header {
font-size: 20px;
background:url(../images/flare.jpg) no-repeat left top;
}
td { td {
font-family: Verdana, Geneva, Arial, helvetica, sans-serif; font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
font-size: 13px; font-size: 13px;