Skip to content

Commit

Permalink
Add field thumbnail_link, imported from "Thumbnail" (#876)
Browse files Browse the repository at this point in the history
If populated, will be used for `thumbnail_url_ss`, which is used by Ursus for thumbnails. If not populated, `access_copy` will continue to be used.
  • Loading branch information
sourcefilter authored May 24, 2021
1 parent ae83339 commit 5816ef6
Show file tree
Hide file tree
Showing 34 changed files with 265 additions and 215 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
pull_request:
branches: [ main ]

# env:
# COMPOSE_FILE: docker-compose-ci.yml

jobs:
rubocop:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ public/branding/

.DS_Store
.vscode/
.devcontainer/

2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.1
2.5.8
11 changes: 10 additions & 1 deletion app/assets/markdown/importer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
- [Tagline](#tagline)
- [IIIF Text direction](#iiif_text_direction)
- [Table of Contents](#table-of-contents)
- [Thumbnail](#thumbnail)
- [Translator](#translator)
- [Type.genre](#type.genre)
- [Type.typeOfResource](#type.typeofresource)
Expand Down Expand Up @@ -256,7 +257,7 @@ The URL of a IIIF resource that can be used to view the image. This is populated

### Illuminator

Also aaccepts: `Name.illuminator`
Also accepts: `Name.illuminator`

### Illustrations note

Expand Down Expand Up @@ -354,6 +355,14 @@ Also accepts: `Description.tableOfContents`

### Tagline

### Thumbnail

URL for an image to be used as the thumbnail. Must be the stem of a IIIF Image API resource of the form `{scheme}://{server}{/prefix}/{identifier}`, omitting all other Image API parameters. For example: `https://iiif.library.ucla.edu/iiif/2/ark%3A%2F21198%2Fz1k667gp`.

For simple images the value will be identical to [`IIIF Access URL`](#iiif-access-url), however for other content types such as multi-image or audiovisual works the two values wil differ.

This is populated by processing the CSV via [bucketeer](https://bucketeer.library.ucla.edu/upload/csv)

### Translator

Also accepts: `Name.translator`
Expand Down
1 change: 1 addition & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ def self.modified_field
config.add_show_field 'summary_tesim'
config.add_show_field 'iiif_text_direction_ssi'
config.add_show_field 'toc_tesim'
config.add_show_field 'thumbnail_link_ssi'
config.add_show_field 'translator_tesim'
config.add_show_field 'uniform_title_tesim'
config.add_show_field 'representative_image_ssi'
Expand Down
2 changes: 2 additions & 0 deletions app/forms/hyrax/californica_collections_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class CalifornicaCollectionsForm < Hyrax::Forms::CollectionForm
:subject_temporal,
:subject_topic,
:tagline,
:thumbnail_link,
:summary,
:toc,
:translator,
Expand Down Expand Up @@ -140,6 +141,7 @@ def secondary_terms
:subject_topic,
:summary,
:toc,
:thumbnail_link,
:translator,
:iiif_text_direction,
:uniform_title,
Expand Down
3 changes: 2 additions & 1 deletion app/forms/hyrax/work_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class WorkForm < Hyrax::Forms::WorkForm
:support,
:tagline,
:toc,
:thumbnail_link,
:translator,
:iiif_text_direction,
:uniform_title
Expand All @@ -81,7 +82,7 @@ class WorkForm < Hyrax::Forms::WorkForm
#
# @return [Enumerable<Symbol>] symbols representing each primary term
def primary_terms
primary = required_fields + [:access_copy, :preservation_copy]
primary = required_fields + [:access_copy, :preservation_copy, :thumbnail_link]
primary = (primary & terms)

(required_fields - primary).each do |missing|
Expand Down
7 changes: 6 additions & 1 deletion app/importers/californica_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CalifornicaMapper < Darlingtonia::HashMapper
attr_reader :row_number

CALIFORNICA_TERMS_MAP = {
access_copy: ["IIIF Access URL", "access_copy", "Thumbnail"],
access_copy: ["IIIF Access URL", "access_copy"],
alternative_title: ["AltTitle.other",
"AltTitle.parallel",
"AltTitle.translated",
Expand Down Expand Up @@ -96,6 +96,7 @@ class CalifornicaMapper < Darlingtonia::HashMapper
"Subject place"],
subject_temporal: "Subject temporal",
iiif_text_direction: "Text direction",
thumbnail_link: ["Thumbnail"],
translator: ["Translator", "Name.translator"],
title: "Title",
toc: ["Table of Contents", "Description.tableOfContents"],
Expand Down Expand Up @@ -409,4 +410,8 @@ def in_works_ids
record_page_sequence
[parent_work.id]
end

def thumbnail_link
map_field(:thumbnail_link).to_a.first
end
end
24 changes: 17 additions & 7 deletions app/indexers/collection_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,31 @@ def solr_during_indexing
end

def thumbnail_url
iiif_url_base = Californica::ManifestBuilderService.new(curation_concern: object).iiif_url
thumbnail = object.thumbnail_link || thumbnail_from_access_copy
if thumbnail.to_s.include?('/iiif/2/')
"#{thumbnail}/full/!200,200/0/default.jpg"
elsif ['.svg', '.png', '.jpg'].include? File.extname(thumbnail.to_s)
thumbnail
else
return nil
end
end

def thumbnail_from_access_copy
iiif_resource = Californica::ManifestBuilderService.new(curation_concern: object).iiif_url

children = Array.wrap(object.members).clone
until iiif_url_base || children.empty?
until iiif_resource || children.empty?
child = children.shift
iiif_url_base = Californica::ManifestBuilderService.new(curation_concern: child).iiif_url
iiif_resource = Californica::ManifestBuilderService.new(curation_concern: child).iiif_url

grandchildren = Array.wrap(child.members).clone
until iiif_url_base || grandchildren.empty?
until iiif_resource || grandchildren.empty?
grandchild = grandchildren.shift
iiif_url_base = Californica::ManifestBuilderService.new(curation_concern: grandchild).iiif_url
iiif_resource = Californica::ManifestBuilderService.new(curation_concern: grandchild).iiif_url
end
end

return nil unless iiif_url_base
"#{iiif_url_base}/full/!200,200/0/default.jpg"
iiif_resource
end
end
21 changes: 15 additions & 6 deletions app/indexers/work_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,25 @@ def human_readable_rights_statement
end

def thumbnail_url
thumbnail = object.thumbnail_link || thumbnail_from_access_copy
if thumbnail.to_s.include?('/iiif/2/')
"#{thumbnail}/full/!200,200/0/default.jpg"
elsif ['.svg', '.png', '.jpg'].include? File.extname(thumbnail.to_s)
thumbnail
else
return nil
end
end

def thumbnail_from_access_copy
# this record has an image path attached
iiif_url_base = Californica::ManifestBuilderService.new(curation_concern: object).iiif_url
iiif_resource = Californica::ManifestBuilderService.new(curation_concern: object).iiif_url
children = Array.wrap(object.members).clone
until iiif_url_base || children.empty?
until iiif_resource || children.empty?
child = children.shift
iiif_url_base = Californica::ManifestBuilderService.new(curation_concern: child).iiif_url
iiif_resource = Californica::ManifestBuilderService.new(curation_concern: child).iiif_url
end

return nil unless iiif_url_base
"#{iiif_url_base}/full/!200,200/0/default.jpg"
iiif_resource
end

# The 'to_a' is needed to force ActiveTriples::Relation to resolve into the String value(s), else you get an error trying to parse the date.
Expand Down
8 changes: 8 additions & 0 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,14 @@ def tagline
self[:tagline_ssi]
end

def thumbnail_link
self[:thumbnail_link_ssi]
end

def thumbnail_url
self[:thumbnail_url_ss]
end

def translator
self[:translator_tesim]
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/ucla_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ module UclaMetadata
property :tagline, predicate: ::RDF::URI.intern('http://iflastandards.info/ns/fr/frbr/frbrer/P3081'), multiple: false do |index|
index.as :stored_sortable
end

property :thumbnail_link, predicate: ::RDF::URI.intern('http://pcdm.org/use#ThumbnailImage'), multiple: false do |index|
index.as :stored_sortable
end
end
end

Expand Down
1 change: 1 addition & 0 deletions app/presenters/hyrax/californica_collection_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def self.terms
:support,
:summary,
:tagline,
:thumbnail_link,
:iiif_text_direction,
:translator,
:toc,
Expand Down
1 change: 1 addition & 0 deletions app/presenters/hyrax/work_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class WorkPresenter < Hyrax::WorkShowPresenter
:summary,
:support,
:tagline,
:thumbnail_link,
:translator,
:toc,
:iiif_text_direction,
Expand Down
38 changes: 18 additions & 20 deletions app/uploaders/csv_manifest_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
].freeze

REQUIRED_VALUES = [
['Item ARK', ['Collection', 'Work', 'ChildWork', 'Manuscript', 'Page']],
['Title', ['Collection', 'Work', 'Manuscript']],
['IIIF Manifest URL', ['Collection', 'Work']],
['Item ARK', ['Collection', 'Work', 'ChildWork', 'Manuscript', 'Page'], :error],
['Title', ['Collection', 'Work', 'Manuscript'], :error],
['IIIF Manifest URL', ['Collection', 'Work'], :error],
# ['Object Type', ['Collection', 'Work']], # hard-coded
['Parent ARK', ['Work', 'ChildWork', 'Manuscript', 'Page']],
['Rights.copyrightStatus', ['Work', 'ChildWork', 'Manuscript', 'Page']],
['File Name', ['Work', 'ChildWork', 'Page']]
['Parent ARK', ['Work', 'ChildWork', 'Manuscript', 'Page'], :warning],
['Rights.copyrightStatus', ['Work', 'ChildWork', 'Manuscript', 'Page'], :warning],
['File Name', ['Work', 'ChildWork', 'Page'], :warning],
['Thumbnail', ['Work', 'ChildWork', 'Manuscript', 'Page'], :warning]
].freeze

MAPPED_HEADERS = CalifornicaMapper.californica_terms_map.values.map { |v| Array.wrap(v) }.flatten.freeze
Expand Down Expand Up @@ -132,7 +133,7 @@ def duplicate_headers
end

def validate_records
required_column_numbers = REQUIRED_VALUES.map { |header, _object_types| @headers.find_index(header) }.compact
required_column_numbers = REQUIRED_VALUES.map { |header, _object_types, _message_type| @headers.find_index(header) }.compact
controlled_column_numbers = CONTROLLED_VOCABULARIES.keys.map { |header| @headers.find_index(header) }.compact
object_type_column = @headers.find_index('Object Type')
row_warnings = Hash.new { |hash, key| hash[key] = [] }
Expand Down Expand Up @@ -168,19 +169,16 @@ def validate_records

# Row missing reqired field values
required_column_numbers.each_with_index do |column_number, j|
field_label, types_that_require = REQUIRED_VALUES[j]
next this_row_errors << "Rows missing required value for \"#{REQUIRED_VALUES[j][0]}\". Your spreadsheet must have this value." if field_label == 'Title' && row[column_number].blank?
next this_row_errors << "Rows missing required value for \"#{REQUIRED_VALUES[j][0]}\". Your spreadsheet must have this value." if field_label == 'Item ARK' && row[column_number].blank?
next this_row_errors << "Rows missing required value for \"#{REQUIRED_VALUES[j][0]}\". Your spreadsheet must have this value." if field_label == 'IIIF Manifest URL' && !object_type.include?("Page") && row[column_number].blank?
next unless types_that_require.include?(object_type)
next unless row[column_number].blank?
this_row_warnings << if field_label == 'Rights.copyrightStatus'
'Rows missing "Rights.copyrightStatus" will have the value set to "unknown".'
elsif field_label == 'File Name'
'Rows missing "File Name" will import metadata-only.'
elsif field_label != 'Title' || field_label != 'Item ARK' || field_label != 'IIIF Manifest URL'
"Rows missing \"#{REQUIRED_VALUES[j][0]}\" cannot be imported." # Debug details #{REQUIRED_VALUES.map { |header, _object_types| header }} #{required_column_numbers}
end
field_label, types_that_require, message_type = REQUIRED_VALUES[j]
next unless row[column_number].blank? && types_that_require.include?(object_type)
case message_type
when :error
this_row_errors << "Rows missing required value for \"#{REQUIRED_VALUES[j][0]}\". Your spreadsheet must have this value."
when :warning
this_row_warnings << "Rows missing recommended value for \"#{REQUIRED_VALUES[j][0]}\". Please add this value or continue to import without."
else
raise "CsvManifestValidator::REQUIRED_VALUES contains unknown message_type #{message_type} for #{field_label}."
end
end

# Row has invalid value in a controlled-vocabulary field
Expand Down
4 changes: 2 additions & 2 deletions app/views/hyrax/base/_attribute_rows.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
<%= presenter.attribute_to_html(:rights_holder, html_dl: true) %>
<%= presenter.attribute_to_html(:rights_statement, render_as: :rights_statement, html_dl: true) %>
<%= presenter.attribute_to_html(:rubricator, html_dl: true) %>
# This invokes License renderer from hyrax gem
<%#= presenter.attribute_to_html(:local_rights_statement, render_as: :local_rights_statement, html_dl: true) %>
<%#= presenter.attribute_to_html(:local_rights_statement, render_as: :local_rights_statement, html_dl: true) # This invokes License renderer from hyrax gem %>
<%= presenter.attribute_to_html(:scribe, html_dl: true) %>
<%= presenter.attribute_to_html(:source, html_dl: true) %>
<%= presenter.attribute_to_html(:subject, render_as: :faceted, html_dl: true) %>
Expand All @@ -73,6 +72,7 @@
<%= presenter.attribute_to_html(:summary, html_dl: true) %>
<%= presenter.attribute_to_html(:support, html_dl: true) %>
<%= presenter.attribute_to_html(:tagline, html_dl: true) %>
<%= presenter.attribute_to_html(:thumbnail_link, html_dl: true) %>
<%= presenter.attribute_to_html(:translator, html_dl: true) %>
<%= presenter.attribute_to_html(:toc, html_dl: true) %>
<%= presenter.attribute_to_html(:uniform_title, html_dl: true) %>
Loading

0 comments on commit 5816ef6

Please sign in to comment.