Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Commit

Permalink
Merge pull request #934 from psu-libraries/i#899-text-content-from-cu…
Browse files Browse the repository at this point in the history
…rator

Paragraph transformation for curator’s textual narrative
  • Loading branch information
awead committed Apr 2, 2019
2 parents 7548ba0 + 9995b78 commit 040d136
Show file tree
Hide file tree
Showing 16 changed files with 54 additions and 18 deletions.
7 changes: 6 additions & 1 deletion app/blacklight/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ class CatalogController < ApplicationController
# @todo configuration of linked field indexing
config.add_facet_field 'creator_role_ssim', label: I18n.t('cho.field_label.role')

fields_excluded_from_metadata_list = %w[
acknowledgments
narrative
]

DataDictionary::Field.all.sort_by(&:created_at).each do |map_field|
catalog_field = map_field.solr_search_field
catalog_label = map_field.display_name || map_field.label.titleize
catalog_helper = map_field.display_transformation == 'no_transformation' ? nil : map_field.display_transformation.to_sym

unless map_field.display_transformation == 'paragraph_heading'
unless fields_excluded_from_metadata_list.include?(map_field.label)
config.add_index_field catalog_field, label: catalog_label, helper_method: catalog_helper
config.add_show_field catalog_field, label: catalog_label, helper_method: catalog_helper
end
Expand Down
5 changes: 5 additions & 0 deletions app/blacklight/local_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ def render_link_to_collection(options_or_value = {})
def paragraph_heading(*args)
# noop
end

# @note Avoids any NoMethodError problems when specifying a custom partial display transformation
def paragraph(*args)
# noop
end
end
6 changes: 3 additions & 3 deletions app/blacklight/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ def schema_label
end

def metadata_fields
@metadata_fields ||= schema.field_ids.map do |field_id|
Schema::MetadataField.find(field_id)
end
@metadata_fields ||= schema.field_ids
.map { |field_id| Schema::MetadataField.find(field_id) }
.sort_by(&:order_index)
end

def transformed_fields
Expand Down
3 changes: 2 additions & 1 deletion app/cho/display_transformation/factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def default_items
{
default_key => DisplayTransformation::None.new,
render_link_to_collection: DisplayTransformation::None.new,
paragraph_heading: DisplayTransformation::None.new
paragraph_heading: DisplayTransformation::None.new,
paragraph: DisplayTransformation::None.new
}
end

Expand Down
3 changes: 3 additions & 0 deletions app/views/shared/transformation_partials/_paragraph.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<% presenter.paragraphs.each do |paragraph| %>
<p><%= paragraph %></p>
<% end %>
1 change: 1 addition & 0 deletions config/data_dictionary/data_dictionary_development.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ subject,string,optional,no_validation,true,no_vocabulary,,Subject,no_transformat
location,string,optional,no_validation,true,no_vocabulary,,Location,no_transformation,no_facet,help me,true
description,text,optional,no_validation,true,no_vocabulary,,Description,no_transformation,no_facet,help me,true
acknowledgments,text,optional,no_validation,true,no_vocabulary,,,paragraph_heading,no_facet,help me,false
narrative,text,optional,no_validation,true,no_vocabulary,,Narrative,paragraph,no_facet,help me,false
genre,string,required_to_publish,no_validation,true,no_vocabulary,,Genre,no_transformation,no_facet,help me,true
collection,string,required_to_publish,no_validation,true,no_vocabulary,,Collection,no_transformation,no_facet,help me,true
repository,string,required_to_publish,no_validation,true,no_vocabulary,,Repository,no_transformation,no_facet,help me,true
Expand Down
1 change: 1 addition & 0 deletions config/data_dictionary/data_dictionary_production.csv
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ subject,string,optional,no_validation,true,no_vocabulary,,Subject,no_transformat
location,string,optional,no_validation,true,no_vocabulary,,Location,no_transformation,no_facet,help me,true
description,text,optional,no_validation,true,no_vocabulary,,Description,no_transformation,no_facet,help me,true
acknowledgments,text,optional,no_validation,true,no_vocabulary,,,paragraph_heading,no_facet,help me,false
narrative,text,optional,no_validation,true,no_vocabulary,,Narrative,paragraph,no_facet,help me,false
genre,string,required_to_publish,no_validation,true,no_vocabulary,,Genre,no_transformation,no_facet,help me,true
collection,string,required_to_publish,no_validation,true,no_vocabulary,,Collection,no_transformation,no_facet,help me,true
repository,string,required_to_publish,no_validation,true,no_vocabulary,,Repository,no_transformation,no_facet,help me,true
Expand Down
1 change: 1 addition & 0 deletions config/data_dictionary/data_dictionary_test.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ home_collection_id,valkyrie_id,optional,resource_exists,false,cho_collections,,C
subtitle,string,optional,no_validation,true,no_vocabulary,,,no_transformation,no_facet,help me,true
description,text,optional,no_validation,true,no_vocabulary,,,no_transformation,no_facet,help me,true
acknowledgments,text,optional,no_validation,true,no_vocabulary,,,paragraph_heading,no_facet,help me,false
narrative,text,optional,no_validation,true,no_vocabulary,,Narrative,paragraph,no_facet,help me,false
created,date,optional,edtf_date,true,no_vocabulary,,,no_transformation,date,help me,false
generic_field,string,optional,no_validation,true,no_vocabulary,,,no_transformation,facet,help me,false
document_field,string,optional,no_validation,true,no_vocabulary,,,no_transformation,no_facet,help me,false
Expand Down
4 changes: 4 additions & 0 deletions config/data_dictionary/schema_fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ development: &development
- schema: 'Collection'
fields:
acknowledgments:
order_index: 2
narrative:
order_index: 1
work_type: 'false'
- schema: 'FileSet'
Expand Down Expand Up @@ -229,6 +231,8 @@ test:
- schema: 'Collection'
fields:
acknowledgments:
order_index: 2
narrative:
order_index: 1
work_type: 'false'
- schema: 'FileSet'
Expand Down
15 changes: 8 additions & 7 deletions spec/blacklight/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class MyResource < Valkyrie::Resource
'home_collection_id,' \
'map_field,' \
'moving_image_field,' \
'narrative,' \
'still_image_field'
end

