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 committed Feb 17, 2024
1 parent c325c91 commit 0f0cdaf
Show file tree
Hide file tree
Showing 48 changed files with 322 additions and 221 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ GEM
paperclip-meta (3.1.0)
paperclip (>= 5.0)
parallel (1.24.0)
parallel_tests (4.5.0)
parallel_tests (4.5.1)
parallel
pg (1.4.6)
pr_geohash (1.0.0)
Expand Down
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 @@ -259,7 +259,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
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/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

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

Loading

0 comments on commit 0f0cdaf

Please sign in to comment.