Skip to content

Commit 949faab

Browse files
committed
Merge pull request #845 from projectblacklight/layout-partials
extract partials and helper methods for reusable (or overridable) elements of the default blacklight layout
2 parents b1d54a3 + 5fb39c4 commit 949faab

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

app/helpers/blacklight/blacklight_helper_behavior.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,4 +575,10 @@ def presenter(document)
575575
def presenter_class
576576
Blacklight::DocumentPresenter
577577
end
578+
579+
##
580+
# Open Search discovery tag for HTML <head> links
581+
def opensearch_description_tag title, href
582+
tag :link, href: href, title: title, type: "application/opensearchdescription+xml", rel: "search"
583+
end
578584
end

app/views/layouts/blacklight.html.erb

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<![endif]-->
1515

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

33-
<div id="ajax-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal menu" aria-hidden="true">
34-
<div class="modal-dialog">
35-
<div class="modal-content">
36-
</div>
37-
</div>
38-
</div>
33+
<%= render partial: 'shared/ajax_modal' %>
3934

40-
<!-- /container -->
4135
<div id="main-container" class="container">
42-
<div class="row">
43-
<div class="col-md-12">
44-
<div id="main-flashes">
45-
<%= render :partial=>'/flash_msg' %>
46-
</div>
47-
</div>
48-
</div>
36+
<%= render :partial=>'/flash_msg', layout: 'shared/flash_messages' %>
4937

5038
<div class="row">
5139
<%= yield %>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<div id="ajax-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal menu" aria-hidden="true">
2+
<div class="modal-dialog">
3+
<div class="modal-content">
4+
</div>
5+
</div>
6+
</div>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="row">
2+
<div class="col-md-12">
3+
<div id="main-flashes">
4+
<%= yield %>
5+
</div>
6+
</div>
7+
</div>

spec/helpers/blacklight_helper_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,4 +532,24 @@ def mock_document_app_helper_url *args
532532
it { should eq 'one_two_three' }
533533
end
534534
end
535+
536+
describe "#opensearch_description_tag" do
537+
subject { helper.opensearch_description_tag 'title', 'href' }
538+
539+
it "should have a search rel" do
540+
expect(subject).to have_selector "link[rel='search']", visible: false
541+
end
542+
543+
it "should have the correct mime type" do
544+
expect(subject).to have_selector "link[type='application/opensearchdescription+xml']", visible: false
545+
end
546+
547+
it "should have a title attribute" do
548+
expect(subject).to have_selector "link[title='title']", visible: false
549+
end
550+
551+
it "should have an href attribute" do
552+
expect(subject).to have_selector "link[href='href']", visible: false
553+
end
554+
end
535555
end

0 commit comments

Comments
 (0)