diff --git a/Dockerfile b/Dockerfile index 614e644..860092a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,18 +3,23 @@ FROM ruby:3.2 AS development ARG UNAME=app ARG UID=1000 ARG GID=1000 +ARG NODE_MAJOR=20 -RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends \ + ca-certificates \ + gnupg \ apt-transport-https \ - nodejs \ vim-tiny +RUN mkdir -p /etc/apt/keyrings +RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${NODE_MAJOR}.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list +RUN apt-get update -yqq && apt-get install -yqq --no-install-recommends nodejs + RUN gem install bundler RUN npm install -g npm - RUN groupadd -g ${GID} -o ${UNAME} RUN useradd -m -d /app -u ${UID} -g ${GID} -o -s /bin/bash ${UNAME} RUN mkdir -p /gems && chown ${UID}:${GID} /gems diff --git a/Gemfile.lock b/Gemfile.lock index 554c01c..b51e959 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,7 @@ GEM specs: addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) - anyway_config (2.5.1) + anyway_config (2.5.2) ruby-next-core (>= 0.14.0) ast (2.4.2) base64 (0.1.1) @@ -72,7 +72,7 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.1) - rubocop (1.56.1) + rubocop (1.56.3) base64 (~> 0.1.1) json (~> 2.3) language_server-protocol (>= 3.17.0) @@ -109,10 +109,10 @@ GEM rack-protection (= 3.1.0) sinatra (= 3.1.0) tilt (~> 2.0) - standard (1.31.0) + standard (1.31.1) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.0) - rubocop (~> 1.56.0) + rubocop (~> 1.56.2) standard-custom (~> 1.0.0) standard-performance (~> 1.2) standard-custom (1.0.2) @@ -123,7 +123,7 @@ GEM rubocop-performance (~> 1.19.0) tilt (2.2.0) unicode-display_width (2.4.2) - webmock (3.18.1) + webmock (3.19.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -161,4 +161,4 @@ DEPENDENCIES yabeda-puma-plugin BUNDLED WITH - 2.4.13 + 2.4.19 diff --git a/README.md b/README.md index a40a575..36c1e75 100644 --- a/README.md +++ b/README.md @@ -30,5 +30,3 @@ If you are working on features, set up a gate so that the feature can be turned In this project we create an environment variable for the feature. If it is true the feature is enabled. If it is false then it is turned off. Current Features: -* `AUTHOR_ON='true'` for enabling Browse By Author -* `SUBJECT_ON='true'` for enabling Browse By Subject diff --git a/catalog-browse.rb b/catalog-browse.rb index 43d59d5..cf98b1f 100644 --- a/catalog-browse.rb +++ b/catalog-browse.rb @@ -22,31 +22,28 @@ config.solr_url = ENV.fetch("BIBLIO_SOLR") end -if ENV.fetch("SUBJECT_ON") == "true" - get "/subject" do - subject = StringCleaner.clean_browse_string(params[:query]) - reference_id = params[:reference_id] || subject - begin - list = SubjectList.for(direction: params[:direction], reference_id: reference_id, num_rows_to_display: 20, original_reference: subject, banner_reference: params[:banner_reference]) - rescue => e - logger.error(e.message) - list = SubjectList::Error.new(reference_id) - end - erb :subject, locals: {list: list} +get "/subject" do + subject = StringCleaner.clean_browse_string(params[:query]) + reference_id = params[:reference_id] || subject + begin + list = SubjectList.for(direction: params[:direction], reference_id: reference_id, num_rows_to_display: 20, original_reference: subject, banner_reference: params[:banner_reference]) + rescue => e + logger.error(e.message) + list = SubjectList::Error.new(reference_id) end + erb :subject, locals: {list: list} end -if ENV.fetch("AUTHOR_ON") == "true" - get "/author" do - author = StringCleaner.clean_browse_string(params[:query]) - reference_id = params[:reference_id] || author - begin - list = AuthorList.for(direction: params[:direction], reference_id: reference_id, num_rows_to_display: 20, original_reference: author, banner_reference: params[:banner_reference]) - rescue => e - logger.error(e.message) - list = AuthorList::Error.new(reference_id) - end - erb :authors, locals: {list: list} + +get "/author" do + author = StringCleaner.clean_browse_string(params[:query]) + reference_id = params[:reference_id] || author + begin + list = AuthorList.for(direction: params[:direction], reference_id: reference_id, num_rows_to_display: 20, original_reference: author, banner_reference: params[:banner_reference]) + rescue => e + logger.error(e.message) + list = AuthorList::Error.new(reference_id) end + erb :authors, locals: {list: list} end get "/callnumber" do callnumber = params[:query] diff --git a/env.example b/env.example index f1cac2f..b750747 100644 --- a/env.example +++ b/env.example @@ -1,6 +1,4 @@ BIBLIO_SOLR='http://biblio-server/solr' -CATALOG_SOLR='http://catalog-solr-server/solr' -CALLNUMBERS_CORE='callnumbers' -AUTHORS_CORE='authors' -AUTHOR_ON='true' -SUBJECT_ON='true' +BROWSE_SOLR='http://catalog-solr-server/solr' +CALLNUMBER_CORE='callnumbers' +AUTHORITY_CORE='authors' diff --git a/lib/models/author_list.rb b/lib/models/author_list.rb index a3d6606..650327c 100644 --- a/lib/models/author_list.rb +++ b/lib/models/author_list.rb @@ -6,7 +6,7 @@ def self.for(direction:, reference_id:, num_rows_to_display:, original_reference num_rows_to_display: num_rows_to_display, original_reference: original_reference, banner_reference: banner_reference, - browse_solr_client: BrowseSolrClient.new(core: ENV.fetch("AUTHORS_CORE"), match_field: "term", q: "browse_field:name") + browse_solr_client: BrowseSolrClient.new(core: ENV.fetch("AUTHORITY_CORE"), match_field: "term", q: "browse_field:name") ) new(browse_list: browse_list) diff --git a/lib/models/subject_list.rb b/lib/models/subject_list.rb index 2d6d4fe..bbd21a5 100644 --- a/lib/models/subject_list.rb +++ b/lib/models/subject_list.rb @@ -6,7 +6,7 @@ def self.for(direction:, reference_id:, num_rows_to_display:, original_reference num_rows_to_display: num_rows_to_display, original_reference: original_reference, banner_reference: banner_reference, - browse_solr_client: BrowseSolrClient.new(core: ENV.fetch("AUTHORS_CORE"), match_field: "term", q: "browse_field:subject") + browse_solr_client: BrowseSolrClient.new(core: ENV.fetch("AUTHORITY_CORE"), match_field: "term", q: "browse_field:subject") ) new(browse_list: browse_list) diff --git a/lib/utilities/browse_solr_client.rb b/lib/utilities/browse_solr_client.rb index 71939d2..ef093e8 100644 --- a/lib/utilities/browse_solr_client.rb +++ b/lib/utilities/browse_solr_client.rb @@ -1,7 +1,7 @@ require "faraday" class BrowseSolrClient - def initialize(solr_url: ENV.fetch("CATALOG_SOLR"), core: ENV.fetch("CALLNUMBERS_CORE"), match_field: "callnumber", q: "*:*") + def initialize(solr_url: ENV.fetch("BROWSE_SOLR"), core: ENV.fetch("CALLNUMBER_CORE"), match_field: "callnumber", q: "*:*") @conn = Faraday.new( url: solr_url ) do |f| diff --git a/package-lock.json b/package-lock.json index a639007..5a4e343 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "devDependencies": { "cssnano": "^6.0.1", - "postcss": "^8.4.27", + "postcss": "^8.4.29", "postcss-cli": "^10.1.0", "postcss-import": "^15.1.0" } @@ -168,9 +168,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001519", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001519.tgz", - "integrity": "sha512-0QHgqR+Jv4bxHMp8kZ1Kn8CH55OikjKJ6JmKkZYP1F3D7w+lnFXF70nG5eNfsZS89jadi5Ywy5UCSKLAglIRkg==", + "version": "1.0.30001527", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001527.tgz", + "integrity": "sha512-YkJi7RwPgWtXVSgK4lG9AHH57nSzvvOp9MesgXmw4Q7n0C3H04L0foHqfxcmSAm5AcWb8dW9AYj2tR7/5GnddQ==", "dev": true, "funding": [ { @@ -511,9 +511,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.485", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.485.tgz", - "integrity": "sha512-1ndQ5IBNEnFirPwvyud69GHL+31FkE09gH/CJ6m3KCbkx3i0EVOrjwz4UNxRmN9H8OVHbC6vMRZGN1yCvjSs9w==", + "version": "1.4.508", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.508.tgz", + "integrity": "sha512-FFa8QKjQK/A5QuFr2167myhMesGrhlOBD+3cYNxO9/S4XzHEXesyTD/1/xF644gC8buFPz3ca6G1LOQD0tZrrg==", "dev": true }, "node_modules/emoji-regex": { @@ -595,9 +595,9 @@ } }, "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "hasInstallScript": true, "optional": true, @@ -917,9 +917,9 @@ } }, "node_modules/postcss": { - "version": "8.4.27", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.27.tgz", - "integrity": "sha512-gY/ACJtJPSmUFPDCHtX78+01fHa64FaU4zaaWfuh1MhGJISufJAH4cun6k/8fwsHYeK4UQmENQK+tRLCFJE8JQ==", + "version": "8.4.29", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.29.tgz", + "integrity": "sha512-cbI+jaqIeu/VGqXEarWkRCCffhjgXc0qjBtXpqJhTBohMUjUQnbBr0xqX3vEKudc4iviTewcJo5ajcec5+wdJw==", "dev": true, "funding": [ { @@ -1763,9 +1763,9 @@ } }, "node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz", + "integrity": "sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==", "dev": true, "engines": { "node": ">= 14" diff --git a/package.json b/package.json index 61f9bc1..ed1f963 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "homepage": "https://github.com/mlibrary/catalog-browse#readme", "devDependencies": { "cssnano": "^6.0.1", - "postcss": "^8.4.27", + "postcss": "^8.4.29", "postcss-cli": "^10.1.0", "postcss-import": "^15.1.0" } diff --git a/spec/requests_spec.rb b/spec/requests_spec.rb index 47d0a02..94033c8 100644 --- a/spec/requests_spec.rb +++ b/spec/requests_spec.rb @@ -2,8 +2,8 @@ describe "requests" do include Rack::Test::Methods before(:each) do - @callnumbers_core = ENV.fetch("CALLNUMBERS_CORE") - @authors_core = ENV.fetch("AUTHORS_CORE") + @callnumbers_core = ENV.fetch("CALLNUMBER_CORE") + @authors_core = ENV.fetch("AUTHORITY_CORE") end context "get /" do it "has status OK" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4606275..782300a 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -122,7 +122,7 @@ def stub_solr_get_request(url:, output: "{}", status: 200, query: nil, no_return } req_attributes[:query] = query unless query.nil? resp = {headers: {content_type: "application/json"}, status: status, body: output} - req = stub_request(:get, "#{ENV["CATALOG_SOLR"]}/#{url}").with(**req_attributes) + req = stub_request(:get, "#{ENV["BROWSE_SOLR"]}/#{url}").with(**req_attributes) if no_return.nil? req.to_return(**resp) diff --git a/spec/utilities/browse_solr_client_spec.rb b/spec/utilities/browse_solr_client_spec.rb index 6552143..504646a 100644 --- a/spec/utilities/browse_solr_client_spec.rb +++ b/spec/utilities/browse_solr_client_spec.rb @@ -4,11 +4,11 @@ end context "#exact_matches" do it "returns an array of ids for an exact match" do - stub_solr_get_request(url: "#{ENV.fetch("CALLNUMBERS_CORE")}/select", query: hash_including({fq: 'callnumber:"Thing"'}), output: fixture("biblio_results.json")) + stub_solr_get_request(url: "#{ENV.fetch("CALLNUMBER_CORE")}/select", query: hash_including({fq: 'callnumber:"Thing"'}), output: fixture("biblio_results.json")) expect(subject.exact_matches(value: "Thing")).to eq(["990059013360106381", "990011613060106381", "990085202960106381", "990155473530106381", "990017586110106381"]) end it "returns an empty errary if the solr request fails" do - stub_solr_get_request(url: "#{ENV.fetch("CALLNUMBERS_CORE")}/select", query: hash_including({fq: 'callnumber:"Thing"'}), no_return: true).to_timeout + stub_solr_get_request(url: "#{ENV.fetch("CALLNUMBER_CORE")}/select", query: hash_including({fq: 'callnumber:"Thing"'}), no_return: true).to_timeout expect(subject.exact_matches(value: "Thing")).to eq([]) end end diff --git a/views/layout/search_box.erb b/views/layout/search_box.erb index 070efd2..3abc076 100644 --- a/views/layout/search_box.erb +++ b/views/layout/search_box.erb @@ -1,12 +1,6 @@ <% fields = YAML.load_file("./config/search_dropdown.yml") active_browse_option = 'browse_by_' + request.path_info[1..-1] - if ENV.fetch("SUBJECT_ON") == "false" - browse_by = fields.find{|x| x[:label] == "Browse by [BETA]"} - browse_by_subject = browse_by[:options].find{|x| x[:label] == "Browse by subject"} - browse_by_subject[:label] = "Browse by subject (coming soon)" - browse_by_subject[:disabled] = "disabled" - end %>