from_hyrax 0.2.1 → 0.2.2
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 +29 -9
- data/lib/from_hyrax/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc37017312a929f14a93fb14cc52628a6c5375e9e7c0390097d722299f912f98
|
4
|
+
data.tar.gz: 8b7170e120b5f243be4745425c9e76575342784e8c1d7447b19407ec8965117c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb5545c4ac7823e3bde4bb02801dedeb90c0d2f45e360b0e43740257518f58bee6b4a3c3d40a26a5257b80b4d0b033764a82ea380d4dfeb56c0fa5b6cd799583
|
7
|
+
data.tar.gz: e06683c9524ce851d9a90acaeaac3b0d4f5bf4aface55e5d218b1a63f38bedb592fd1fe37f830a18f790ae954a9709611fae26ba64c33ac14154fa48f4f6794f
|
@@ -5,18 +5,19 @@ class FromHyraxController < ActionController::Base
|
|
5
5
|
require 'net/http'
|
6
6
|
|
7
7
|
def hyrax_api
|
8
|
-
|
9
|
-
|
8
|
+
return nil unless instances.include?(params[:repo])
|
9
|
+
uri = URI("https://#{params[:repo]}/to_spotlight/api/#{params[:api_type]}")
|
10
|
+
response = get_response(uri)
|
10
11
|
render html: response.body.html_safe
|
11
12
|
end
|
12
13
|
|
13
14
|
def index
|
14
|
-
|
15
|
+
instances
|
15
16
|
end
|
16
17
|
|
17
18
|
def new
|
18
19
|
uri = URI("http://#{params[:repo]}/to_spotlight/api/fields?work=#{params[:work]}")
|
19
|
-
response =
|
20
|
+
response = get_response(uri)
|
20
21
|
@hyrax_fields = eval(response.body)
|
21
22
|
@spotlight_fields = spotlight_fields.map { |f| [f[:label], f[:field_name]] }
|
22
23
|
end
|
@@ -26,11 +27,13 @@ class FromHyraxController < ActionController::Base
|
|
26
27
|
# use Spotlight::Engine.config.upload_fields to get spotlight fields list
|
27
28
|
# map {|f| [f.label, f.field_name]}
|
28
29
|
@mappings = params[:transfer][:mappings].permit!.to_h.map { |_, v| v unless v['spotlight']['0'].empty? }.compact #use hash.values
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
#@res = Net::HTTP.post URI("http://#{params[:repo]}/to_spotlight/receive"),
|
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' }
|
36
|
+
@res = post_response URI("http://#{params[:repo]}/to_spotlight/receive"), post_options
|
34
37
|
end
|
35
38
|
|
36
39
|
def receive
|
@@ -39,6 +42,23 @@ class FromHyraxController < ActionController::Base
|
|
39
42
|
|
40
43
|
private
|
41
44
|
|
45
|
+
def get_response uri
|
46
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
47
|
+
http.use_ssl = true
|
48
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
49
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
50
|
+
http.request(request)
|
51
|
+
end
|
52
|
+
|
53
|
+
def post_response uri, options={}
|
54
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
55
|
+
http.use_ssl = true
|
56
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
57
|
+
request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')
|
58
|
+
request.body = options.to_json
|
59
|
+
http.request(request)
|
60
|
+
end
|
61
|
+
|
42
62
|
def instances
|
43
63
|
@instances ||= FromHyrax::Engine.config['hyrax_instances'] || []
|
44
64
|
end
|
data/lib/from_hyrax/version.rb
CHANGED