Skip to content

Commit

Permalink
reorganize homepage to be consistent with design
Browse files Browse the repository at this point in the history
  • Loading branch information
mejackreed committed Nov 18, 2014
1 parent 127ef33 commit 93dc953
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 33 deletions.
23 changes: 21 additions & 2 deletions app/assets/stylesheets/geoblacklight/modules/home.css.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
[data-map="home"] {
height: 600px;
}
height: 400px;
}

.home-search-area {
text-align: center;
}

.home-facet-label {
background: $gray-light;
border-radius: .25em;
color: #fff;
font-size: 1.4em;
line-height: 2em;
padding: .2em .6em .3em;
text-align: center;

&:hover {
color: #fff;
text-decoration: none;
}
}
4 changes: 4 additions & 0 deletions app/helpers/geoblacklight_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def snippit(text)
end
end

def render_facet_tags(facet)
render_facet_limit(facets_from_request(facet).first, partial: 'facet_tag_item', layout: 'facet_tag_layout')
end

def layer_type_image(type)
content_tag :span, '', class: "geoblacklight-icon geoblacklight-#{type.downcase}"
end
Expand Down
3 changes: 3 additions & 0 deletions app/views/catalog/_facet_tag_item.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% display_facet.items.each do |item| %>
<%= link_to item.value, catalog_index_path({f: {"#{facet_field.field}" => [item.value]}}), class: 'home-facet-label' %>
<% end %>
1 change: 1 addition & 0 deletions app/views/catalog/_facet_tag_layout.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= yield %>
19 changes: 17 additions & 2 deletions app/views/catalog/_home_text.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<div id='row'>
<%= content_tag :div, '', id: 'map', data: { map: 'home', 'catalog-path'=> catalog_index_path , 'map-bbox' => params[:bbox]} %>
<div class='jumbotron'>
<div class='home-search-area'>
<%= content_tag :h2, t('geoblacklight.home.headline') %>
<%= content_tag :h3, t('geoblacklight.home.search_heading') %>
<%= render_search_bar %>
</div>
</div>

<div class='row'>
<div class='col-md-6 text-center'>
<%= content_tag :h4, t('geoblacklight.home.category_heading') %>
<%= render_facet_tags [:dc_subject_sm] %>
</div>
<div class='col-md-6 text-center'>
<%= content_tag :h4, t('geoblacklight.home.map_heading') %>
<%= content_tag :div, '', id: 'map', data: { map: 'home', 'catalog-path'=> catalog_index_path , 'map-bbox' => params[:bbox]} %>
</div>
</div>
12 changes: 12 additions & 0 deletions app/views/catalog/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% unless has_search_parameters? %>
<%# if there are no input/search related params, display the "home" partial -%>
<%= render 'home' %>
<% else %>
<div id="sidebar" class="col-md-3 col-sm-4">
<%= render 'search_sidebar' %>
</div>

<div id="content" class="col-md-9 col-sm-8">
<%= render 'search_results' %>
</div>
<% end %>
25 changes: 25 additions & 0 deletions app/views/shared/_header_navbar.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div id="header-navbar" class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#user-util-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<%= link_to application_name, root_path, class: "navbar-brand" %>
</div>

<div class="collapse navbar-collapse" id="user-util-collapse">
<%= render :partial=>'/user_util_links' %>
</div>
</div>
</div>

