Skip to content

Commit

Permalink
🐛 Add custom rendering for license
Browse files Browse the repository at this point in the history
Prior to this commit, the License would render as a plain URL.  With
this change, we are now coercing the license into a URL that is labeled
and titled with the name of the license.

This is copied and modified based on [Rights show partial][1]

Related to:

- https://github.com/scientist-softserv/adventist-dl/issues/620

[1]: https://github.com/samvera/hyrax/blob/b334e186e77691d7da8ed59ff27f091be1c2a700/app/views/records/show_fields/_rights.html.erb
  • Loading branch information
jeremyf committed Oct 10, 2023
1 parent f8eee24 commit 1c2a9d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,7 @@ Metrics/BlockLength:
- 'spec/**/*.rb'
- 'lib/tasks/*.rake'
- 'app/controllers/catalog_controller.rb'

RSpec/FilePath:
Exclude:
- 'spec/config/application_spec.rb'
2 changes: 0 additions & 2 deletions app/services/uploaded_collection_thumbnail_path_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ def call(object)
"/uploads/uploaded_collection_thumbnails/#{object.id}/#{object.id}_card.jpg"
end

# rubocop:disable Metrics/LineLength, Rails/FilePath
def uploaded_thumbnail?(collection)
File.exist?(File.join(upload_dir(collection), "#{collection.id}_card.jpg"))
end

def upload_dir(collection)
Hyku::Application.path_for("public/uploads/uploaded_collection_thumbnails/#{collection.id}")
end
# rubocop:enable Metrics/LineLength, Rails/FilePath
end
end
4 changes: 4 additions & 0 deletions app/views/records/show_fields/_license.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<% service = Hyrax::LicenseService.new %>
<% record.license.each do |r| %>
<%= link_to_field('license', r, service.label(r)) %> <%= iconify_auto_link(r, false) %><br />
<% end %>

0 comments on commit 1c2a9d4

Please sign in to comment.