Expand All @@ -112,16 +113,16 @@ class MyResource < Valkyrie::Resource
}
end

it { is_expected.to eq("#{csv_header}\nabc123,,my_title,,,,,,,,,value1||value2,xyx789,,,\n") }
it { is_expected.to eq("#{csv_header}\nabc123,,my_title,,,,,,,,,value1||value2,xyx789,,,,\n") }

context 'with a collection containing works and file sets' do
let(:collection) { create :library_collection }
let(:work) { create :work, :with_file, home_collection_id: [collection.id], title: 'Work One' }
let(:work1_csv) { "#{work.id},Generic,Work One,,,,,,,,,,#{collection.id},,," }
let(:file_set1_csv) { "#{work.member_ids.first},,hello_world.txt,,,,,,,,,,,,," }
let(:work1_csv) { "#{work.id},Generic,Work One,,,,,,,,,,#{collection.id},,,," }
let(:file_set1_csv) { "#{work.member_ids.first},,hello_world.txt,,,,,,,,,,,,,," }
let(:work2) { create :work, :with_file, home_collection_id: [collection.id], title: 'Work Two' }
let(:work2_csv) { "#{work2.id},Generic,Work Two,,,,,,,,,,#{collection.id},,," }
let(:file_set2_csv) { "#{work2.member_ids.first},,hello_world.txt,,,,,,,,,,,,," }
let(:work2_csv) { "#{work2.id},Generic,Work Two,,,,,,,,,,#{collection.id},,,," }
let(:file_set2_csv) { "#{work2.member_ids.first},,hello_world.txt,,,,,,,,,,,,,," }

let(:document) do
{ 'internal_resource_tsim' => 'MyCollection', id: collection.id, title_tesim: ['my_collection'] }
Expand Down Expand Up @@ -153,8 +154,8 @@ class MyResource < Valkyrie::Resource
end

let(:file_set) { create(:file_set) }
let(:work_csv) { 'abc123,,my_title,,,,,,,,,value1||value2,xyx789,,,' }
let(:file_set_csv) { "#{file_set.id},,Original File Name,,,,,,,,,,,,," }
let(:work_csv) { 'abc123,,my_title,,,,,,,,,value1||value2,xyx789,,,,' }
let(:file_set_csv) { "#{file_set.id},,Original File Name,,,,,,,,,,,,,," }

before { file_set }

Expand Down
3 changes: 3 additions & 0 deletions spec/cho/collection/archival_collections/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
let(:description) { Faker::Hipster.sentence }
let(:identifier) { Faker::Number.leading_zero_number(10) }
let(:acknowledgments) { Faker::Lorem.paragraph }
let(:narrative) { Faker::Lorem.paragraph }

