Skip to content

Commit

Permalink
enhancement: show the topic type within search results. Only show the…
Browse files Browse the repository at this point in the history
… exact one, but has ability to display heirarchy (Topic -> Person)
  • Loading branch information
Kieran Pilkington committed Nov 13, 2009
1 parent d8a9743 commit 46b04e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/views/search/_generic.rhtml
Expand Up @@ -2,6 +2,11 @@
<div class="generic-result-header">
<h4><%= link_to h(title), source_url, :tabindex => '1' %></h4>
</div>
<% if topic_types %>
<div class="generic-result-topic-type">
Topic type: <%= topic_types.last %>
</div>
<% end %>
<div class="generic-result-description">
<%= strip_tags(short_summary) %>
<div class="generic-result-more">
Expand Down
3 changes: 2 additions & 1 deletion app/views/search/_results.rhtml
Expand Up @@ -91,7 +91,8 @@
:short_summary => result[:short_summary],
:related => result[:related],
:result => result[:id],
:first_result => (index == 0) } -%>
:first_result => (index == 0),
:topic_types => result[:topic_types] } -%>
<% if result[:class] == 'StillImage' %>
<%= render(:partial => "image", :locals => locals.merge({ :locally_hosted => result[:locally_hosted],
Expand Down
8 changes: 8 additions & 0 deletions lib/zoom_search.rb
Expand Up @@ -238,6 +238,14 @@ def parse_from_xml_in(zoom_record)
result_hash[field_name.to_sym] = field_value
end

# determine the topic type(s)
topic_type_names = TopicType.all(:select => 'name').collect { |topic_type| topic_type.name }
result_hash[:topic_types] = Array.new
oai_dc.xpath(".//dc:coverage", oai_dc.namespaces).each do |node|
value = node.content.strip
result_hash[:topic_types] << value if topic_type_names.include?(value)
end

# get coverage values, these can be used for geographic values or temporal information
location_or_temporal_nodes = oai_dc.xpath(".//dc:coverage", oai_dc.namespaces).select { |node| !node.content.scan(":").blank? }

Expand Down

0 comments on commit 46b04e2

Please sign in to comment.