Skip to content

Commit

Permalink
NDLサーチのインポート対象に"periodicals"などを追加 (#1859)
Browse files Browse the repository at this point in the history
* add "periodicals" to mediatype param

* fix checked_item and checkin forms

* require @rails/ujs

* require jquery_ujs

* move some JavaScript files to app/javascript

* add video and audio to mediatype

* add scores to mediatype

* update cassette files

* fix spec file
  • Loading branch information
nabeta authored Feb 17, 2024
1 parent 7f48cc7 commit e9141a8
Show file tree
Hide file tree
Showing 54 changed files with 574 additions and 423 deletions.
11 changes: 6 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ GEM
warden (~> 1.2.3)
diff-lcs (1.5.1)
docile (1.4.0)
dotenv (3.0.0)
dotenv-rails (3.0.0)
dotenv (= 3.0.0)
dotenv (3.0.1)
dotenv-rails (3.0.1)
dotenv (= 3.0.1)
railties (>= 6.1)
ebnf (2.5.0)
htmlentities (~> 4.3)
Expand Down Expand Up @@ -268,7 +268,8 @@ GEM
nio4r (2.7.0)
nokogiri (1.16.2-x86_64-linux)
racc (~> 1.4)
nori (2.6.0)
nori (2.7.0)
bigdecimal
oai (1.2.1)
builder (>= 3.1.0)
faraday (< 3)
Expand All @@ -278,7 +279,7 @@ GEM
parallel (1.24.0)
parallel_tests (4.5.0)
parallel
pg (1.5.4)
pg (1.5.5)
pr_geohash (1.0.0)
pretender (0.5.0)
actionpack (>= 6.1)
Expand Down
3 changes: 0 additions & 3 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,4 @@
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require rails-ujs
//= require activestorage
//= require jquery2
//= require enju_leaf
1 change: 1 addition & 0 deletions app/controllers/checkins_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def index
else
@checkins = Checkin.page(params[:page])
end
@checkin = Checkin.new

respond_to do |format|
format.html # index.html.erb
Expand Down
6 changes: 6 additions & 0 deletions app/javascript/channels/consumer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `bin/rails generate channel` command.

import { createConsumer } from "@rails/actioncable"

export default createConsumer()
5 changes: 5 additions & 0 deletions app/javascript/channels/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Load all the channels within this directory and all subdirectories.
// Channel files must be named *_channel.js.

const channels = require.context('.', true, /_channel\.js$/)
channels.keys().forEach(channels)
13 changes: 12 additions & 1 deletion app/javascript/packs/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,15 @@
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)

console.log('Hello World from Webpacker')
//console.log('Hello World from Webpacker')

import Rails from "@rails/ujs"
import * as ActiveStorage from "@rails/activestorage"
import "channels"
import "jquery"
import $ from 'jquery'
global.$ = $
global.jQuery = $

Rails.start()
ActiveStorage.start()
2 changes: 1 addition & 1 deletion app/models/concerns/enju_ndl/enju_manifestation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def create_additional_attributes(doc, manifestation)
end

def search_ndl(query, options = {})
options = { dpid: 'iss-ndl-opac', item: 'any', idx: 1, per_page: 10, raw: false, mediatype: 'books' }.merge(options)
options = { dpid: 'iss-ndl-opac', item: 'any', idx: 1, per_page: 10, raw: false, mediatype: 'books periodicals video audio scores' }.merge(options)
doc = nil
results = {}
startrecord = options[:idx].to_i
Expand Down
2 changes: 1 addition & 1 deletion app/models/ndl_book.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def self.search(query, page = 1, _per_page = per_page)
cnt = per_page
page = 1 if page.to_i < 1
idx = (page.to_i - 1) * cnt + 1
doc = Nokogiri::XML(Manifestation.search_ndl(query, cnt: cnt, page: page, idx: idx, raw: true, mediatype: 'books').to_s)
doc = Nokogiri::XML(Manifestation.search_ndl(query, cnt: cnt, page: page, idx: idx, raw: true, mediatype: 'books periodicals video audio scores').to_s)
items = doc.xpath('//channel/item').map{|node| new node }
total_entries = doc.at('//channel/openSearch:totalResults').content.to_i

Expand Down
4 changes: 2 additions & 2 deletions app/views/checked_items/_list.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div style="color: red"><%= flash[:message] -%></div>

<div class="search_form">
<%= form_with(model: checked_item, html: {method: :post}, url: checked_items_path(basket_id: @basket.id)) do |f| -%>
<%= error_messages(@checked_item) if @checked_item -%>
<%= form_with(model: checked_item, html: {method: :post}, url: checked_items_path(basket_id: @basket.id), local: false) do |f| -%>
<%= error_messages(checked_item) if checked_item -%>
<p>
<%= f.label :item_identifier, t('activerecord.attributes.item.item_identifier') -%>: <%= f.search_field :item_identifier, class: 'resource_item_identifier' -%>
<%= f.submit t('page.read'), 'data-disable-with' => t('page.saving') -%><br />
Expand Down
2 changes: 1 addition & 1 deletion app/views/checked_items/index.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$("#checked_item_list").html("<%= escape_javascript(render('checked_items/list')) %>");
$("#checked_item_list").html("<%= escape_javascript(render('checked_items/list', checked_item: @checked_item)) %>");
2 changes: 1 addition & 1 deletion app/views/checkins/_list.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div style="color: red"><%= flash[:message] -%></div>

<div class="search_form">
<%= form_with(model: checkin, html: {method: :post}, url: checkins_path(basket_id: @basket.id)) do |f| -%>
<%= form_with(model: checkin, html: {method: :post}, url: checkins_path(basket_id: @basket.id), local: false) do |f| -%>
<%= error_messages(checkin) %>
<p>
<%= label_tag :item_identifier, t('activerecord.attributes.item.item_identifier') -%>:
Expand Down
2 changes: 1 addition & 1 deletion app/views/checkins/index.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$("#checkin_list").html("<%= escape_javascript(render('checkins/list')) %>");
$("#checkin_list").html("<%= escape_javascript(render('checkins/list', checkin: @checkin)) %>");
1 change: 1 addition & 0 deletions app/views/page/_include.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<%= stylesheet_link_tag 'application' %>
<%= stylesheet_link_tag 'print', media: :print %>
<%= javascript_pack_tag 'application' %>
<%= javascript_include_tag 'application' %>
<%= csrf_meta_tag %>

Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
module EnjuLeaf
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 7.0
config.load_defaults 6.1

# Configuration for the application, engines, and railties goes here.
#
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
"name": "enju_leaf",
"private": true,
"dependencies": {
"@rails/actioncable": "~7.0.8",
"@rails/activestorage": "~7.0.8",
"@rails/ujs": "~7.0.8",
"@rails/webpacker": "5.4.3",
"mirador": "^3.3.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12"
"webpack-cli": "^3.3.12",
"jquery": "^2.2.4"
},
"devDependencies": {
"webpack-dev-server": "^3"
Expand Down

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

Loading

0 comments on commit e9141a8

Please sign in to comment.