Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate display date into 'Creation date' and 'Publication date' #6062

Merged
merged 4 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/assets/stylesheets/blacklight.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ img.no-icon {

.page-item span.page-link {
color: $dark !important;
}
}
3 changes: 2 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ class CatalogController < ApplicationController
# solr fields to be displayed in the index (search results) view
# The ordering of the field names is the order of the display
config.add_index_field 'title_tesi', label: 'Title', if: Proc.new {|context, _field_config, _document| context.request.format == :json }
config.add_index_field 'date_issued_ssi', label: 'Date', helper_method: :combined_display_date
config.add_index_field 'date_issued_ssi', label: 'Date', if: Proc.new {|_context, _field_config, document| document[:date_issued_ssi].present? }
config.add_index_field 'date_created_ssi', label: 'Date', if: Proc.new {|_context, _field_config, document| document[:date_created_ssi].present? && document[:date_issued_ssi].blank? }
Comment on lines +118 to +119
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great way to handle this! Much simpler than what I was suggesting with a helper method.

config.add_index_field 'creator_ssim', label: 'Main contributors', helper_method: :contributor_index_display
config.add_index_field 'abstract_ssi', label: 'Summary', helper_method: :description_index_display
config.add_index_field 'duration_ssi', label: 'Duration', if: Proc.new {|context, _field_config, _document| context.request.format == :json }
Expand Down
12 changes: 0 additions & 12 deletions app/helpers/media_objects_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,6 @@ def dropbox_url collection
ic.iconv(url)
end

def combined_display_date media_object
(issued,created) = case media_object
when MediaObject, SpeedyAF::Proxy::MediaObject
[media_object.date_issued, media_object.date_created]
when Hash
[media_object[:document]['date_issued_ssi'], media_object[:document]['date_created_ssi']]
end
result = issued
result += " (Creation date: #{created})" if created.present?
result
end

def display_other_identifiers media_object
# bibliographic_id has form [:type,"value"], other_identifier has form [[:type,"value],[:type,"value"],...]
ids = media_object.bibliographic_id.present? ? [media_object.bibliographic_id] : []
Expand Down
3 changes: 2 additions & 1 deletion app/models/iiif_manifest_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def display_lending_period(media_object)
def iiif_metadata_fields
fields = [
metadata_field('Title', media_object.title, media_object.id),
metadata_field('Date', combined_display_date(media_object), 'Not provided'),
masaball marked this conversation as resolved.
Show resolved Hide resolved
metadata_field('Publication date', media_object.date_issued),
metadata_field('Creation date', media_object.date_created),
metadata_field('Main contributor', media_object.creator),
metadata_field('Summary', display_summary(media_object)),
metadata_field('Contributor', media_object.contributor),
Expand Down
3 changes: 2 additions & 1 deletion app/views/playlist_items/_current_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Unless required by applicable law or agreed to in writing, software distributed
</div>

<dl id="creation_metadata">
<%= display_metadata('Date', combined_display_date(@current_mediaobject), 'Not provided') %>
<%= display_metadata('Publication date', @current_mediaobject.date_issued) %>
<%= display_metadata('Creation date', @current_mediaobject.date_created) %>
<%= display_metadata('Main contributor', @current_mediaobject.creator) %>
<% unless @current_mediaobject.abstract.blank? %>
<dt>Summary</dt>
Expand Down
8 changes: 4 additions & 4 deletions spec/models/iiif_manifest_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
it 'provides metadata' do
allow_any_instance_of(IiifManifestPresenter).to receive(:lending_enabled).and_return(false)

['Title', 'Date', 'Main contributor', 'Summary', 'Contributor', 'Publisher', 'Genre', 'Subject', 'Time period',
'Location', 'Collection', 'Unit', 'Language', 'Rights Statement', 'Terms of Use', 'Physical Description', 'Series',
['Title', 'Publication date', 'Creation date', 'Main contributor', 'Summary', 'Contributor', 'Publisher', 'Genre', 'Subject',
'Time period', 'Location', 'Collection', 'Unit', 'Language', 'Rights Statement', 'Terms of Use', 'Physical Description', 'Series',
'Related Item', 'Notes', 'Table of Contents', 'Local Note', 'Other Identifier', 'Access Restrictions', 'Bibliographic ID'
].each do |field|
expect(subject).to include(field)
Expand Down Expand Up @@ -93,8 +93,8 @@
it 'provides metadata' do
allow_any_instance_of(IiifManifestPresenter).to receive(:lending_enabled).and_return(true)

['Title', 'Date', 'Main contributor', 'Summary', 'Contributor', 'Publisher', 'Genre', 'Subject', 'Time period',
'Location', 'Collection', 'Unit', 'Language', 'Rights Statement', 'Terms of Use', 'Physical Description', 'Series',
['Title', 'Publication date', 'Creation date', 'Main contributor', 'Summary', 'Contributor', 'Publisher', 'Genre', 'Subject',
'Time period', 'Location', 'Collection', 'Unit', 'Language', 'Rights Statement', 'Terms of Use', 'Physical Description', 'Series',
'Related Item', 'Notes', 'Table of Contents', 'Local Note', 'Other Identifier', 'Access Restrictions', 'Bibliographic ID', 'Lending Period'
].each do |field|
expect(subject).to include(field)
Expand Down