Skip to content

Commit

Permalink
Updated primo support in BibWorkshop
Browse files Browse the repository at this point in the history
  • Loading branch information
abartov committed Feb 6, 2024
1 parent f3e2c4c commit 57a4ab1
Show file tree
Hide file tree
Showing 9 changed files with 107 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ gem 'rmultimarkdown' # new wrapper over Fletcher Penney's MultiMarkDown 6 (MMD 6
gem 'yt' # for polling YouTube for new videos

gem 'hebrew', '>= 0.2.1' # https://github.com/abartov/hebrew
gem 'gared', '>= 0.0.29' # https://gitlab.com/abartov/gared # for scraping bibliographic data from Hebrew sources
gem 'gared', '>= 0.1.1' # https://gitlab.com/abartov/gared # for scraping bibliographic data from Hebrew sources
# gem 'goldiloader'
gem 'haml'
#gem 'zoom', '~>0.4.1', :git => 'https://github.com/bricestacey/ruby-zoom.git' # for Z39.50 queries to libraries
Expand Down
18 changes: 8 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ GEM
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.2)
aws-eventstream (~> 1, >= 1.0.2)
base64 (0.2.0)
bcrypt_pbkdf (1.1.0)
benchmark-ips (2.10.0)
better_sjr (1.0.0)
Expand Down Expand Up @@ -192,8 +193,7 @@ GEM
docx (0.7.0)
nokogiri (~> 1.13, >= 1.13.0)
rubyzip (~> 2.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
domain_name (0.6.20240107)
dry-core (1.0.0)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
Expand Down Expand Up @@ -259,7 +259,7 @@ GEM
fugit (1.8.1)
et-orbi (~> 1, >= 1.2.7)
raabro (~> 1.4)
gared (0.0.29)
gared (0.1.1)
nokogiri (> 1.8)
rest-client (~> 2)
watir (~> 6)
Expand Down Expand Up @@ -527,7 +527,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.5)
rexml (3.2.6)
rmagick (5.3.0)
pkg-config (~> 1.4)
rmultimarkdown (6.4.0.4)
Expand Down Expand Up @@ -577,7 +577,8 @@ GEM
sprockets (> 3.0)
sprockets-rails
tilt
selenium-webdriver (4.8.6)
selenium-webdriver (4.17.0)
base64 (~> 0.2)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
Expand Down Expand Up @@ -623,9 +624,6 @@ GEM
concurrent-ruby (~> 1.0)
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
version_gem (1.1.1)
watir (6.19.1)
regexp_parser (>= 1.2, < 3)
Expand All @@ -635,7 +633,7 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
websocket (1.2.9)
websocket (1.2.10)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
Expand Down Expand Up @@ -673,7 +671,7 @@ DEPENDENCIES
execjs
factory_bot_rails (~> 6.2.0)
faker (~> 2.19.0)
gared (>= 0.0.29)
gared (>= 0.1.1)
gepub
grape (= 1.6.0)
grape-entity (~> 0.10.1)
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/bib_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,14 @@ def query_source_by_type(q, bib_source)
when 'hebrewbooks'
provider = Gared::Hebrewbooks.new
when 'primo'
provider = Gared::Primo.new(bib_source.url, bib_source.institution)
provider = Gared::Primo.new(bib_source.url, bib_source.vid, bib_source.scope, bib_source.api_key)
when 'idea'
provider = Gared::Idea.new(bib_source.url)
when 'nli_api'
provider = Gared::Nli_Api.new(bib_source.url, bib_source.api_key)
end
ret = []
#debugger
ret = provider.query_publications_by_person(q, bib_source) if provider # bib_source is sent as context, so that the resulting Publication objects would be able to access the linkify logic for their source; should probably be replaced by a proc
return ret
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/bib_sources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def set_options_and_settings
# set up which fields are needed for different source types (according to the Gared gem)
@options = {
aleph: { typename: t(:aleph), enable: [:url, :port, :institution, :item_pattern]},
primo:{ typename: t(:primo), enable: [:url, :institution, :item_pattern]},
primo:{ typename: t(:primo), enable: [:url, :item_pattern, :vid, :scope, :api_key]},
idea: { typename: t(:idea), enable: [:url, :item_pattern]},
hebrewbooks: { typename: t(:hebrewbooks), enable: []},
nli_api: { typename: t(:nli_api), enable: [:url, :api_key]},
Expand All @@ -67,6 +67,6 @@ def set_options_and_settings

# Only allow a trusted parameter "white list" through.
def bib_source_params
params.require(:bib_source).permit(:title, :source_type, :institution, :status, :url, :port, :api_key, :comments, :item_pattern)
params.require(:bib_source).permit(:title, :source_type, :institution, :status, :url, :port, :api_key, :comments, :item_pattern, :vid, :scope)
end
end
8 changes: 8 additions & 0 deletions app/views/bib_sources/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
.scfield
= f.label :api_key, t(:api_key)
= f.text_field :api_key
.scfield
= f.label :vid, t(:bib_vid)
= f.text_field :vid
.scfield
= f.label :scope, t(:bib_scope)
= f.text_field :scope
.scfield
= f.label t(:comments)
= f.text_area :comments
Expand All @@ -48,6 +54,8 @@
$('#bib_source_item_pattern').prop('disabled', options[v].enable.includes('item_pattern') ? false : true);
$('#bib_source_institution').prop('disabled', options[v].enable.includes('institution') ? false : true);
$('#bib_source_api_key').prop('disabled', options[v].enable.includes('api_key') ? false : true);
$('#bib_source_vid').prop('disabled', options[v].enable.includes('vid') ? false : true);
$('#bib_source_scope').prop('disabled', options[v].enable.includes('scope') ? false : true);
}
}

