Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

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

Erik Hatcher7dec1958a4e2
diff --git a/client/ruby/flare/app/controllers/simile_controller.rb b/client/ruby/flare/app/controllers/simile_controller.rb
index 4283a9fe651..2f34ab5a8f3 100755
--- a/client/ruby/flare/app/controllers/simile_controller.rb
+++ b/client/ruby/flare/app/controllers/simile_controller.rb
@@ -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
diff --git a/client/ruby/flare/app/views/browse/index.rhtml b/client/ruby/flare/app/views/browse/index.rhtml
index 4535d5e1d91..0b0f104b608 100644
--- a/client/ruby/flare/app/views/browse/index.rhtml
+++ b/client/ruby/flare/app/views/browse/index.rhtml
@@ -1,50 +1,57 @@
-<% form_tag(:action=>'add_query') do %>
- Query: <%= text_field_with_auto_complete :search, :query %>
+<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>
+
+<% @facet_fields.each do |field|%>
+ <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 %>
+ </ul>
<% end %>
-<%=link_to 'clear constraints', :action => 'clear'%>
+</div>
+</div>
+
<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>
+ <%=link_to q[:negative] ? "-" : '+', :action => :invert_query, :index => i%> <%=q[:query]%> <%=link_to image_tag("x-close.gif"), :action => :remove_query, :index => i %>
<% 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>
+ <%=link_to image_tag("x-close.gif"), :action => :remove_filter, :index => i %>
<% end %>
-</ul>
+<div><%=link_to 'clear constraints', :action => 'clear'%></div>
</div>
-<h2>facets</h2>
+<div>Results <strong>1-<%=[@response.total_hits,10].min%></strong> of <strong><%[email protected]_hits%></strong></div>
-<div class="boxContent">
-<% @facet_fields.each do |field|%>
- <h4><%=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>
- </ul>
-<% end %>
-</div>
-<h2>results</h2>
-<div>
-Found: <%[email protected]_hits%>
-<ul>
- <% @response.each do |doc| %>
- <li><%= debug doc%></li>
+<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 %>
-</ul>
+</table>
</div>
-<h3>index info</h3><%=debug @info %>
-<h3>search/facet response header</h3><%=debug @response.data['responseHeader']%>
+
+
+<!-- <h3>index info</h3><%=debug @info %>
+
+<h3>search/facet response header</h3><%=debug @response.data['responseHeader']%> -->
diff --git a/client/ruby/flare/app/views/layouts/browse.rhtml b/client/ruby/flare/app/views/layouts/browse.rhtml
index 3e15f35bb93..364a28a182f 100755
--- a/client/ruby/flare/app/views/layouts/browse.rhtml
+++ b/client/ruby/flare/app/views/layouts/browse.rhtml
@@ -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>
\ No newline at end of file
diff --git a/client/ruby/flare/app/views/simile/exhibit.rhtml b/client/ruby/flare/app/views/simile/exhibit.rhtml
index 243971d21cf..e0a76862772 100644
--- a/client/ruby/flare/app/views/simile/exhibit.rhtml
+++ b/client/ruby/flare/app/views/simile/exhibit.rhtml
@@ -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>
diff --git a/client/ruby/flare/public/images/flare.jpg b/client/ruby/flare/public/images/flare.jpg
new file mode 100644
index 00000000000..5db42029267
Binary files /dev/null and b/client/ruby/flare/public/images/flare.jpg differ
diff --git a/client/ruby/flare/public/images/x-close.gif b/client/ruby/flare/public/images/x-close.gif
new file mode 100644
index 00000000000..27e7bc36e45
Binary files /dev/null and b/client/ruby/flare/public/images/x-close.gif differ
diff --git a/client/ruby/flare/public/stylesheets/flare.css b/client/ruby/flare/public/stylesheets/flare.css
index ff54d54a2d4..4323249f58c 100644
--- a/client/ruby/flare/public/stylesheets/flare.css
+++ b/client/ruby/flare/public/stylesheets/flare.css
@@ -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;