Skip to content

Commit

Permalink
Merge pull request #845 from projectblacklight/layout-partials
Browse files Browse the repository at this point in the history
extract partials and helper methods for reusable (or overridable) elements of the default blacklight layout
  • Loading branch information
jcoyne committed Mar 19, 2014
2 parents b1d54a3 + 5fb39c4 commit 949faab
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 15 deletions.
6 changes: 6 additions & 0 deletions app/helpers/blacklight/blacklight_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -575,4 +575,10 @@ def presenter(document)
def presenter_class
Blacklight::DocumentPresenter
end

##
# Open Search discovery tag for HTML <head> links
def opensearch_description_tag title, href
tag :link, href: href, title: title, type: "application/opensearchdescription+xml", rel: "search"
end
end
18 changes: 3 additions & 15 deletions app/views/layouts/blacklight.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<![endif]-->

<title><%= render_page_title %></title>
<link href="<%= opensearch_catalog_path(:format => 'xml', :only_path => false) %>" title="<%= application_name%>" type="application/opensearchdescription+xml" rel="search"/>
<%= opensearch_description_tag application_name, opensearch_catalog_path(:format => 'xml', :only_path => false) %>
<%= favicon_link_tag asset_path('favicon.ico') %>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
Expand All @@ -30,22 +30,10 @@
<body class="<%= render_body_class %>">
<%= render :partial => 'shared/header_navbar' %>

<div id="ajax-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal menu" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
<%= render partial: 'shared/ajax_modal' %>

<!-- /container -->
<div id="main-container" class="container">
<div class="row">
<div class="col-md-12">
<div id="main-flashes">
<%= render :partial=>'/flash_msg' %>
</div>
</div>
</div>
<%= render :partial=>'/flash_msg', layout: 'shared/flash_messages' %>

<div class="row">
<%= yield %>
Expand Down
6 changes: 6 additions & 0 deletions app/views/shared/_ajax_modal.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<div id="ajax-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal menu" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
</div>
</div>
</div>
7 changes: 7 additions & 0 deletions app/views/shared/_flash_messages.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="row">
<div class="col-md-12">
<div id="main-flashes">
<%= yield %>
</div>
</div>
</div>
20 changes: 20 additions & 0 deletions spec/helpers/blacklight_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -532,4 +532,24 @@ def mock_document_app_helper_url *args
it { should eq 'one_two_three' }
end
end

describe "#opensearch_description_tag" do
subject { helper.opensearch_description_tag 'title', 'href' }

it "should have a search rel" do
expect(subject).to have_selector "link[rel='search']", visible: false
end

it "should have the correct mime type" do
expect(subject).to have_selector "link[type='application/opensearchdescription+xml']", visible: false
end

it "should have a title attribute" do
expect(subject).to have_selector "link[title='title']", visible: false
end

it "should have an href attribute" do
expect(subject).to have_selector "link[href='href']", visible: false
end
end
end

0 comments on commit 949faab

Please sign in to comment.