it 'creates a new archival collection' do
visit(new_archival_collection_path)
Expand All @@ -47,6 +48,7 @@
fill_in('archival_collection[description]', with: description)
fill_in('archival_collection[alternate_ids]', with: identifier)
fill_in('archival_collection[acknowledgments]', with: acknowledgments)
fill_in('archival_collection[narrative]', with: narrative)
select(agent, from: 'archival_collection[creator][agent]')
select('blasting', from: 'archival_collection[creator][role]')
choose('Mediated')
Expand All @@ -59,6 +61,7 @@
expect(page).to have_content("#{agent.display_name}, blasting")
expect(page).to have_selector('h2', text: 'Acknowledgments')
expect(page).to have_content(acknowledgments)
expect(page).to have_content(narrative)
end
end
end
6 changes: 4 additions & 2 deletions spec/cho/collection/change_set_behaviors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ class MyCollectionChangeSet < Valkyrie::ChangeSet
'title',
'alternate_ids',
'creator',
'acknowledgments'
'acknowledgments',
'narrative'
)
end
end
Expand All @@ -101,7 +102,8 @@ class MyCollectionChangeSet < Valkyrie::ChangeSet
'title',
'alternate_ids',
'creator',
'acknowledgments'
'acknowledgments',
'narrative'
)
end
end
Expand Down
5 changes: 4 additions & 1 deletion spec/cho/collection/curated_collections/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
let(:subtitle) { Faker::Hipster.sentence }
let(:description) { Faker::Hipster.sentence }
let(:identifier) { Faker::Number.leading_zero_number(10) }
let(:acknowledgments) { Faker::Lorem.paragraph }
let(:acknowledgments) { 'Acknowledgmentium ' + Faker::Lorem.paragraph }
let(:narrative) { 'Narratismus ' + Faker::Lorem.paragraph }

it 'creates a new curated collection' do
visit(new_curated_collection_path)
Expand All @@ -47,6 +48,7 @@
fill_in('curated_collection[description]', with: description)
fill_in('curated_collection[alternate_ids]', with: identifier)
fill_in('curated_collection[acknowledgments]', with: acknowledgments)
fill_in('curated_collection[narrative]', with: narrative)
select(agent, from: 'curated_collection[creator][agent]')
select('blasting', from: 'curated_collection[creator][role]')
choose('Mediated')
Expand All @@ -59,6 +61,7 @@
expect(page).to have_content("#{agent.display_name}, blasting")
expect(page).to have_selector('h2', text: 'Acknowledgments')
expect(page).to have_content(acknowledgments)
expect(page).to have_content(narrative)
end
end
end
3 changes: 3 additions & 0 deletions spec/cho/collection/library_collections/new_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
let(:description) { Faker::Hipster.sentence }
let(:identifier) { Faker::Number.leading_zero_number(10) }
let(:acknowledgments) { Faker::Lorem.paragraph }
let(:narrative) { Faker::Lorem.paragraph }

it 'creates a new library collection' do
visit(new_library_collection_path)
Expand All @@ -47,6 +48,7 @@
fill_in('library_collection[description]', with: description)
fill_in('library_collection[alternate_ids]', with: identifier)
fill_in('library_collection[acknowledgments]', with: acknowledgments)
fill_in('library_collection[narrative]', with: narrative)
select(agent, from: 'library_collection[creator][agent]')
select('blasting', from: 'library_collection[creator][role]')
choose('Mediated')
Expand All @@ -59,6 +61,7 @@
expect(page).to have_content("#{agent.display_name}, blasting")
expect(page).to have_selector('h2', text: 'Acknowledgments')
expect(page).to have_content(acknowledgments)
expect(page).to have_content(narrative)
end
end
end
4 changes: 2 additions & 2 deletions spec/cho/display_transformation/factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class OtherTransformation < DisplayTransformation::Base
described_class.transformations = transformations
end

it { is_expected.to eq([:no_transformation, :render_link_to_collection, :paragraph_heading]) }
it { is_expected.to eq([:no_transformation, :render_link_to_collection, :paragraph_heading, :paragraph]) }

context 'valid transformations set' do
let(:transformations) { { abc: MyTransformation.new, other: OtherTransformation.new } }

it { is_expected.to eq([:abc, :other, :no_transformation, :render_link_to_collection, :paragraph_heading]) }
it { is_expected.to eq([:abc, :other, :no_transformation, :render_link_to_collection, :paragraph_heading, :paragraph]) }
end
end

Expand Down
5 changes: 4 additions & 1 deletion spec/cho/schema/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@
},
{
'schema' => 'Collection',
'fields' => { 'acknowledgments' => { 'order_index' => 1 } },
'fields' => {
'acknowledgments' => { 'order_index' => 2 },
'narrative' => { 'order_index' => 1 }
},
'work_type' => 'false'
},
{ 'schema' => 'FileSet', 'fields' => [], 'work_type' => 'false' }
Expand Down

0 comments on commit 040d136

Please sign in to comment.