to_spotlight 0.2 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/to_spotlight/spotlight_transfer_controller.rb +30 -2
- data/app/jobs/to_spotlight/spotlight_transfer_job.rb +13 -6
- data/app/views/to_spotlight/spotlight_transfer/approve.html.erb +0 -2
- data/lib/generators/install/install_generator.rb +7 -0
- data/lib/generators/install/templates/config/to_spotlight.yml +1 -0
- data/lib/to_spotlight/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42072bef23a9bedf75316257ef35e762377533a0a47eb9736cc301110760017f
|
4
|
+
data.tar.gz: 12287d3718e9c835fe4e4de9451cb2320d7618062a4b2335ef81c79da3c23adb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5b1cbeb353243a6bcdf333feaeee88c5e83a07973cef77c3b4c2bc9fcee5e97df779ee2fbe85a570163158dec377aff2a588dc105a2beba5ae89ad5a2328b5c
|
7
|
+
data.tar.gz: edd17d9bc9b12b183f77320ae504953d8c753b3f6c0bffed75c79d0268067028effe8936bd3a8b3b1f43c3d498930b041f585970766ad37bfc835e34ccb4333d
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module ToSpotlight
|
2
|
-
class SpotlightTransferController <
|
2
|
+
class SpotlightTransferController < ApplicationController
|
3
3
|
protect_from_forgery with: :exception
|
4
|
+
before_action :authenticate_user!
|
4
5
|
skip_before_action :verify_authenticity_token, only: :receive
|
6
|
+
helper_method :default_page_title, :admin_host?, :available_translations, :available_works
|
7
|
+
include ActionView::Helpers::UrlHelper
|
8
|
+
layout 'hyrax/dashboard' if Hyrax
|
9
|
+
before_action :authenticate, except: :index
|
5
10
|
require 'json'
|
6
11
|
require 'net/http'
|
7
12
|
|
@@ -20,7 +25,7 @@ module ToSpotlight
|
|
20
25
|
end
|
21
26
|
|
22
27
|
def receive
|
23
|
-
return unless params[:token]
|
28
|
+
return unless params[:token] == token
|
24
29
|
@transfer = ToSpotlight::SpotlightTransfer.new get_transfer_attributes
|
25
30
|
@transfer.mappings = params[:mappings]
|
26
31
|
if @transfer.save
|
@@ -50,6 +55,10 @@ module ToSpotlight
|
|
50
55
|
|
51
56
|
private
|
52
57
|
|
58
|
+
def token
|
59
|
+
ToSpotlight::Engine.config['hyrax_instances']
|
60
|
+
end
|
61
|
+
|
53
62
|
def mapping_invert(hash)
|
54
63
|
result = []
|
55
64
|
test = hash.map { |h| {h['hyrax'] => h['spotlight'].values} }
|
@@ -118,5 +127,24 @@ module ToSpotlight
|
|
118
127
|
:spotlight_url)
|
119
128
|
end
|
120
129
|
|
130
|
+
#helpers
|
131
|
+
def available_works
|
132
|
+
@available_works ||= Hyrax::QuickClassificationQuery.new(current_user).authorized_models
|
133
|
+
end
|
134
|
+
|
135
|
+
def default_page_title
|
136
|
+
'Spotlight Transfer'
|
137
|
+
end
|
138
|
+
|
139
|
+
def admin_host?
|
140
|
+
false unless Settings.multitenancy.enabled rescue nil
|
141
|
+
end
|
142
|
+
|
143
|
+
def available_translations
|
144
|
+
{
|
145
|
+
'en' => 'English',
|
146
|
+
'fr' => 'French'
|
147
|
+
}
|
148
|
+
end
|
121
149
|
end
|
122
150
|
end
|
@@ -50,15 +50,22 @@ module ToSpotlight
|
|
50
50
|
File.open(dir.join(filename), 'wb') do |file|
|
51
51
|
file.write(csv_array.join("\n"))
|
52
52
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
token: 'secret_token' }.to_json,
|
58
|
-
'Content-Type' => 'application/json'
|
53
|
+
res = post_response URI("#{transfer.spotlight_url}/from_hyrax/receive"),
|
54
|
+
csv_url: "https://#{base_url}/uploads/csvs/#{filename}",
|
55
|
+
transfer: transfer.attributes.slice(:user, :exhibit), #only allow user+exhibit
|
56
|
+
token: 'secret_token'
|
59
57
|
|
60
58
|
end
|
61
59
|
|
60
|
+
def post_response uri, options={}
|
61
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
62
|
+
http.use_ssl = true
|
63
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
64
|
+
request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')
|
65
|
+
request.body = options.to_json
|
66
|
+
http.request(request)
|
67
|
+
end
|
68
|
+
|
62
69
|
def base_url
|
63
70
|
@base_url ||= ::Account.where(tenant: Apartment::Tenant.current).first.cname
|
64
71
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class CdmMigrator::InstallGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def inject_content_dm_yml
|
5
|
+
copy_file('config/to_spotlight.yml', 'config/to_spotlight.yml') unless File.file?('config/to_spotlight.yml')
|
6
|
+
end
|
7
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
secret_token: 'rftvgyuhwefhcgyvuryweudijxoschdufygvebhqwdijloschvugbeiofhqdijlcnhqeljcmjioeql328r9hdfec3h'
|
data/lib/to_spotlight/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: to_spotlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.5
|
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
|
@@ -72,6 +72,8 @@ files:
|
|
72
72
|
- config/application.rb
|
73
73
|
- config/routes.rb
|
74
74
|
- db/migrate/20200310153953_create_to_spotlight_spotlight_transfers.rb
|
75
|
+
- lib/generators/install/install_generator.rb
|
76
|
+
- lib/generators/install/templates/config/to_spotlight.yml
|
75
77
|
- lib/tasks/to_spotlight_tasks.rake
|
76
78
|
- lib/to_spotlight.rb
|
77
79
|
- lib/to_spotlight/engine.rb
|