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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 701c458c978b82af2182dd38541d47e138d167dc833594ec907bc75a7fae22ce
4
- data.tar.gz: d17303bc8c32a043db18b1ff382adce41bb8e09717de46e77fe781918612622e
3
+ metadata.gz: 8a456ae00345fe94bd306dada4cbad8adb0b15d5711a36f4ca42f301fb95f73a
4
+ data.tar.gz: bdba2ee1cda317be7785a03c34dfda8e02b44928fc48dd56f5bc30c660dcf2c2
5
5
  SHA512:
6
- metadata.gz: 021ea7d23cc8068b078cd76f30514189879bcc21b1db1c92ffbb52839fe52e3b4b301b10580e3291988aace386d52c2bda0d4be6417aade08af483c29bbb2876
7
- data.tar.gz: 18ef84636d952fd114429608194765658bda88307210c98e05845c632b575f6cd37332e5b93027c1701fdeb0b2d32a7ba640d7b2a4dd0a30eaf3aef8d73fc1a8
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 = URI("#{params[:repo]}/to_spotlight/api/#{params[:api_type]}")
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 = URI("#{params[:repo]}/to_spotlight/api/fields")
22
- response = get_response(uri)
23
- @hyrax_fields = eval(response.body)
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 = 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
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
- def get_response uri
43
- http = Net::HTTP.new(uri.host, uri.port)
44
- http.use_ssl = true
45
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
46
- request = Net::HTTP::Get.new(uri.request_uri)
47
- http.request(request)
48
- end
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
- def post_response uri, options={}
51
- http = Net::HTTP.new(uri.host, uri.port)
52
- http.use_ssl = true
53
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
54
- request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json')
55
- request.body = options.to_json
56
- http.request(request)
57
- end
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
- def instances
60
- @instances ||= FromHyrax::Engine.config['hyrax_instances'] || []
61
- end
60
+ def instances
61
+ @instances ||= FromHyrax::Engine.config['hyrax_instances'] || []
62
+ end
62
63
 
63
- def token
64
- FromHyrax::Engine.config['secret_token']
65
- end
64
+ def token
65
+ FromHyrax::Engine.config['secret_token']
66
+ end
66
67
 
67
- def csv_params
68
- params.require(:transfer).permit(:user, :exhibit_id).to_h
69
- end
68
+ def csv_params
69
+ params.require(:transfer).permit(:user, :exhibit_id).to_h
70
+ end
70
71
 
71
- def spotlight_fields
72
- # use Spotlight::Engine.config.upload_fields to get spotlight fields list
73
- # map {|f| [f.label, f.field_name]}
74
- [
75
- { label: 'Description', field_name: 'spotlight_upload_dc_description_tesim' },
76
- { label: 'Abstract', field_name: 'spotlight_upload_dc_Subject_tesim' },
77
- { label: 'Subjects', field_name: 'spotlight_upload_dc_Subjects_tesim' },
78
- { label: 'Subjects Facet', field_name: 'spotlight_upload_dc_Subjects_ftesim' },
79
- { label: 'Creator', field_name: 'spotlight_upload_Creator_tesim' },
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><td><b><%= "Common Fields" %></b></td></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><td><b><%= "Work Specific Fields" if category.include?"common" %></b></td></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 from_hyrax.new_path do %>
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
- <%= params.inspect %>
16
+ <%#= params.inspect %>
17
17
 
18
- <%= form_tag from_hyrax.create_path do %>
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]", @current_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
- FromHyrax::Engine.routes.draw do
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
@@ -1,3 +1,3 @@
1
1
  module FromHyrax
2
- VERSION = '0.2.5'.freeze
2
+ VERSION = '0.2.6'.freeze
3
3
  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.5
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-05 00:00:00.000000000 Z
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
@@ -1,7 +0,0 @@
1
- <h1>FromHyrax::FromHyrax#create</h1>
2
- <p>Find me in app/views/from_hyrax/from_hyrax/create.html.erb</p>
3
- <br>
4
-
5
- <%= @mappings %>
6
- <br>
7
- <%= @res.body %>