from_hyrax 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/from_hyrax_controller.rb +7 -8
- data/app/jobs/from_hyrax/run_import_job.rb +11 -13
- data/app/views/from_hyrax/index.html.erb +8 -9
- data/app/views/from_hyrax/new.html.erb +19 -21
- data/lib/from_hyrax/version.rb +1 -1
- data/lib/generators/install/install_generator.rb +1 -1
- data/lib/generators/install/templates/config/from_hyrax.yml +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d58d64b8fd9446a26bfcbd58655dd7ad39b03a853707b13b09fd30d2a594f40b
|
4
|
+
data.tar.gz: 3d69d08df378a7036390d75101e426db526a74a0a4c7e7760d6dbf9c43b93a75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 520a52ddb299bb2b2307afdae1b7136d0fabdfaaa586885f7136100dbbc68655440d58782201c037de654394e898686bc798110622419fd3a0462ebe87d7b921
|
7
|
+
data.tar.gz: 4848021ff6d5e005077f38f283195714d570d1772e169c5fbd9eccff3a30aa8fe8915eeabe1ce7c1a545207edcf3b4af57ab6822ece55d0029425181cb343ddf
|
@@ -1,7 +1,9 @@
|
|
1
1
|
class FromHyraxController < ActionController::Base
|
2
2
|
layout 'from_hyrax/application'
|
3
|
+
before_action :authenticate_user!
|
3
4
|
protect_from_forgery with: :exception
|
4
5
|
skip_before_action :verify_authenticity_token, only: :receive
|
6
|
+
load_and_authorize_resource :current_exhibit, class: Spotlight::Exhibit
|
5
7
|
require 'net/http'
|
6
8
|
|
7
9
|
def hyrax_api
|
@@ -23,20 +25,15 @@ class FromHyraxController < ActionController::Base
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def create
|
28
|
+
return unless instances.include? params[:repo]
|
26
29
|
# go to: to_spotlight/receive
|
27
|
-
# use Spotlight::Engine.config.upload_fields to get spotlight fields list
|
28
|
-
# map {|f| [f.label, f.field_name]}
|
29
30
|
@mappings = params[:transfer][:mappings].permit!.to_h.map { |_, v| v unless v['spotlight']['0'].empty? }.compact #use hash.values
|
30
|
-
|
31
|
-
# { transfer: params[:transfer],
|
32
|
-
# mappings: @mappings,
|
33
|
-
# token: 'secret_token' }.to_json,
|
34
|
-
# 'Content-Type' => 'application/json'
|
35
|
-
post_options = { transfer: params[:transfer], mappings: @mappings, token: 'secret_token' }
|
31
|
+
post_options = { transfer: params[:transfer], mappings: @mappings, token: token }
|
36
32
|
@res = post_response URI("#{params[:repo]}/to_spotlight/receive"), post_options
|
37
33
|
end
|
38
34
|
|
39
35
|
def receive
|
36
|
+
return unless params[:token] == token
|
40
37
|
FromHyrax::RunImportJob.perform_later(params[:csv_url], csv_params)
|
41
38
|
end
|
42
39
|
|
@@ -72,6 +69,8 @@ class FromHyraxController < ActionController::Base
|
|
72
69
|
end
|
73
70
|
|
74
71
|
def spotlight_fields
|
72
|
+
# use Spotlight::Engine.config.upload_fields to get spotlight fields list
|
73
|
+
# map {|f| [f.label, f.field_name]}
|
75
74
|
[
|
76
75
|
{ label: 'Description', field_name: 'spotlight_upload_dc_description_tesim' },
|
77
76
|
{ label: 'Abstract', field_name: 'spotlight_upload_dc_Subject_tesim' },
|
@@ -3,21 +3,19 @@ module FromHyrax
|
|
3
3
|
queue_as :default
|
4
4
|
|
5
5
|
def perform(csv_url, csv_params)
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
Rails.logger.warn "Import Job #{csv_url}, params: #{csv_params.inspect}"
|
7
|
+
csv = CSV.parse(get_response(URI(csv_url)).body, headers: true, return_headers: false).map(&:to_hash)
|
8
|
+
exhibit = ::Spotlight::Exhibit.find(csv_params[:exhibit_id])
|
9
|
+
user = ::User.find(csv_params[:user])
|
9
10
|
Spotlight::AddUploadsFromCSV.perform_later(csv, exhibit, user)
|
10
11
|
end
|
11
12
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
io.set_encoding('utf-8')
|
13
|
+
def get_response uri
|
14
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
15
|
+
http.use_ssl = true
|
16
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
17
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
18
|
+
http.request(request)
|
21
19
|
end
|
22
20
|
end
|
23
|
-
end
|
21
|
+
end
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<%= select_tag "repo", options_for_select(@instances), {include_blank: true, onchange: 'get_next(this)'} %>
|
7
|
-
|
8
|
-
|
9
|
-
<% end %>
|
1
|
+
<%= render 'spotlight/shared/exhibit_sidebar' %>
|
2
|
+
<div id="content" class="col-md-9">
|
3
|
+
<%= form_tag from_hyrax.new_path do %>
|
4
|
+
<%= select_tag "repo", options_for_select(@instances), {include_blank: true, onchange: 'get_next(this)'} %>
|
5
|
+
<div id="collections_div"></div>
|
6
|
+
<%= submit_tag 'start mapping' %>
|
7
|
+
<% end %>
|
8
|
+
</div>
|
@@ -1,34 +1,32 @@
|
|
1
|
-
|
2
|
-
<p>Find me in app/views/from_hyrax/from_hyrax/new.html.erb</p>
|
3
|
-
|
1
|
+
<%= render 'spotlight/shared/exhibit_sidebar' %>
|
4
2
|
<style type="text/css" media="screen">
|
5
3
|
|
6
|
-
table{
|
7
|
-
border-collapse:collapse;
|
8
|
-
border:1px solid black;
|
4
|
+
table {
|
5
|
+
border-collapse: collapse;
|
6
|
+
border: 1px solid black;
|
9
7
|
}
|
10
8
|
|
11
|
-
table td{
|
12
|
-
border:1px solid black;
|
9
|
+
table td {
|
10
|
+
border: 1px solid black;
|
13
11
|
}
|
14
12
|
</style>
|
13
|
+
<div id="content" class="col-md-9">
|
14
|
+
<h1><%= "Map from #{params[:repo]}" %></h1>
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
<%= params.inspect %>
|
19
|
-
|
20
|
-
<%= form_tag from_hyrax.create_path do %>
|
16
|
+
<%= params.inspect %>
|
21
17
|
|
22
|
-
|
18
|
+
<%= form_tag from_hyrax.create_path do %>
|
23
19
|
|
24
|
-
|
25
|
-
<%= render 'rows' %>
|
20
|
+
<%#= select_tag "admin_set", options_for_select(@admin_sets), include_blank: true %>
|
26
21
|
<%= hidden_field_tag "repo", params[:repo] %>
|
27
|
-
<%= hidden_field_tag "transfer[user]",
|
28
|
-
<%= hidden_field_tag "transfer[exhibit_id]",
|
22
|
+
<%= hidden_field_tag "transfer[user]", current_user %>
|
23
|
+
<%= hidden_field_tag "transfer[exhibit_id]", @current_exhibit.id %>
|
29
24
|
<%= hidden_field_tag "transfer[collection_id]", params[:collection] %>
|
30
25
|
<%= hidden_field_tag "transfer[spotlight_url]", request.base_url %>
|
31
|
-
</table>
|
32
|
-
<%= submit_tag 'request import'%>
|
33
|
-
<% end %>
|
34
26
|
|
27
|
+
<table>
|
28
|
+
<%= render 'rows' %>
|
29
|
+
</table>
|
30
|
+
<%= submit_tag 'request import' %>
|
31
|
+
<% end %>
|
32
|
+
</div>
|
data/lib/from_hyrax/version.rb
CHANGED
@@ -2,6 +2,6 @@ class CdmMigrator::InstallGenerator < Rails::Generators::Base
|
|
2
2
|
source_root File.expand_path('../templates', __FILE__)
|
3
3
|
|
4
4
|
def inject_content_dm_yml
|
5
|
-
copy_file(
|
5
|
+
copy_file('config/from_hyrax.yml', 'config/from_hyrax.yml') unless File.file?('config/from_hyrax.yml')
|
6
6
|
end
|
7
7
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: from_hyrax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sephirothkod
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|