humanize facet labels, more config work

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@519127 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2007-03-16 20:21:02 +00:00
parent f1c149f8fb
commit 5f5bd3b620
6 changed files with 19 additions and 13 deletions

View File

@ -3,4 +3,7 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def facet_label(field)
field.match(/(.*)_.*/)[1].humanize.downcase
end
end

View File

@ -7,6 +7,7 @@
</div>
<!-- <h2>browse facets</h2> -->
<% if @flare.facet_queries.size > 0%>
<h4>
saved searches
</h4>
@ -22,10 +23,10 @@
</li>
<% end %>
</ul>
<% end %>
<% @flare.facet_fields.each do |field|%>
<h4>
<%=h field%> <%=link_to "[browse]", :action => 'facet', :field => field%>
<%= facet_label(field)%> <%=link_to "[browse]", :action => 'facet', :field => field%>
<!-- <%=link_to field, :action => 'facet', :field => field%> -->
</h4>

View File

@ -16,7 +16,7 @@
<div id="exhibit-view-panel"></div>
</td>
<td width="25%">
<div id="exhibit-browse-panel" ex:facets="<%= SOLR_CONFIG[:exhibit_facets] -%>"></div>
<div id="exhibit-browse-panel" ex:facets="<%= @flare.facet_fields.collect {|f| ".#{f}"}.join(',') -%>"></div>
</td>
</tr>
</table>

View File

@ -15,7 +15,8 @@ xml.data do
xml.event(doc['title_text'],
:start => doc[SOLR_CONFIG[:timeline_dates].to_s],
:end => doc[SOLR_CONFIG[:timeline_dates].to_s],
:title => doc['title_text'])
:title => doc['title_text'],
:image => SOLR_CONFIG[:image_proc] ? SOLR_CONFIG[:image_proc].call(doc) : nil)
end
end

View File

@ -67,9 +67,8 @@ solr_environments = {
},
:delicious => {
# :image_url => Proc.new {|d| "http://images.amazon.com/images/P/#{d[:asin_text]}.01.MZZZZZZZ"},
:timeline_dates => :published_year_facet,
:exhibit_facets => ".medium_facet, .country_facet, .signed_facet, .rating_facet, .language_facet, .genre_facet, .publisher_facet, .published_year_facet"
:image_proc => Proc.new {|doc| "http://images.amazon.com/images/P/#{doc['asin_text']}.01.MZZZZZZZ"}
},
:tang => {
@ -77,12 +76,12 @@ solr_environments = {
:marc => {
:timeline_dates => :year_facet,
:exhibit_facets => ".subject_genre_facet, .subject_era_facet, .subject_topic_facet, .subject_geographic_facet, .year_facet"
},
# TODO: :uva could inherit :marc settings, only overriding the template for VIRGO links
:uva => {
:timeline_dates => :year_facet
:timeline_dates => :year_facet,
:facets_exclude => [:filename_facet]
},
}
SOLR_ENV = ENV["SOLR_ENV"] || "development"

View File

@ -16,27 +16,29 @@ class FlareContext
attr_reader :facet_fields, :text_fields
def initialize(solr_config)
@connection = Solr::Connection.new(solr_config[:solr_url])
@solr_config = solr_config
@connection = Solr::Connection.new(@solr_config[:solr_url])
clear
@facet_queries = {} # name => {:queries => [], :filters => []}
puts "initialize\n-------","#{solr_config.inspect}"
@index_info = @connection.send(Solr::Request::IndexInfo.new)
excluded = @solr_config[:facets_exclude] ? @solr_config[:facets_exclude].collect {|e| e.to_s} : []
@facet_fields = @index_info.field_names.find_all {|v| v =~ /_facet$/} - excluded
@facet_fields = @index_info.field_names.find_all {|v| v =~ /_facet$/}
@text_fields = @index_info.field_names.find_all {|v| v =~ /_text$/}
end
def clear
puts "clear\n-------"
@queries = []
@filters = []
@applied_facet_queries = []
# this is cleared for development purposes - allowing flare to stay running but different Solr datasets swapping
@index_info = @connection.send(Solr::Request::IndexInfo.new)
@facet_fields = @index_info.field_names.find_all {|v| v =~ /_facet$/}
excluded = @solr_config[:facets_exclude] ? @solr_config[:facets_exclude].collect {|e| e.to_s} : []
@facet_fields = @index_info.field_names.find_all {|v| v =~ /_facet$/} - excluded
@text_fields = @index_info.field_names.find_all {|v| v =~ /_text$/}
# facet_queries not cleared as their lifetime is different than constraints