From c328ca3f011a73b720fa32e768cf9dc1566304ae Mon Sep 17 00:00:00 2001 From: Shana Date: Mon, 28 Nov 2022 10:42:41 -0800 Subject: [PATCH 1/3] [i212] - connect LOC to remote qa --- .env | 1 + config/initializers/qa.rb | 31 +++++++++++++++++++++++++++++++ config/oclcts-authorities.yml | 24 ++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 config/initializers/qa.rb create mode 100644 config/oclcts-authorities.yml diff --git a/.env b/.env index ec6d0418..f0254020 100644 --- a/.env +++ b/.env @@ -8,6 +8,7 @@ DB_TEST_NAME=hyku_test DB_USER=postgres DB_HOST=db DB_PORT=5432 +ENGINE_MOUNT=authorities FCREPO_HOST=fcrepo FCREPO_PORT=8080 FCREPO_URL=http://fcrepo:8080/rest diff --git a/config/initializers/qa.rb b/config/initializers/qa.rb new file mode 100644 index 00000000..2509c1bd --- /dev/null +++ b/config/initializers/qa.rb @@ -0,0 +1,31 @@ +Qa.config do |config| + # When enabled, CORS headers will be added to the responses for search and show. `OPTIONS` method will also be supported. + # Uncomment one of the lines below to enable or disable CORS headers. This configuration defaults to disabled when not set. + # More information on CORS headers at: https://fetch.spec.whatwg.org/#cors-protocol + # config.enable_cors_headers + # config.disable_cors_headers + + # Provide a token that allows reloading of linked data authorities through the controller + # action '/reload/linked_data/authorities?auth_token=YOUR_AUTH_TOKEN_DEFINED_HERE' without + # requiring a restart of rails. By default, reloading through the browser is not allowed + # when the token is nil or blank. Change to any string to control who has access to reload. + config.authorized_reload_token = 'YOUR_AUTH_TOKEN_DEFINED_HERE' + + # For linked data access, specify default language for sorting and selection. The default is only used if a language is not + # specified in the authority's configuration file and not passed in as a parameter. (e.g. :en, [:en], or [:en, :fr]) + # config.default_language = :en + + # When true, prevents ldpath requests from making additional network calls. All values will come from the context graph + # passed to the ldpath request. + # config.limit_ldpath_to_context = true + + # Define default behavior for property_map.optional? when it is not defined in the configuration for a property. + # When false, properties that do not override default optional behavior will be shown whether or not the property has a value in the graph. + # When true, properties that do not override default optional behavior will not be shown whn the property does not have a value in the graph. + # config.property_map_default_for_optional = false + + # IP data including IP address, city, state, and country will be logged with each request. + # When false, IP data is logged + # When true, IP data will not be logged (default for backward compatibility) + # config.suppress_ip_data_from_log = true +end diff --git a/config/oclcts-authorities.yml b/config/oclcts-authorities.yml new file mode 100644 index 00000000..925fcf07 --- /dev/null +++ b/config/oclcts-authorities.yml @@ -0,0 +1,24 @@ +url-pattern: + prefix-query: http://tspilot.oclc.org/{authority-id}/?query=oclcts.rootHeading+exact+%22{query}*%22&version=1.1&operation=searchRetrieve&recordSchema=http%3A%2F%2Fzthes.z3950.org%2Fxml%2F1.0%2F&maximumRecords=10&startRecord=1&resultSetTTL=300&recordPacking=xml&recordXPath=&sortKeys= + id-lookup: http://tspilot.oclc.org/{authority-id}/?query=dc.identifier+exact+%22{id}%22&version=1.1&operation=searchRetrieve&recordSchema=http%3A%2F%2Fzthes.z3950.org%2Fxml%2F1.0%2F&maximumRecords=10&startRecord=1&resultSetTTL=300&recordPacking=xml&recordXPath=&sortKeys= +authorities: + lcgft: + name: Library of Congress Genre/Form Terms for Library and Archival Materials (LCGFT) + bisacsh: + name: Book Industry Study Group Subject Headings (BISAC®). Used with permission. + fast: + name: Faceted Application of Subject Terminology (FAST subject headings) + gsafd: + name: Form and genre headings for fiction and drama + lcshac: + name: Library of Congress AC Subject Headings + lcsh: + name: Library of Congress Subject Headings + mesh: + name: Medical Subject Headings (MeSH®) + lctgm: + name: "Thesaurus for graphic materials: TGM I, Subject terms" + gmgpc: + name: "Thesaurus for graphic materials: TGM II, Genre terms" + meta: + name: Controlled Vocabulary Metadata From 04be464f0922a101c7a04bd104ef1aee3b9dc45f Mon Sep 17 00:00:00 2001 From: Shana Date: Tue, 29 Nov 2022 11:01:36 -0800 Subject: [PATCH 2/3] [i212] - add subject partial for controlled vocabulary and spec --- .../records/edit_fields/_subject.html.erb | 13 ++++++++++++ .../edit_fields/_subject.html.erb_spec.rb | 21 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 app/views/records/edit_fields/_subject.html.erb create mode 100644 spec/views/records/edit_fields/_subject.html.erb_spec.rb diff --git a/app/views/records/edit_fields/_subject.html.erb b/app/views/records/edit_fields/_subject.html.erb new file mode 100644 index 00000000..d389f4d0 --- /dev/null +++ b/app/views/records/edit_fields/_subject.html.erb @@ -0,0 +1,13 @@ +<%= f.input :subject, + # TODO(shanalmoore) as: :controlled_vocabulary is not working for some reason, + as: :multi_value, + placeholder: 'Search for a subject', + input_html: { + class: 'form-control', + data: { 'autocomplete-url' => "/authorities/search/loc/subjects", + 'autocomplete' => key } + }, + ### Required for the ControlledVocabulary javascript: + wrapper_html: { data: { 'autocomplete-url' => "/authorities/search/loc/subjects", + 'field-name' => key }}, + required: f.object.required?(key) %> diff --git a/spec/views/records/edit_fields/_subject.html.erb_spec.rb b/spec/views/records/edit_fields/_subject.html.erb_spec.rb new file mode 100644 index 00000000..b228a577 --- /dev/null +++ b/spec/views/records/edit_fields/_subject.html.erb_spec.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true +RSpec.describe 'records/edit_fields/_subject.html.erb', type: :view do + let(:work) { GenericWork.new } + let(:form) { Hyrax::GenericWorkForm.new(work, nil, controller) } + let(:form_template) do + %( + <%= simple_form_for [main_app, @form] do |f| %> + <%= render "records/edit_fields/subject", f: f, key: 'subject' %> + <% end %> + ) + end + + before do + assign(:form, form) + render inline: form_template + end + + it 'has url for autocomplete service' do + expect(rendered).to have_selector('input[data-autocomplete-url="/authorities/search/loc/subjects"][data-autocomplete="subject"]') + end +end From fc0b7896cf17cc79705ac9239322057832fabb91 Mon Sep 17 00:00:00 2001 From: Shana Date: Fri, 2 Dec 2022 10:22:35 -0800 Subject: [PATCH 3/3] rubocop fix --- spec/views/records/edit_fields/_subject.html.erb_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/views/records/edit_fields/_subject.html.erb_spec.rb b/spec/views/records/edit_fields/_subject.html.erb_spec.rb index b228a577..c65e9839 100644 --- a/spec/views/records/edit_fields/_subject.html.erb_spec.rb +++ b/spec/views/records/edit_fields/_subject.html.erb_spec.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + RSpec.describe 'records/edit_fields/_subject.html.erb', type: :view do let(:work) { GenericWork.new } let(:form) { Hyrax::GenericWorkForm.new(work, nil, controller) } @@ -16,6 +17,8 @@ end it 'has url for autocomplete service' do - expect(rendered).to have_selector('input[data-autocomplete-url="/authorities/search/loc/subjects"][data-autocomplete="subject"]') + expect(rendered).to have_selector( + 'input[data-autocomplete-url="/authorities/search/loc/subjects"][data-autocomplete="subject"]' + ) end end