hydra-head 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.textile +7 -3
- data/app/controllers/assets_controller.rb +1 -145
- data/app/views/catalog/_edit_partials/_default_details.html.erb +0 -2
- data/lib/hydra-head/version.rb +1 -1
- data/lib/hydra.rb +3 -1
- data/lib/hydra/assets.rb +147 -0
- data/vendor/cache/curb-0.7.15.gem +0 -0
- metadata +5 -3
data/HISTORY.textile
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
h3. 3.1.2
|
2
|
+
* Make asset controller easily overridden
|
3
|
+
|
4
|
+
|
1
5
|
h3. 3.1.1
|
2
|
-
*
|
3
|
-
*
|
4
|
-
* Don't issue two notice
|
6
|
+
* Selected facet was not html_safe
|
7
|
+
* document_list was attempting to call Mash#get, when sorting by object_type_facet
|
8
|
+
* Don't issue two notice messages when saving document.
|
5
9
|
|
6
10
|
|
7
11
|
h3. 3.1.0
|
@@ -1,147 +1,3 @@
|
|
1
|
-
require 'mediashelf/active_fedora_helper'
|
2
|
-
|
3
1
|
class AssetsController < ApplicationController
|
4
|
-
include
|
5
|
-
include Blacklight::SolrHelper
|
6
|
-
include Hydra::RepositoryController
|
7
|
-
include Hydra::AssetsControllerHelper
|
8
|
-
include ReleaseProcessHelper
|
9
|
-
|
10
|
-
|
11
|
-
include Blacklight::Catalog
|
12
|
-
helper :hydra
|
13
|
-
|
14
|
-
before_filter :search_session, :history_session
|
15
|
-
before_filter :load_document, :only => :update # allows other filters to operate on the document before the update method is called
|
16
|
-
before_filter :require_solr
|
17
|
-
|
18
|
-
# need to include this after the :require_solr/fedora before filters because of the before filter that the workflow provides.
|
19
|
-
include Hydra::SubmissionWorkflow
|
20
|
-
|
21
|
-
|
22
|
-
prepend_before_filter :sanitize_update_params, :only=>:update
|
23
|
-
before_filter :check_embargo_date_format, :only=>:update
|
24
|
-
|
25
|
-
def show
|
26
|
-
if params.has_key?("field")
|
27
|
-
|
28
|
-
@response, @document = get_solr_response_for_doc_id
|
29
|
-
# @document = SolrDocument.new(@response.docs.first)
|
30
|
-
result = @document["#{params["field"]}_t"]
|
31
|
-
# document_fedora = SaltDocument.load_instance(params[:id])
|
32
|
-
# result = document_fedora.datastreams_in_memory[params["datastream"]].send("#{params[:field]}_values")
|
33
|
-
unless result.nil?
|
34
|
-
if params.has_key?("field_index")
|
35
|
-
result = result[params["field_index"].to_i-1]
|
36
|
-
elsif result.kind_of?(Array)
|
37
|
-
result = result.first
|
38
|
-
end
|
39
|
-
end
|
40
|
-
respond_to do |format|
|
41
|
-
format.html { render :text=>result }
|
42
|
-
format.textile { render :text=> RedCloth.new(result, [:sanitize_html]).to_html }
|
43
|
-
end
|
44
|
-
else
|
45
|
-
redirect_to :controller=>"catalog", :action=>"show"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# Uses the update_indexed_attributes method provided by ActiveFedora::Base
|
50
|
-
# This should behave pretty much like the ActiveRecord update_indexed_attributes method
|
51
|
-
# For more information, see the ActiveFedora docs.
|
52
|
-
#
|
53
|
-
# @example Appends a new "subject" value of "My Topic" to on the descMetadata datastream in in the _PID_ document.
|
54
|
-
# put :update, :id=>"_PID_", "asset"=>{"descMetadata"=>{"subject"=>{"-1"=>"My Topic"}}
|
55
|
-
# @example Sets the 1st and 2nd "medium" values on the descMetadata datastream in the _PID_ document, overwriting any existing values.
|
56
|
-
# put :update, :id=>"_PID_", "asset"=>{"descMetadata"=>{"medium"=>{"0"=>"Paper Document", "1"=>"Image"}}
|
57
|
-
def update
|
58
|
-
logger.debug("attributes submitted: #{@sanitized_params.inspect}")
|
59
|
-
|
60
|
-
@response = update_document(@document, @sanitized_params)
|
61
|
-
|
62
|
-
@document.save
|
63
|
-
flash[:notice] = "Your changes have been saved."
|
64
|
-
|
65
|
-
logger.debug("returning #{response.inspect}")
|
66
|
-
|
67
|
-
respond_to do |want|
|
68
|
-
want.html {
|
69
|
-
redirect_to( {:controller => "catalog", :action => "edit", :id => params[:id]}.merge(params_for_next_step_in_wokflow) )
|
70
|
-
}
|
71
|
-
want.js {
|
72
|
-
render :json=> tidy_response_from_update(@response)
|
73
|
-
}
|
74
|
-
want.textile {
|
75
|
-
if @response.kind_of?(Hash)
|
76
|
-
textile_response = tidy_response_from_update(@response).values.first
|
77
|
-
end
|
78
|
-
render :text=> RedCloth.new(textile_response, [:sanitize_html]).to_html
|
79
|
-
}
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def new
|
84
|
-
af_model = retrieve_af_model(params[:content_type])
|
85
|
-
if af_model
|
86
|
-
@asset = af_model.new
|
87
|
-
apply_depositor_metadata(@asset)
|
88
|
-
set_collection_type(@asset, params[:content_type])
|
89
|
-
@asset.save
|
90
|
-
model_display_name = af_model.to_s.camelize.scan(/[A-Z][^A-Z]*/).join(" ")
|
91
|
-
msg = "Created a #{model_display_name} with pid #{@asset.pid}. Now it's ready to be edited."
|
92
|
-
flash[:notice]= msg
|
93
|
-
end
|
94
|
-
session[:scripts] = params[:combined] == "true"
|
95
|
-
redirect_to url_for(:action=>"edit", :controller=>"catalog", :id=>@asset.pid, :new_asset=>true)
|
96
|
-
end
|
97
|
-
|
98
|
-
def destroy
|
99
|
-
af = ActiveFedora::Base.load_instance_from_solr(params[:id])
|
100
|
-
the_model = ActiveFedora::ContentModel.known_models_for( af ).first
|
101
|
-
unless the_model.nil?
|
102
|
-
af = the_model.load_instance_from_solr(params[:id])
|
103
|
-
assets = af.destroy_child_assets
|
104
|
-
end
|
105
|
-
af.delete
|
106
|
-
msg = "Deleted #{params[:id]}"
|
107
|
-
msg.concat(" and associated file_asset(s): #{assets.join(", ")}") unless assets.empty?
|
108
|
-
flash[:notice]= msg
|
109
|
-
redirect_to url_for(:action => 'index', :controller => "catalog", :q => nil , :f => nil)
|
110
|
-
end
|
111
|
-
|
112
|
-
|
113
|
-
# This is a method to simply remove the item from SOLR but keep the object in fedora.
|
114
|
-
alias_method :withdraw, :destroy
|
115
|
-
|
116
|
-
protected
|
117
|
-
|
118
|
-
def load_document
|
119
|
-
@document = load_document_from_params
|
120
|
-
end
|
121
|
-
|
122
|
-
|
123
|
-
def mods_assets_update_validation
|
124
|
-
desc_metadata = params[:asset][:descMetadata]
|
125
|
-
rights_metadata = params[:asset][:rightsMetadata]
|
126
|
-
if !rights_metadata.nil? and rights_metadata.has_key?(:embargo_embargo_release_date)
|
127
|
-
unless rights_metadata[:embargo_embargo_release_date]["0"].blank?
|
128
|
-
begin
|
129
|
-
parsed_date = Date.parse(rights_metadata[:embargo_embargo_release_date]["0"]).to_s
|
130
|
-
params[:asset][:rightsMetadata][:embargo_embargo_release_date]["0"] = parsed_date
|
131
|
-
rescue
|
132
|
-
flash[:error] = "You must enter a valid release date."
|
133
|
-
return false
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
if !desc_metadata.nil? and desc_metadata.has_key?(:title_info_main_title) and desc_metadata.has_key?(:journal_0_title_info_main_title)
|
139
|
-
if desc_metadata[:title_info_main_title]["0"].blank? or desc_metadata[:journal_0_title_info_main_title]["0"].blank?
|
140
|
-
flash[:error] = "The title fields are required."
|
141
|
-
return false
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
return true
|
146
|
-
end
|
2
|
+
include Hydra::Assets
|
147
3
|
end
|
@@ -4,8 +4,6 @@
|
|
4
4
|
<%= form_tag url_for(:action=>"update", :controller=>"assets"), :id=>"document_metadata" "accept-charset"=>"utf-8" do %>
|
5
5
|
|
6
6
|
<div id="multipleEdit">
|
7
|
-
<div id="loading" style="display:none;"><img src="/plugin_assets/hydra-head/images/ajax-loader.gif" width="32" height="32" alt="Saving"/> Saving...</div>
|
8
|
-
<div>
|
9
7
|
<dl class="defList fl-theme-mist">
|
10
8
|
<%= editable_metadata_field(@document_fedora, "descMetadata", :title, :label => "Title:") %>
|
11
9
|
</dl>
|
data/lib/hydra-head/version.rb
CHANGED
data/lib/hydra.rb
CHANGED
data/lib/hydra/assets.rb
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
module Hydra::Assets
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
include MediaShelf::ActiveFedoraHelper
|
4
|
+
include Blacklight::SolrHelper
|
5
|
+
include Hydra::RepositoryController
|
6
|
+
include Hydra::AssetsControllerHelper
|
7
|
+
include ReleaseProcessHelper
|
8
|
+
include Blacklight::Catalog
|
9
|
+
|
10
|
+
included do
|
11
|
+
helper :hydra
|
12
|
+
|
13
|
+
before_filter :search_session, :history_session
|
14
|
+
before_filter :require_solr
|
15
|
+
before_filter :load_document, :only => :update # allows other filters to operate on the document before the update method is called
|
16
|
+
|
17
|
+
# need to include this after the :require_solr/fedora before filters because of the before filter that the workflow provides.
|
18
|
+
include Hydra::SubmissionWorkflow
|
19
|
+
|
20
|
+
|
21
|
+
prepend_before_filter :sanitize_update_params, :only=>:update
|
22
|
+
before_filter :check_embargo_date_format, :only=>:update
|
23
|
+
end
|
24
|
+
|
25
|
+
def show
|
26
|
+
if params.has_key?("field")
|
27
|
+
|
28
|
+
@response, @document = get_solr_response_for_doc_id
|
29
|
+
# @document = SolrDocument.new(@response.docs.first)
|
30
|
+
result = @document["#{params["field"]}_t"]
|
31
|
+
# document_fedora = SaltDocument.load_instance(params[:id])
|
32
|
+
# result = document_fedora.datastreams_in_memory[params["datastream"]].send("#{params[:field]}_values")
|
33
|
+
unless result.nil?
|
34
|
+
if params.has_key?("field_index")
|
35
|
+
result = result[params["field_index"].to_i-1]
|
36
|
+
elsif result.kind_of?(Array)
|
37
|
+
result = result.first
|
38
|
+
end
|
39
|
+
end
|
40
|
+
respond_to do |format|
|
41
|
+
format.html { render :text=>result }
|
42
|
+
format.textile { render :text=> RedCloth.new(result, [:sanitize_html]).to_html }
|
43
|
+
end
|
44
|
+
else
|
45
|
+
redirect_to :controller=>"catalog", :action=>"show"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Uses the update_indexed_attributes method provided by ActiveFedora::Base
|
50
|
+
# This should behave pretty much like the ActiveRecord update_indexed_attributes method
|
51
|
+
# For more information, see the ActiveFedora docs.
|
52
|
+
#
|
53
|
+
# @example Appends a new "subject" value of "My Topic" to on the descMetadata datastream in in the _PID_ document.
|
54
|
+
# put :update, :id=>"_PID_", "asset"=>{"descMetadata"=>{"subject"=>{"-1"=>"My Topic"}}
|
55
|
+
# @example Sets the 1st and 2nd "medium" values on the descMetadata datastream in the _PID_ document, overwriting any existing values.
|
56
|
+
# put :update, :id=>"_PID_", "asset"=>{"descMetadata"=>{"medium"=>{"0"=>"Paper Document", "1"=>"Image"}}
|
57
|
+
def update
|
58
|
+
logger.debug("attributes submitted: #{@sanitized_params.inspect}")
|
59
|
+
|
60
|
+
@response = update_document(@document, @sanitized_params)
|
61
|
+
|
62
|
+
@document.save
|
63
|
+
flash[:notice] = "Your changes have been saved."
|
64
|
+
|
65
|
+
logger.debug("returning #{response.inspect}")
|
66
|
+
|
67
|
+
respond_to do |want|
|
68
|
+
want.html {
|
69
|
+
redirect_to( {:controller => "catalog", :action => "edit", :id => params[:id]}.merge(params_for_next_step_in_wokflow) )
|
70
|
+
}
|
71
|
+
want.js {
|
72
|
+
render :json=> tidy_response_from_update(@response)
|
73
|
+
}
|
74
|
+
want.textile {
|
75
|
+
if @response.kind_of?(Hash)
|
76
|
+
textile_response = tidy_response_from_update(@response).values.first
|
77
|
+
end
|
78
|
+
render :text=> RedCloth.new(textile_response, [:sanitize_html]).to_html
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def new
|
84
|
+
af_model = retrieve_af_model(params[:content_type])
|
85
|
+
if af_model
|
86
|
+
@asset = af_model.new
|
87
|
+
apply_depositor_metadata(@asset)
|
88
|
+
set_collection_type(@asset, params[:content_type])
|
89
|
+
@asset.save
|
90
|
+
model_display_name = af_model.to_s.camelize.scan(/[A-Z][^A-Z]*/).join(" ")
|
91
|
+
msg = "Created a #{model_display_name} with pid #{@asset.pid}. Now it's ready to be edited."
|
92
|
+
flash[:notice]= msg
|
93
|
+
end
|
94
|
+
session[:scripts] = params[:combined] == "true"
|
95
|
+
redirect_to url_for(:action=>"edit", :controller=>"catalog", :id=>@asset.pid, :new_asset=>true)
|
96
|
+
end
|
97
|
+
|
98
|
+
def destroy
|
99
|
+
af = ActiveFedora::Base.load_instance_from_solr(params[:id])
|
100
|
+
the_model = ActiveFedora::ContentModel.known_models_for( af ).first
|
101
|
+
unless the_model.nil?
|
102
|
+
af = the_model.load_instance_from_solr(params[:id])
|
103
|
+
assets = af.destroy_child_assets
|
104
|
+
end
|
105
|
+
af.delete
|
106
|
+
msg = "Deleted #{params[:id]}"
|
107
|
+
msg.concat(" and associated file_asset(s): #{assets.join(", ")}") unless assets.empty?
|
108
|
+
flash[:notice]= msg
|
109
|
+
redirect_to url_for(:action => 'index', :controller => "catalog", :q => nil , :f => nil)
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
# This is a method to simply remove the item from SOLR but keep the object in fedora.
|
114
|
+
alias_method :withdraw, :destroy
|
115
|
+
|
116
|
+
protected
|
117
|
+
|
118
|
+
def load_document
|
119
|
+
@document = load_document_from_params
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
def mods_assets_update_validation
|
124
|
+
desc_metadata = params[:asset][:descMetadata]
|
125
|
+
rights_metadata = params[:asset][:rightsMetadata]
|
126
|
+
if !rights_metadata.nil? and rights_metadata.has_key?(:embargo_embargo_release_date)
|
127
|
+
unless rights_metadata[:embargo_embargo_release_date]["0"].blank?
|
128
|
+
begin
|
129
|
+
parsed_date = Date.parse(rights_metadata[:embargo_embargo_release_date]["0"]).to_s
|
130
|
+
params[:asset][:rightsMetadata][:embargo_embargo_release_date]["0"] = parsed_date
|
131
|
+
rescue
|
132
|
+
flash[:error] = "You must enter a valid release date."
|
133
|
+
return false
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
if !desc_metadata.nil? and desc_metadata.has_key?(:title_info_main_title) and desc_metadata.has_key?(:journal_0_title_info_main_title)
|
139
|
+
if desc_metadata[:title_info_main_title]["0"].blank? or desc_metadata[:journal_0_title_info_main_title]["0"].blank?
|
140
|
+
flash[:error] = "The title fields are required."
|
141
|
+
return false
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
return true
|
146
|
+
end
|
147
|
+
end
|
Binary file
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hydra-head
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 3.1.
|
9
|
+
- 2
|
10
|
+
version: 3.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield, Justin Coyne & many more. See https://github.com/projecthydra/hydra-head/contributors
|
@@ -973,6 +973,7 @@ files:
|
|
973
973
|
- lib/hydra.rb
|
974
974
|
- lib/hydra/access_controls_enforcement.rb
|
975
975
|
- lib/hydra/access_controls_evaluation.rb
|
976
|
+
- lib/hydra/assets.rb
|
976
977
|
- lib/hydra/assets_controller_helper.rb
|
977
978
|
- lib/hydra/catalog.rb
|
978
979
|
- lib/hydra/common_mods_index_methods.rb
|
@@ -1154,6 +1155,7 @@ files:
|
|
1154
1155
|
- vendor/cache/crack-0.3.1.gem
|
1155
1156
|
- vendor/cache/cucumber-1.1.0.gem
|
1156
1157
|
- vendor/cache/cucumber-rails-1.1.1.gem
|
1158
|
+
- vendor/cache/curb-0.7.15.gem
|
1157
1159
|
- vendor/cache/daemons-1.1.4.gem
|
1158
1160
|
- vendor/cache/database_cleaner-0.6.7.gem
|
1159
1161
|
- vendor/cache/diff-lcs-1.1.3.gem
|