Skip to content

Commit

Permalink
Merge pull request #240 from pulibrary/i236-change-banner-text
Browse files Browse the repository at this point in the history
Render HTML from banner config
  • Loading branch information
kelynch authored Mar 18, 2022
2 parents 0e85789 + d02b8a9 commit 4be9664
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ Metrics/BlockLength:
Rails/Output:
Exclude:
- app/lib/cli.rb

RSpec/AnyInstance:
Exclude:
- spec/lib/research_data_harvester_spec.rb

RSpec/ExampleLength:
Exclude:
- spec/lib/research_data_collection_spec.rb
- spec/system/banner_spec.rb

Rails/UnknownEnv:
Enabled: false
4 changes: 2 additions & 2 deletions app/helpers/banner_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module BannerHelper
def banner_content
@yaml_data = YAML.load_file('config/banner.yml')
return false if @yaml_data[Rails.env].nil?
@banner_title = content_tag(:h1, @yaml_data[Rails.env]['title'])
@banner_body = content_tag(:p, @yaml_data[Rails.env]['body'])
@banner_title = "<h1>#{@yaml_data[Rails.env]['title']}</h1>"
@banner_body = "<p>#{@yaml_data[Rails.env]['body']}</p>"
end
# rubocop:enable Rails/ContentTag
end
4 changes: 2 additions & 2 deletions app/views/shared/_banner.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if banner_content %>
<div id="banner">
<%= @banner_title %>
<%= @banner_body %>
<%= sanitize @banner_title %>
<%= sanitize @banner_body %>
</div>
<% end %>
13 changes: 7 additions & 6 deletions config/banner.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
development:
title: Welcome to the development site
body: This is a message for development
test:
title: Welcome to the test site
body: This is a message for test
title: Welcome to the <i>test</i> site
body: This is a <b>test</b> <a href="mailto:[email protected]">message.</a>
staging:
title: Welcome to the staging site
body: This is a message for staging
title: Welcome to Princeton Data Commons Discovery (Staging)!
body: PRDS is proud to share our new website for the discovery and sharing of research data. Have a look around and <a href="mailto:[email protected]">let us know what you think.</a>
production:
title: Welcome to the production site
body: This is a message for production
title: Welcome to Princeton Data Commons Discovery!
body: PRDS is proud to share our new website for the discovery and sharing of research data. Have a look around and <a href="mailto:[email protected]">let us know what you think.</a>
9 changes: 9 additions & 0 deletions spec/system/banner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,13 @@
visit '/catalog/78348'
expect(page).to have_css '#banner'
end

it "renders html tags in the banner" do
visit '/catalog/78348'
expect(page).not_to have_content "<i>test</i>"
expect(page.find("div#banner h1 i").text).to eq "test"
expect(page).not_to have_content "<b>test</b>"
expect(page.find("div#banner p b").text).to eq "test"
expect(page).to have_link "message", href: "mailto:[email protected]"
end
end

0 comments on commit 4be9664

Please sign in to comment.