diff --git a/Gemfile b/Gemfile index a846947f0..9785fc838 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 6a6d3387e..6e42c51c5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -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) diff --git a/app/controllers/bib_controller.rb b/app/controllers/bib_controller.rb index 1309cc0e6..f1acc5742 100644 --- a/app/controllers/bib_controller.rb +++ b/app/controllers/bib_controller.rb @@ -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 diff --git a/app/controllers/bib_sources_controller.rb b/app/controllers/bib_sources_controller.rb index 5ed30f729..d312dd0ff 100644 --- a/app/controllers/bib_sources_controller.rb +++ b/app/controllers/bib_sources_controller.rb @@ -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]}, @@ -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 diff --git a/app/views/bib_sources/_form.html.haml b/app/views/bib_sources/_form.html.haml index 4dcdfc6f5..50e233785 100644 --- a/app/views/bib_sources/_form.html.haml +++ b/app/views/bib_sources/_form.html.haml @@ -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 @@ -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); } } diff --git a/app/views/bib_sources/show.html.haml b/app/views/bib_sources/show.html.haml index a06616f64..71c169ee3 100644 --- a/app/views/bib_sources/show.html.haml +++ b/app/views/bib_sources/show.html.haml @@ -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) diff --git a/config/locales/he.yml b/config/locales/he.yml index 976871453..d103716ab 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -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: סוגות וסוגים diff --git a/db/migrate/20240206222123_add_vid_scope_to_bib_source.rb b/db/migrate/20240206222123_add_vid_scope_to_bib_source.rb new file mode 100644 index 000000000..8543f4204 --- /dev/null +++ b/db/migrate/20240206222123_add_vid_scope_to_bib_source.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 455de9f58..426861d1e 100755 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" @@ -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| @@ -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" @@ -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" @@ -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" @@ -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"