<% unless current_page?(root_url) %>
<div id="search-navbar" class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<%= render_search_bar %>
</div>
</div>
<% end %>
5 changes: 5 additions & 0 deletions config/locales/geoblacklight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@ en:
download:
success: 'Your file %{title} is ready for download'
error: 'Sorry, the requested file could not be downloaded'
home:
headline: 'Explore and discover...'
search_heading: 'Find the maps and data you need'
category_heading: 'Find by category'
map_heading: 'Find by location'
tools:
login_to_view: 'Login to view and download'
42 changes: 14 additions & 28 deletions spec/features/home_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,24 @@
before do
visit root_path
end
scenario 'should have facets listed correctly' do
within '#facet-panel-collapse' do
expect(page).to have_css('div.panel.facet_limit', text: 'Institution')
expect(page).to have_css('div.panel.facet_limit', text: 'Publisher')
expect(page).to have_css('div.panel.facet_limit', text: 'Subject')
expect(page).to have_css('div.panel.facet_limit', text: 'Place')
expect(page).to have_css('div.panel.facet_limit', text: 'Year')
expect(page).to have_css('div.panel.facet_limit', text: 'Access')
expect(page).to have_css('div.panel.facet_limit', text: 'Data type')
expect(page).to have_css('div.panel.facet_limit', text: 'Format')
expect(page).to have_css('div.panel.facet_limit', text: 'Language')
scenario 'search bar' do
expect(page).to_not have_css '#search-navbar'
within '.jumbotron' do
expect(page).to have_css 'h2', text: 'Explore and discover...'
expect(page).to have_css 'h3', text: 'Find the maps and data you need'
expect(page).to have_css 'form.search-query-form'
end
click_link 'Institution'
expect(page).to have_css('a.facet_select', text: 'Harvard', visible: true)
expect(page).to have_css('a.facet_select', text: 'Tufts', visible: true)
expect(page).to have_css('a.facet_select', text: 'MIT', visible: true)
expect(page).to have_css('a.facet_select', text: 'MassGIS', visible: true)
expect(page).to have_css('a.facet_select', text: 'Stanford', visible: true)
end
scenario 'find by category' do
expect(page).to have_css '.home-facet-label', count: 7
click_link 'Census'
expect(page).to have_css '.filterName', text: 'Subject'
expect(page).to have_css '.filterValue', text: 'Census'
end
scenario 'map should be visible' do
within '#content' do
within '#main-container' do
expect(page).to have_css('#map')
expect(page).to have_css('img.leaflet-tile', count: 16)
expect(page).to have_css('img.leaflet-tile', count: 4)
end
end
scenario 'clicking map search should create a spatial search' do
Expand All @@ -37,13 +32,4 @@
end
expect(page).to have_css '#documents'
end

scenario 'clicking map search should retain current search parameters' do
visit '/?f[dc_subject_sm][]=polygon&f[dc_subject_sm][]=boundaries'
find('#map').double_click
within '#appliedParams' do
expect(page).to have_content('Subject polygon')
expect(page).to have_content('Subject boundaries')
end
end
end
32 changes: 31 additions & 1 deletion spec/features/split_view.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,39 @@

feature 'Index view', js: true do
before do
visit catalog_index_path( f: { dct_provenance_s: ['Stanford']})
visit catalog_index_path(q: '*')
end

scenario 'should have documents and map on page' do
visit catalog_index_path(f: { dct_provenance_s: ['Stanford']})
expect(page).to have_css('#documents')
expect(page).to have_css(".document", count: 2)
expect(page).to have_css('#map')
end

scenario 'should have facets listed correctly' do
within '#facet-panel-collapse' do
expect(page).to have_css('div.panel.facet_limit', text: 'Institution')
expect(page).to have_css('div.panel.facet_limit', text: 'Publisher')
expect(page).to have_css('div.panel.facet_limit', text: 'Subject')
expect(page).to have_css('div.panel.facet_limit', text: 'Place')
expect(page).to have_css('div.panel.facet_limit', text: 'Year')
expect(page).to have_css('div.panel.facet_limit', text: 'Access')
expect(page).to have_css('div.panel.facet_limit', text: 'Data type')
expect(page).to have_css('div.panel.facet_limit', text: 'Format')
expect(page).to have_css('div.panel.facet_limit', text: 'Language')
end
click_link 'Institution'
expect(page).to have_css('a.facet_select', text: 'Harvard', visible: true)
expect(page).to have_css('a.facet_select', text: 'Tufts', visible: true)
expect(page).to have_css('a.facet_select', text: 'MIT', visible: true)
expect(page).to have_css('a.facet_select', text: 'MassGIS', visible: true)
expect(page).to have_css('a.facet_select', text: 'Stanford', visible: true)
end

scenario 'hover on record should produce bounding box on map' do
# Needed to find an svg element on the page
visit catalog_index_path(f: { dct_provenance_s: ['Stanford']})
expect(Nokogiri::HTML.parse(page.body).css('path').length).to eq 0
find('.documentHeader', match: :first).trigger(:mouseover)
expect(Nokogiri::HTML.parse(page.body).css('path').length).to eq 1
Expand All @@ -32,4 +54,12 @@
expect(find('.page_entries')).to have_content('1 - 10')
end

scenario 'clicking map search should retain current search parameters' do
visit '/?f[dc_subject_sm][]=polygon&f[dc_subject_sm][]=boundaries'
find('#map').double_click
within '#appliedParams' do
expect(page).to have_content('Subject polygon')
expect(page).to have_content('Subject boundaries')
end
end
end

0 comments on commit 93dc953

Please sign in to comment.