from_hyrax 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/from_hyrax/application.js +4 -4
- data/app/controllers/from_hyrax_controller.rb +42 -96
- data/app/views/from_hyrax/_rows.erb +6 -2
- data/app/views/from_hyrax/index.html.erb +1 -1
- data/app/views/from_hyrax/new.html.erb +3 -3
- data/config/routes.rb +6 -6
- data/lib/from_hyrax/version.rb +1 -1
- metadata +2 -3
- data/app/views/from_hyrax/create.html.erb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a456ae00345fe94bd306dada4cbad8adb0b15d5711a36f4ca42f301fb95f73a
|
4
|
+
data.tar.gz: bdba2ee1cda317be7785a03c34dfda8e02b44928fc48dd56f5bc30c660dcf2c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5431fb3d21d357f88b5e54b5263f34f21830aaee235cbc7e41cf067d19e26fb22df3e49fe63bab7e98a855961e40582d87b7b8535da859db1c8639537bb2c9a5
|
7
|
+
data.tar.gz: aa6c9bfa913f8e488a0ffa381208645bff700fe0b3c204f1b751019db79228062e47b261c7fd27b051228867b5fcafa142cfe1e324d04d8d730a3de008abfc32
|
@@ -13,10 +13,10 @@
|
|
13
13
|
//= require_tree .
|
14
14
|
|
15
15
|
function newSelect(e) {
|
16
|
-
count = e.parentElement.childElementCount/2;
|
16
|
+
count = e.parentElement.childElementCount / 2;
|
17
17
|
cln = e.previousElementSibling.cloneNode(true);
|
18
|
-
cln.name = cln.name.replace(/spotlight\]\[.*\]/, "spotlight]["+count+"]");
|
19
|
-
cln.id = cln.id.replace(/spotlight\]\[.*\]/, "spotlight]["+count+"]");
|
18
|
+
cln.name = cln.name.replace(/spotlight\]\[.*\]/, "spotlight][" + count + "]");
|
19
|
+
cln.id = cln.id.replace(/spotlight\]\[.*\]/, "spotlight][" + count + "]");
|
20
20
|
e.parentElement.appendChild(document.createElement('br'));
|
21
21
|
e.parentElement.appendChild(cln);
|
22
22
|
|
@@ -26,7 +26,7 @@ function get_next(e) {
|
|
26
26
|
var url = "/from_hyrax/hyrax_api?repo=" + e.value + "&api_type=collections";
|
27
27
|
var replace = document.getElementById("collections_div");
|
28
28
|
var xhttp = new XMLHttpRequest();
|
29
|
-
xhttp.onreadystatechange = function() {
|
29
|
+
xhttp.onreadystatechange = function () {
|
30
30
|
if (this.readyState == 4 && this.status == 200) {
|
31
31
|
replace.innerHTML = this.responseText;
|
32
32
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class FromHyraxController < Spotlight::ApplicationController
|
2
2
|
layout 'from_hyrax/application'
|
3
|
-
before_action :authenticate_user
|
3
|
+
before_action :authenticate_user!, except: :receive
|
4
4
|
protect_from_forgery with: :exception
|
5
5
|
skip_before_action :verify_authenticity_token, only: :receive
|
6
6
|
load_and_authorize_resource :current_exhibit, class: Spotlight::Exhibit
|
@@ -8,7 +8,7 @@ class FromHyraxController < Spotlight::ApplicationController
|
|
8
8
|
|
9
9
|
def hyrax_api
|
10
10
|
return nil unless instances.include?(params[:repo])
|
11
|
-
uri
|
11
|
+
uri = URI("#{params[:repo]}/to_spotlight/api/#{params[:api_type]}")
|
12
12
|
response = get_response(uri)
|
13
13
|
render html: response.body.html_safe
|
14
14
|
end
|
@@ -18,18 +18,19 @@ class FromHyraxController < Spotlight::ApplicationController
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def new
|
21
|
-
uri
|
22
|
-
response
|
23
|
-
@hyrax_fields
|
21
|
+
uri = URI("#{params[:repo]}/to_spotlight/api/fields")
|
22
|
+
response = get_response(uri)
|
23
|
+
@hyrax_fields = eval(response.body)
|
24
24
|
@spotlight_fields = spotlight_fields.map { |f| [f[:label], f[:field_name]] }
|
25
25
|
end
|
26
26
|
|
27
27
|
def create
|
28
28
|
return unless instances.include? params[:repo]
|
29
29
|
# go to: to_spotlight/receive
|
30
|
-
@mappings
|
31
|
-
post_options = {
|
32
|
-
@res
|
30
|
+
@mappings = params[:transfer][:mappings].permit!.to_h.map { |_, v| v unless v['spotlight']['0'].empty? }.compact #use hash.values
|
31
|
+
post_options = {transfer: params[:transfer], mappings: @mappings, token: token}
|
32
|
+
@res = post_response URI("#{params[:repo]}/to_spotlight/receive"), post_options
|
33
|
+
redirect_to from_hyrax_index_path
|
33
34
|
end
|
34
35
|
|
35
36
|
def receive
|
@@ -39,98 +40,43 @@ class FromHyraxController < Spotlight::ApplicationController
|
|
39
40
|
|
40
41
|
private
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
def get_response uri
|
44
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
45
|
+
http.use_ssl = true
|
46
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
47
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
48
|
+
http.request(request)
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
51
|
+
def post_response uri, options = {}
|
52
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
53
|
+
http.use_ssl = true
|
54
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
55
|
+
request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')
|
56
|
+
request.body = options.to_json
|
57
|
+
http.request(request)
|
58
|
+
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
def instances
|
61
|
+
@instances ||= FromHyrax::Engine.config['hyrax_instances'] || []
|
62
|
+
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
def token
|
65
|
+
FromHyrax::Engine.config['secret_token']
|
66
|
+
end
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
def csv_params
|
69
|
+
params.require(:transfer).permit(:user, :exhibit_id).to_h
|
70
|
+
end
|
70
71
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
{ label: 'Publisher', field_name: 'spotlight_upload_Publisher_tesim' },
|
81
|
-
{ label: 'Contributors', field_name: 'spotlight_upload_Contributors_tesim' },
|
82
|
-
{ label: 'Date', field_name: 'spotlight_upload_dc_Date_tesi' },
|
83
|
-
{ label: 'Date searchable', field_name: 'spotlight_upload_dc_Date-Created_Searchable_ftesi' },
|
84
|
-
{ label: 'Date searchable', field_name: 'spotlight_upload_dc_Date-Created_Searchable_tesi' },
|
85
|
-
{ label: 'Genre', field_name: 'spotlight_upload_dc_Type_Genre_tesim' },
|
86
|
-
{ label: 'Genre Facet', field_name: 'spotlight_upload_dc_Type_Genre_ftesim' },
|
87
|
-
{ label: 'Format', field_name: 'spotlight_upload_Format_tesim' },
|
88
|
-
{ label: 'Identifier', field_name: 'spotlight_upload_Identifier_tesim' },
|
89
|
-
{ label: 'Source', field_name: 'spotlight_upload_Source_tesim' },
|
90
|
-
{ label: 'Language', field_name: 'spotlight_upload_Language_tesim' },
|
91
|
-
{ label: 'Language Facet', field_name: 'spotlight_upload_Language_ftesim' },
|
92
|
-
{ label: 'Relation', field_name: 'spotlight_upload_Relation_tesim' },
|
93
|
-
{ label: 'Coverage', field_name: 'spotlight_upload_Coverage_tesim' },
|
94
|
-
{ label: 'Rights', field_name: 'spotlight_upload_Rights_tesim' },
|
95
|
-
{ label: 'Provenance', field_name: 'spotlight_upload_Provenance_tesim' },
|
96
|
-
{ label: 'Title-Alternative', field_name: 'spotlight_upload_dc_Title_Alternative_tesim' },
|
97
|
-
{ label: 'Description-Table Of Contents', field_name: 'spotlight_upload_Description-Table-Of-Contents_tesim' },
|
98
|
-
{ label: 'Description-Abstract', field_name: 'spotlight_upload_Description-Abstract_tesim' },
|
99
|
-
{ label: 'Format-Extent', field_name: 'spotlight_upload_Format-Extent_tesim' },
|
100
|
-
{ label: 'Format-Medium', field_name: 'spotlight_upload_Format-Medium_tesim' },
|
101
|
-
{ label: 'Identifier-Bibliographic Citation', field_name: 'spotlight_upload_Identifier-Bibliographic-Citation_tesim' },
|
102
|
-
{ label: 'Collection', field_name: 'spotlight_upload_dc_Relation_IsPartOf_Collection_tesim' },
|
103
|
-
{ label: 'Collection Facet', field_name: 'spotlight_upload_dc_Relation_IsPartOf_Collection_ftesim' },
|
104
|
-
{ label: 'Location(s)', field_name: 'spotlight_upload_dc_Coverage-Spatial_Location_tesim' },
|
105
|
-
{ label: 'Location(s) Facet', field_name: 'spotlight_upload_dc_Coverage-Spatial_Location_ftesim' },
|
106
|
-
{ label: 'Coverage-Temporal', field_name: 'spotlight_upload_Coverage-Temporal_tesim' },
|
107
|
-
{ label: 'Date Digitized', field_name: 'spotlight_upload_Date-Digitized_tesi' },
|
108
|
-
{ label: 'Transcript', field_name: 'spotlight_upload_dc_Description_Transcript_tesim' },
|
109
|
-
{ label: 'People Depicted', field_name: 'spotlight_upload_dc_Subject_People_tesim' },
|
110
|
-
{ label: 'People Facet', field_name: 'spotlight_upload_dc_Subject_People_ftesim' },
|
111
|
-
{ label: 'Sketchfab Uid', field_name: 'spotlight_upload_Sketchfab-uid_tesim' },
|
112
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_x_dbsm },
|
113
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_y_dbsm },
|
114
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_width_dbsm },
|
115
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_height_dbsm },
|
116
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_title_tesim },
|
117
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_author_tesim },
|
118
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_description_tesim },
|
119
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_date_tesim },
|
120
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_publisher_tesim },
|
121
|
-
{ label: 'Hidden', field_name: 'spotlight_annotation_publisher-place_tesim' },
|
122
|
-
{ label: 'Hidden', field_name: 'spotlight_annotation_publisher-date_tesim' },
|
123
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_people_tesim },
|
124
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_locations_tesim },
|
125
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_transcript_tesim },
|
126
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_genre_tesim },
|
127
|
-
{ label: 'Hidden', field_name: :spotlight_annotation_public_isim },
|
128
|
-
{ label: 'Parent', field_name: 'spotlight_upload_parent_tesim' },
|
129
|
-
{ label: 'Commentary', field_name: 'spotlight_upload_Commentary_tesim' },
|
130
|
-
{ label: 'User Defined 2', field_name: 'spotlight_upload_UserDefined_tesim' },
|
131
|
-
{ label: 'sortDate', field_name: 'sortDate' },
|
132
|
-
{ label: 'Geographic Coordinates', field_name: 'spotlight_upload_dc_box_tesim' }
|
133
|
-
]
|
134
|
-
end
|
72
|
+
def spotlight_fields
|
73
|
+
@spotlight_fields ||= Spotlight::Engine.config.upload_fields
|
74
|
+
.map do |f|
|
75
|
+
{
|
76
|
+
label: f.label,
|
77
|
+
field_name: f.field_name
|
78
|
+
}
|
79
|
+
end
|
80
|
+
end
|
135
81
|
|
136
82
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
<tr
|
1
|
+
<tr>
|
2
|
+
<td><b><%= "Common Fields" %></b></td>
|
3
|
+
</tr>
|
2
4
|
<% @hyrax_fields.each do |category, fields| %>
|
3
5
|
|
4
6
|
<% fields.each_with_index do |field, i| %>
|
@@ -17,6 +19,8 @@
|
|
17
19
|
</td>
|
18
20
|
</tr>
|
19
21
|
<% end %>
|
20
|
-
<tr
|
22
|
+
<tr>
|
23
|
+
<td><b><%= "Work Specific Fields" if category.include? "common" %></b></td>
|
24
|
+
</tr>
|
21
25
|
<% end %>
|
22
26
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= render 'spotlight/shared/exhibit_sidebar' %>
|
2
2
|
<div id="content" class="col-md-9">
|
3
|
-
<%= form_tag
|
3
|
+
<%= form_tag from_hyrax_new_path do %>
|
4
4
|
<%= select_tag "repo", options_for_select(@instances), {include_blank: true, onchange: 'get_next(this)'} %>
|
5
5
|
<div id="collections_div"></div>
|
6
6
|
<%= submit_tag 'start mapping' %>
|
@@ -13,14 +13,14 @@
|
|
13
13
|
<div id="content" class="col-md-9">
|
14
14
|
<h1><%= "Map from #{params[:repo]}" %></h1>
|
15
15
|
|
16
|
-
|
16
|
+
<%#= params.inspect %>
|
17
17
|
|
18
|
-
<%= form_tag
|
18
|
+
<%= form_tag from_hyrax_create_path do %>
|
19
19
|
|
20
20
|
<%#= select_tag "admin_set", options_for_select(@admin_sets), include_blank: true %>
|
21
21
|
<%= hidden_field_tag "repo", params[:repo] %>
|
22
22
|
<%= hidden_field_tag "transfer[user]", current_user %>
|
23
|
-
<%= hidden_field_tag "transfer[exhibit_id]",
|
23
|
+
<%= hidden_field_tag "transfer[exhibit_id]", current_exhibit.id %>
|
24
24
|
<%= hidden_field_tag "transfer[collection_id]", params[:collection] %>
|
25
25
|
<%= hidden_field_tag "transfer[spotlight_url]", request.base_url %>
|
26
26
|
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
get 'index'
|
3
|
-
post 'new'
|
4
|
-
post 'create'
|
5
|
-
post 'receive'
|
6
|
-
get 'hyrax_api'
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
get '/spotlight/:exhibit_id/from_hyrax' => 'from_hyrax#index', as: 'from_hyrax_index'
|
3
|
+
post '/spotlight/:exhibit_id/from_hyrax/new' => 'from_hyrax#new', as: 'from_hyrax_new'
|
4
|
+
post '/from_hyrax/create' => 'from_hyrax#create'
|
5
|
+
post '/from_hyrax/receive' => 'from_hyrax#receive'
|
6
|
+
get '/from_hyrax/hyrax_api' => 'from_hyrax#hyrax_api'
|
7
7
|
end
|
data/lib/from_hyrax/version.rb
CHANGED
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.6
|
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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -60,7 +60,6 @@ files:
|
|
60
60
|
- app/mailers/from_hyrax/application_mailer.rb
|
61
61
|
- app/models/from_hyrax/application_record.rb
|
62
62
|
- app/views/from_hyrax/_rows.erb
|
63
|
-
- app/views/from_hyrax/create.html.erb
|
64
63
|
- app/views/from_hyrax/index.html.erb
|
65
64
|
- app/views/from_hyrax/new.html.erb
|
66
65
|
- app/views/from_hyrax/receive.html.erb
|