Expand Down
9 changes: 9 additions & 0 deletions app/views/bib_sources/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
%p
%b= t(:api_key)
= @bib_source.api_key
%p
%b= t(:bib_vid)
= @bib_source.vid
%p
%b= t(:bib_scope)
= @bib_source.scope
%p
%b= t(:item_pattern)
= @bib_source.item_pattern
%p
%b= t(:status)
= t(@bib_source.status)
Expand Down
2 changes: 2 additions & 0 deletions config/locales/he.yml
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ he:
add_url: הוסף את הקישורית
existing_aboutnesses: נושאים קיימים
bib_workshop: הסדנה הביבליוגרפית
bib_vid: קוד VID
bib_scope: קוד scope
# genre key names are currently hard-coded in ApplicationController
genres: סוגות
genres_and_types: סוגות וסוגים
Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20240206222123_add_vid_scope_to_bib_source.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddVidScopeToBibSource < ActiveRecord::Migration[6.1]
def change
add_column :bib_sources, :vid, :string
add_column :bib_sources, :scope, :string
end
end
70 changes: 69 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_12_18_165322) do
ActiveRecord::Schema.define(version: 2024_02_06_222123) do

create_table "aboutnesses", id: :integer, charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.integer "work_id"
Expand Down Expand Up @@ -157,6 +157,8 @@
t.integer "status"
t.string "institution"
t.string "item_pattern", limit: 2048
t.string "vid"
t.string "scope"
end

create_table "blazer_audits", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
Expand Down Expand Up @@ -226,6 +228,55 @@
t.index ["manifestation_id"], name: "index_bookmarks_on_manifestation_id"
end

create_table "collection_items", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.bigint "collection_id"
t.string "alt_title"
t.text "context"
t.integer "seqno"
t.string "item_type"
t.bigint "item_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.string "markdown", limit: 2048
t.index ["collection_id"], name: "index_collection_items_on_collection_id"
t.index ["item_type", "item_id"], name: "index_collection_items_on_item"
end

create_table "collections", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.string "title"
t.string "sort_title"
t.string "subtitle"
t.string "issn"
t.integer "collection_type"
t.string "inception"
t.integer "inception_year"
t.integer "publication_id"
t.integer "toc_id"
t.integer "toc_strategy"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["inception_year"], name: "index_collections_on_inception_year"
t.index ["publication_id"], name: "index_collections_on_publication_id"
t.index ["sort_title"], name: "index_collections_on_sort_title"
t.index ["toc_id"], name: "index_collections_on_toc_id"
end

create_table "corporate_bodies", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.string "name"
t.string "alternate_names"
t.string "location"
t.string "inception"
t.integer "inception_year"
t.string "dissolution"
t.integer "dissolution_year"
t.string "wikidata_uri"
t.string "viaf_id"
t.text "comments"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["name"], name: "index_corporate_bodies_on_name"
end

create_table "creations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.integer "work_id"
t.integer "person_id"
Expand Down Expand Up @@ -478,6 +529,18 @@
t.index ["user_id"], name: "index_impressions_on_user_id"
end

create_table "involved_authorities", charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.string "authority_type"
t.bigint "authority_id"
t.integer "role"
t.string "item_type"
t.bigint "item_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["authority_type", "authority_id"], name: "index_involved_authorities_on_authority"
t.index ["item_type", "item_id"], name: "index_involved_authorities_on_item"
end

create_table "legacy_recommendations", id: :integer, charset: "utf8mb4", collation: "utf8mb4_bin", force: :cascade do |t|
t.string "from"
t.string "about"
Expand Down Expand Up @@ -717,10 +780,12 @@
t.string "sort_name"
t.integer "status"
t.datetime "published_at"
t.integer "root_collection_id"
t.index ["gender"], name: "gender_index"
t.index ["impressions_count"], name: "index_people_on_impressions_count"
t.index ["name"], name: "index_people_on_name"
t.index ["period"], name: "index_people_on_period"
t.index ["root_collection_id"], name: "index_people_on_root_collection_id"
t.index ["sort_name"], name: "index_people_on_sort_name"
t.index ["status", "published_at"], name: "index_people_on_status_and_published_at"
t.index ["toc_id"], name: "people_toc_id_fk"
Expand Down Expand Up @@ -1008,6 +1073,9 @@
add_foreign_key "base_users", "users"
add_foreign_key "bookmarks", "base_users"
add_foreign_key "bookmarks", "manifestations"
add_foreign_key "collection_items", "collections"
add_foreign_key "collections", "publications"
add_foreign_key "collections", "tocs"
add_foreign_key "dictionary_aliases", "dictionary_entries"
add_foreign_key "dictionary_entries", "manifestations"
add_foreign_key "dictionary_links", "dictionary_entries", column: "from_entry_id"
Expand Down

0 comments on commit 57a4ab1

Please sign in to comment.