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
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
@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)
# Exhibit seems to require a label attribute to be happy
@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 }
format.html # renders exhibit.rhtml
format.json { render :json => {'items' => @data}.to_json } # Exhibit seems to require data to be in a 'items' Hash
end
end
end

View File

@ -1,50 +1,57 @@
<% form_tag(:action=>'add_query') do %>
Query: <%= text_field_with_auto_complete :search, :query %>
<% end %>
<%=link_to 'clear constraints', :action => 'clear'%>
<div>
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>
<div id="sidebar"><div class="boxContent">
<% form_tag(:action=>'add_query') do %>
<%= text_field_with_auto_complete :search, :query %>
<%=submit_tag "search"%>
<% end %>
<h2>facets</h2>
<div class="boxContent">
<% @facet_fields.each do |field|%>
<h4><%=field%></h4>
<h4><%=link_to field, :action => 'facet', :field_name => field%></h4>
<ul>
<% @response.field_facets(field).each do |k,v| %>
<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>
<% end %>
</div>
<h2>results</h2>
<div>
Found: <%=@response.total_hits%>
<ul>
<% @response.each do |doc| %>
<li><%= debug doc%></li>
<% end %>
</ul>
</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>
<head>
<title>Flare: <%=controller.action_name%></title>
<title>Solr Flare: <%=controller.action_name%></title>
<%= javascript_include_tag :defaults %>
<%= stylesheet_link_tag 'flare'%>
</head>
<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>
</html>

View File

@ -1,17 +1,11 @@
<html>
<head>
<title>MIT Nobel Prize Winners</title>
<title>SIMILE Exhibit view</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>
@ -22,7 +16,7 @@
<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>
<div id="exhibit-browse-panel" ex:facets=".genre_facet, .medium_facet, .country_facet, .signed_facet, .rating_facet, .language_facet"></div>
</td>
</tr>
</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;
}
#header {
font-size: 20px;
background:url(../images/flare.jpg) no-repeat left top;
}
td {
font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
font-size: 13px;