Skip to content

Commit

Permalink
make show categories linkable to search, adds in more button on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Dec 1, 2014
1 parent ced46f6 commit 3d51019
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/geoblacklight/modules/home.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
.category-block {
@extend .col-md-6;
@extend .text-center;
min-height: 200px;
min-height: 240px;

.category-icon {
font-size: 6em;
Expand Down
8 changes: 8 additions & 0 deletions app/helpers/geoblacklight_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,12 @@ def layer_access_image(access)
""
end
end

##
# Renders an unique array of search links based off of terms
# passed in using the facet parameter
#
def render_facet_links(facet, items)
items.uniq.map { |item| link_to item, catalog_index_path(f: { "#{facet}" => [item] }) }.join(', ').html_safe
end
end
2 changes: 1 addition & 1 deletion app/views/catalog/_facet_tag_item.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<% display_facet.items.each do |item| %>
<%= link_to item.value, catalog_index_path({f: {"#{facet_field.field}" => [item.value]}}), class: 'home-facet-link' %><%= "," unless item == display_facet.items.last %>
<%= link_to item.value, catalog_index_path({f: {"#{facet_field.field}" => [item.value]}}), class: 'home-facet-link' %><%= "," %>
<% end %>
3 changes: 2 additions & 1 deletion app/views/catalog/_facet_tag_layout.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
<%= yield %>
<%= yield %>
<%= link_to t('blacklight.search.facets.more'), catalog_facet_path(display_facet.name), class: 'more_facets_link' %>
4 changes: 4 additions & 0 deletions app/views/catalog/_home_text.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,28 @@
<div class='category-icon'>
<span class='glyphicon glyphicon-home'></span>
</div>
<h3>Institution</h3>
<%= render_facet_tags [:dct_provenance_s] %>
</div>
<div class='category-block'>
<div class='category-icon'>
<span class='glyphicon glyphicon-download'></span>
</div>
<h3>Data type</h3>
<%= render_facet_tags [:layer_geom_type_s] %>
</div>
<div class='category-block'>
<div class='category-icon'>
<span class='glyphicon glyphicon-globe'></span>
</div>
<h3>Placename</h3>
<%= render_facet_tags [:dct_spatial_sm] %>
</div>
<div class='category-block'>
<div class='category-icon'>
<span class='glyphicon glyphicon-tags'></span>
</div>
<h3>Subject</h3>
<%= render_facet_tags [:dc_subject_sm] %>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/views/catalog/_upper_metadata.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
<% end %>
<% unless document['dct_spatial_sm'].nil? %>
<dt>Places</dt>
<dd itemprop="spatial"><%= document['dct_spatial_sm'].sort.uniq.join(', ') %>&nbsp;</dd>
<dd itemprop="spatial"><%= render_facet_links('dct_spatial_sm', document['dct_spatial_sm']) %>&nbsp;</dd>
<% end %>
<% unless document['dc_subject_sm'].nil? %>
<dt>Subjects</dt>
<dd itemprop="keywords"><%= document['dc_subject_sm'].sort.uniq.join(', ') %>&nbsp;</dd>
<dd itemprop="keywords"><%= render_facet_links('dc_subject_sm', document['dc_subject_sm']) %>&nbsp;</dd>
<% end %>
<% unless document['dct_temporal_sm'].nil? %>
<dt>Years</dt>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/geoblacklight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ en:
home:
headline: 'Explore and discover...'
search_heading: 'Find the maps and data you need'
category_heading: 'Find by category'
category_heading: 'Find by...'
map_heading: 'Find by location'
tools:
login_to_view: 'Login to view and download'
1 change: 1 addition & 0 deletions spec/features/home_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
scenario 'find by category' do
expect(page).to have_css '.category-block', count: 4
expect(page).to have_css '.home-facet-link', count: 28
expect(page).to have_css 'a.more_facets_link', count: 4
click_link 'Census'
expect(page).to have_css '.filterName', text: 'Subject'
expect(page).to have_css '.filterValue', text: 'Census'
Expand Down
16 changes: 16 additions & 0 deletions spec/helpers/geoblacklight_helpers_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'spec_helper'

describe GeoblacklightHelper do
include GeoblacklightHelper
include ActionView::Helpers::UrlHelper
describe '#render_facet_links' do
it 'should contain unique links' do
expect(self).to receive(:catalog_index_path).exactly(3).times.and_return("http://example.com/catalog?f[dc_subject_sm][]=category")
html = Capybara.string(render_facet_links('dc_subject_sm', ['Test', 'Test', 'Earth', 'Science']))
expect(html).to have_css 'a', count: 3
expect(html).to have_css 'a', text: 'Test', count: 1
expect(html).to have_css 'a', text: 'Earth', count: 1
expect(html).to have_css 'a', text: 'Science', count: 1
end
end
end

0 comments on commit 3d51019

Please sign in to comment.