Skip to content

Commit

Permalink
Merge pull request #1145 from sul-dlss/avoid_html_safe
Browse files Browse the repository at this point in the history
Avoid the use of html_safe for the Stanford-only icon
  • Loading branch information
corylown authored Aug 26, 2024
2 parents 32aa599 + de1e95f commit b7822b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-08-19 13:52:42 UTC using RuboCop version 1.65.1.
# on 2024-08-19 17:28:43 UTC using RuboCop version 1.65.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down
5 changes: 4 additions & 1 deletion app/components/bibliographic_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ def middle_fields
mods.nestedRelatedItem(value_renderer: Purl::RelatedItemValueRenderer)
end

# Adds the "Stanford only" red "S" if this is via the OCLC proxy
def build_transformer(field)
->(value) { format_mods_html(value, field:) + with_stanford_only(value) }
end

def with_stanford_only(value)
return unless value.downcase.include?('https://stanford.idm.oclc.org/login?url=')

'<span class="stanford-only-text"><span class="visually-hidden">Stanford only </span></span>'.html_safe
tag.span class: 'stanford-only-text' do
tag.span 'Stanford only', class: 'visually-hidden'
end
end
end

0 comments on commit b7822b9

Please sign in to comment.