Skip to content

Commit

Permalink
Merge pull request #98 from mlibrary/2023-09-05-updates
Browse files Browse the repository at this point in the history
September 2023 dependency updates.
  • Loading branch information
niquerio authored Sep 11, 2023
2 parents aee8a82 + 11929be commit 3ccb6b3
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 69 deletions.
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -161,4 +161,4 @@ DEPENDENCIES
yabeda-puma-plugin

BUNDLED WITH
2.4.13
2.4.19
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
41 changes: 19 additions & 22 deletions catalog-browse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 3 additions & 5 deletions env.example
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 1 addition & 1 deletion lib/models/author_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/models/subject_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/utilities/browse_solr_client.rb
Original file line number Diff line number Diff line change
@@ -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|
Expand Down
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
4 changes: 2 additions & 2 deletions spec/requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions spec/utilities/browse_solr_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions views/layout/search_box.erb
Original file line number Diff line number Diff line change
@@ -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
%>

<form class="search-box" role="search" method="post" action="<%= ENV.fetch('BASE_URL') %>/search">
Expand Down

0 comments on commit 3ccb6b3

Please sign in to comment.