hydra-head 4.0.3 → 4.1.0
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/.gitignore +1 -0
- data/HISTORY.textile +17 -2
- data/app/assets/stylesheets/hydra/html_refactor.css +3 -30
- data/app/assets/stylesheets/hydra/styles.css +6 -64
- data/app/controllers/downloads_controller.rb +1 -1
- data/app/controllers/hydra/assets_controller.rb +10 -1
- data/app/controllers/hydra/contributors_controller.rb +15 -1
- data/app/controllers/hydra/file_assets_controller.rb +1 -1
- data/app/controllers/hydra/permissions_controller.rb +14 -0
- data/app/helpers/hydra/article_metadata_helper_behavior.rb +14 -1
- data/app/helpers/hydra/downloads_helper_behavior.rb +6 -0
- data/app/helpers/hydra/facets_helper_behavior.rb +7 -0
- data/app/helpers/hydra/generic_content_objects_helper_behavior.rb +6 -0
- data/app/helpers/hydra/hydra_assets_helper_behavior.rb +10 -0
- data/app/helpers/hydra/hydra_fedora_metadata_helper_behavior.rb +31 -0
- data/app/helpers/hydra/hydra_helper_behavior.rb +18 -7
- data/app/helpers/hydra/hydra_uploader_helper_behavior.rb +5 -0
- data/app/helpers/hydra/inline_editable_metadata_helper_behavior.rb +6 -0
- data/app/helpers/hydra/javascript_includes_helper_behavior.rb +7 -0
- data/app/helpers/hydra/personalization_helper_behavior.rb +5 -0
- data/app/helpers/hydra/release_process_helper_behavior.rb +5 -0
- data/app/models/generic_content.rb +3 -0
- data/app/models/generic_image.rb +3 -0
- data/app/models/superuser.rb +4 -2
- data/app/models/user_attribute.rb +7 -2
- data/app/views/_add_assets_links.html.erb +4 -4
- data/app/views/catalog/_index_partials/_default.html.erb +2 -2
- data/app/views/catalog/show.html.erb +1 -1
- data/app/views/generic_contents/_index.html.erb +2 -2
- data/app/views/generic_images/_edit.html.erb +1 -1
- data/app/views/generic_images/_index.html.erb +2 -2
- data/app/views/hydra/file_assets/_file_assets_form.html.erb +1 -1
- data/app/views/hydra/file_assets/_index.html.erb +2 -2
- data/app/views/hydra/file_assets/_result.html.erb +1 -1
- data/app/views/layouts/hydra-head.html.erb +4 -1
- data/app/views/mods_assets/_index_list.html.erb +1 -1
- data/app/views/mods_assets/_index_table.html.erb +2 -2
- data/app/views/mods_assets/_show.html.erb +1 -1
- data/app/views/mods_assets/_show_file_assets.html.erb +1 -1
- data/config/jetty.yml +1 -1
- data/config/locales/hydra.en.yml +7 -0
- data/config/solr.yml +1 -1
- data/config/solr_mappings.yml +2 -2
- data/hydra-head.gemspec +5 -4
- data/lib/generators/hydra/head_generator.rb +6 -5
- data/lib/generators/hydra/templates/config/fedora.yml +1 -1
- data/lib/generators/hydra/templates/config/solr.yml +1 -1
- data/lib/hydra-head/version.rb +1 -1
- data/lib/hydra.rb +13 -11
- data/lib/hydra/assets.rb +5 -135
- data/lib/hydra/catalog.rb +6 -44
- data/lib/hydra/controller.rb +10 -27
- data/lib/hydra/controller/assets_controller_behavior.rb +142 -0
- data/lib/hydra/controller/catalog_controller_behavior.rb +56 -0
- data/lib/hydra/controller/controller_behavior.rb +59 -0
- data/lib/hydra/controller/file_assets_behavior.rb +142 -0
- data/lib/hydra/controller/repository_controller_behavior.rb +119 -0
- data/lib/hydra/controller/upload_behavior.rb +139 -0
- data/lib/hydra/file_assets.rb +3 -138
- data/lib/hydra/file_assets_helper.rb +6 -133
- data/lib/hydra/generic_content.rb +15 -0
- data/lib/hydra/generic_image.rb +10 -0
- data/lib/hydra/global_configurable.rb +46 -0
- data/lib/hydra/model_methods.rb +3 -3
- data/lib/hydra/model_mixins.rb +1 -1
- data/lib/hydra/model_mixins/solr_document_extension.rb +24 -0
- data/lib/hydra/repository_controller.rb +4 -95
- data/lib/hydra/ui/controller.rb +1 -2
- data/lib/hydra/user.rb +13 -1
- data/lib/railties/hydra-fixtures.rake +1 -1
- data/tasks/hydra-head.rake +2 -0
- data/{app/models → test_support/etc}/common_metadata_asset.rb +1 -2
- data/test_support/features/mods_asset_show.feature +1 -1
- data/test_support/features/support/env.rb +2 -0
- data/test_support/features/support/paths.rb +2 -0
- data/test_support/spec/controllers/catalog_controller_spec.rb +8 -0
- data/test_support/spec/controllers/catalog_controller_viewing_context_spec.rb +10 -1
- data/test_support/spec/controllers/catalog_valid_html_spec.rb +8 -0
- data/test_support/spec/controllers/contributors_controller_spec.rb +10 -0
- data/test_support/spec/controllers/file_assets_controller_spec.rb +15 -3
- data/test_support/spec/controllers/hydra-assets_controller_spec.rb +11 -1
- data/test_support/spec/controllers/hydra_controller_spec.rb +15 -4
- data/test_support/spec/controllers/permissions_controller_spec.rb +8 -0
- data/test_support/spec/helpers/access_controls_enforcement_spec.rb +1 -2
- data/test_support/spec/helpers/file_assets_helper_spec.rb +1 -1
- data/test_support/spec/helpers/generic_content_objects_helper_spec.rb +10 -1
- data/test_support/spec/helpers/hydra-repository_controller_spec.rb +1 -1
- data/test_support/spec/helpers/hydra_assets_helper_spec.rb +8 -0
- data/test_support/spec/helpers/hydra_fedora_metadata_helper_spec.rb +11 -0
- data/test_support/spec/helpers/hydra_helper_spec.rb +18 -0
- data/test_support/spec/helpers/hydra_model_methods_spec.rb +0 -12
- data/test_support/spec/helpers/hydra_uploader_helper_spec.rb +8 -0
- data/test_support/spec/helpers/javascript_includes_helper_spec.rb +9 -1
- data/test_support/spec/lib/catalog_spec.rb +10 -3
- data/test_support/spec/lib/global_configurable_spec.rb +98 -0
- data/test_support/spec/lib/model_methods_spec.rb +29 -0
- data/test_support/spec/models/generic_content_spec.rb +11 -0
- data/test_support/spec/models/generic_image_spec.rb +15 -0
- data/test_support/spec/models/user_spec.rb +25 -0
- metadata +39 -37
- data/app/models/ability.rb +0 -5
- data/app/models/hydra/ability.rb +0 -137
- data/app/models/hydra/datastream/common_mods_index_methods.rb +0 -47
- data/app/models/hydra/datastream/mods_article.rb +0 -530
- data/app/models/hydra/datastream/mods_dataset.rb +0 -173
- data/app/models/hydra/datastream/mods_generic_content.rb +0 -498
- data/app/models/hydra/datastream/mods_image.rb +0 -497
- data/app/models/hydra/datastream/rights_metadata.rb +0 -191
- data/app/models/hydra/role_mapper_behavior.rb +0 -33
- data/app/models/role_mapper.rb +0 -6
- data/lib/hydra/access_controls_enforcement.rb +0 -237
- data/lib/hydra/access_controls_evaluation.rb +0 -38
- data/lib/hydra/common_mods_index_methods.rb +0 -46
- data/lib/hydra/model_mixins/mods_object.rb +0 -17
- data/lib/hydra/model_mixins/rights_metadata.rb +0 -357
- data/lib/hydra/mods_article.rb +0 -535
- data/lib/hydra/mods_dataset.rb +0 -177
- data/lib/hydra/mods_generic_content.rb +0 -500
- data/lib/hydra/mods_image.rb +0 -500
- data/lib/uva/mods_index_methods.rb +0 -30
- data/test_support/spec/lib/common_mods_index_methods_spec.rb +0 -26
- data/test_support/spec/models/ability_spec.rb +0 -40
- data/test_support/spec/models/hydra_rights_metadata_spec.rb +0 -175
- data/test_support/spec/models/role_mapper_spec.rb +0 -22
- data/test_support/spec/unit/rights_metadata_spec.rb +0 -80
data/lib/hydra/assets.rb
CHANGED
@@ -1,137 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
include Blacklight::SolrHelper
|
7
|
-
include Hydra::RepositoryController
|
8
|
-
include Hydra::AssetsControllerHelper
|
9
|
-
include ReleaseProcessHelper
|
10
|
-
include Blacklight::Catalog
|
11
|
-
|
12
|
-
included do
|
13
|
-
helper :hydra
|
14
|
-
include Hydra::UI::Controller
|
15
|
-
before_filter :search_session, :history_session
|
16
|
-
before_filter :load_document, :only => :update # allows other filters to operate on the document before the update method is called
|
17
|
-
|
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
|
-
result = @document["#{params["field"]}_t"]
|
30
|
-
unless result.nil?
|
31
|
-
if params.has_key?("field_index")
|
32
|
-
result = result[params["field_index"].to_i-1]
|
33
|
-
elsif result.kind_of?(Array)
|
34
|
-
result = result.first
|
35
|
-
end
|
36
|
-
end
|
37
|
-
respond_to do |format|
|
38
|
-
format.html { render :text=>result }
|
39
|
-
format.textile { render :text=> RedCloth.new(result, [:sanitize_html]).to_html }
|
40
|
-
end
|
41
|
-
else
|
42
|
-
redirect_to catalog_path(params[:id])
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
# Uses the update_indexed_attributes method provided by ActiveFedora::Base
|
47
|
-
# This should behave pretty much like the ActiveRecord update_indexed_attributes method
|
48
|
-
# For more information, see the ActiveFedora docs.
|
49
|
-
#
|
50
|
-
# @example Appends a new "subject" value of "My Topic" to on the descMetadata datastream in in the _PID_ document.
|
51
|
-
# put :update, :id=>"_PID_", "asset"=>{"descMetadata"=>{"subject"=>{"-1"=>"My Topic"}}
|
52
|
-
# @example Sets the 1st and 2nd "medium" values on the descMetadata datastream in the _PID_ document, overwriting any existing values.
|
53
|
-
# put :update, :id=>"_PID_", "asset"=>{"descMetadata"=>{"medium"=>{"0"=>"Paper Document", "1"=>"Image"}}
|
54
|
-
def update
|
55
|
-
logger.debug("attributes submitted: #{@sanitized_params.inspect}")
|
56
|
-
|
57
|
-
@response = update_document(@document, @sanitized_params)
|
58
|
-
|
59
|
-
@document.save
|
60
|
-
flash[:notice] = "Your changes have been saved."
|
61
|
-
|
62
|
-
#logger.debug("returning #{@response.inspect}")
|
63
|
-
|
64
|
-
respond_to do |want|
|
65
|
-
want.html {
|
66
|
-
redirect_to next_step(params[:id])
|
67
|
-
}
|
68
|
-
want.js {
|
69
|
-
render :json=> tidy_response_from_update(@response)
|
70
|
-
}
|
71
|
-
want.textile {
|
72
|
-
if @response.kind_of?(Hash)
|
73
|
-
textile_response = tidy_response_from_update(@response).values.first
|
74
|
-
end
|
75
|
-
render :text=> RedCloth.new(textile_response, [:sanitize_html]).to_html
|
76
|
-
}
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def new
|
81
|
-
af_model = retrieve_af_model(params[:content_type])
|
82
|
-
raise "Can't find a model for #{params[:content_type]}" unless af_model
|
83
|
-
@asset = af_model.new
|
84
|
-
apply_depositor_metadata(@asset)
|
85
|
-
set_collection_type(@asset, params[:content_type])
|
86
|
-
@asset.save
|
87
|
-
model_display_name = af_model.to_s.camelize.scan(/[A-Z][^A-Z]*/).join(" ")
|
88
|
-
msg = "Created a #{model_display_name} with pid #{@asset.pid}. Now it's ready to be edited."
|
89
|
-
flash[:notice]= msg
|
90
|
-
session[:scripts] = params[:combined] == "true"
|
91
|
-
|
92
|
-
redirect_to edit_catalog_path(@asset.pid, :new_asset=>true)
|
93
|
-
end
|
94
|
-
|
95
|
-
def destroy
|
96
|
-
af = ActiveFedora::Base.find(params[:id], :cast=>true)
|
97
|
-
assets = af.destroy_child_assets
|
98
|
-
af.delete
|
99
|
-
msg = "Deleted #{params[:id]}"
|
100
|
-
msg.concat(" and associated file_asset(s): #{assets.join(", ")}") unless assets.empty?
|
101
|
-
flash[:notice]= msg
|
102
|
-
redirect_to catalog_index_path()
|
103
|
-
end
|
104
|
-
|
105
|
-
|
106
|
-
# This is a method to simply remove the item from SOLR but keep the object in fedora.
|
107
|
-
alias_method :withdraw, :destroy
|
108
|
-
|
109
|
-
protected
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
def mods_assets_update_validation
|
114
|
-
desc_metadata = params[:asset][:descMetadata]
|
115
|
-
rights_metadata = params[:asset][:rightsMetadata]
|
116
|
-
if !rights_metadata.nil? and rights_metadata.has_key?(:embargo_embargo_release_date)
|
117
|
-
unless rights_metadata[:embargo_embargo_release_date]["0"].blank?
|
118
|
-
begin
|
119
|
-
parsed_date = Date.parse(rights_metadata[:embargo_embargo_release_date]["0"]).to_s
|
120
|
-
params[:asset][:rightsMetadata][:embargo_embargo_release_date]["0"] = parsed_date
|
121
|
-
rescue
|
122
|
-
flash[:error] = "You must enter a valid release date."
|
123
|
-
return false
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
if !desc_metadata.nil? and desc_metadata.has_key?(:title_info_main_title) and desc_metadata.has_key?(:journal_0_title_info_main_title)
|
129
|
-
if desc_metadata[:title_info_main_title]["0"].blank? or desc_metadata[:journal_0_title_info_main_title]["0"].blank?
|
130
|
-
flash[:error] = "The title fields are required."
|
131
|
-
return false
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
return true
|
1
|
+
module Hydra
|
2
|
+
module Assets
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
require 'hydra/controller/assets_controller_behavior'
|
5
|
+
include Hydra::Controller::AssetsControllerBehavior
|
136
6
|
end
|
137
7
|
end
|
data/lib/hydra/catalog.rb
CHANGED
@@ -1,49 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# For search & discovery in those apps, use Blacklight and customize the "index" partials for each type of content to include links to the show/edit actions of the corresponding Controllers.
|
4
|
-
#
|
5
|
-
# This Module extends Blacklight Catalog behaviors to give you a "Hydra" Catalog with edit and show behaviors on top of the Blacklight search behaviors.
|
6
|
-
# Include this module into any of your Blacklight Catalog classes (ie. CatalogController) to add Hydra functionality.
|
7
|
-
#
|
8
|
-
# will move to lib/hydra/controller/catalog_controller_behavior in release 5.x
|
1
|
+
require 'hydra/controller/catalog_controller_behavior'
|
2
|
+
require 'deprecation'
|
9
3
|
module Hydra::Catalog
|
10
4
|
extend ActiveSupport::Concern
|
11
|
-
|
12
|
-
|
5
|
+
extend Deprecation
|
6
|
+
|
13
7
|
included do
|
14
|
-
|
15
|
-
include Hydra::Controller
|
16
|
-
include Hydra::UI::Controller
|
17
|
-
|
18
|
-
# Controller filters
|
19
|
-
# Also see the generator (or generated CatalogController) to see more before_filters in action
|
20
|
-
before_filter :load_fedora_document, :only=>[:show,:edit]
|
21
|
-
|
22
|
-
# View Helpers
|
23
|
-
helper :hydra_uploader
|
24
|
-
helper :article_metadata
|
25
|
-
rescue_from ActiveFedora::ObjectNotFoundError, :with => :nonexistent_document
|
26
|
-
end
|
27
|
-
|
28
|
-
def edit
|
29
|
-
show
|
30
|
-
render "show"
|
31
|
-
end
|
32
|
-
|
33
|
-
# This will render the "delete" confirmation page and a form to submit a destroy request to the assets controller
|
34
|
-
def delete
|
35
|
-
show
|
36
|
-
render "show"
|
37
|
-
end
|
38
|
-
|
39
|
-
def nonexistent_document
|
40
|
-
if Rails.env == "development"
|
41
|
-
render
|
42
|
-
else
|
43
|
-
flash[:notice] = "Sorry, you have requested a record that doesn't exist."
|
44
|
-
params.delete(:id)
|
45
|
-
index
|
46
|
-
render "index", :status => 404
|
47
|
-
end
|
8
|
+
Deprecation.warn(Hydra::Catalog, "Hydra::Catalog is deprecated and is replaced by Hydra::Controller::CatalogControllerBehavior.")
|
9
|
+
include Hydra::Controller::CatalogControllerBehavior
|
48
10
|
end
|
49
11
|
end
|
data/lib/hydra/controller.rb
CHANGED
@@ -10,34 +10,17 @@
|
|
10
10
|
#
|
11
11
|
# will move to lib/hydra/controller/controller_behavior in release 5.x
|
12
12
|
module Hydra::Controller
|
13
|
+
autoload :AssetsControllerBehavior, 'hydra/controller/assets_controller_behavior'
|
14
|
+
autoload :CatalogControllerBehavior, 'hydra/controller/catalog_controller_behavior'
|
15
|
+
autoload :ControllerBehavior, 'hydra/controller/controller_behavior'
|
16
|
+
autoload :RepositoryControllerBehavior, 'hydra/controller/repository_controller_behavior'
|
17
|
+
autoload :UploadBehavior, 'hydra/controller/upload_behavior'
|
18
|
+
autoload :FileAssetsBehavior, 'hydra/controller/file_assets_behavior'
|
13
19
|
|
14
|
-
|
15
|
-
# Other modules to auto-include
|
16
|
-
klass.send(:include, Hydra::AccessControlsEnforcement)
|
17
|
-
klass.send(:include, Hydra::RepositoryController)
|
20
|
+
extend ActiveSupport::Concern
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
included do
|
23
|
+
ActiveSupport::Deprecation.warn("Hydra::Controller has been renamed Hydra::Controller::ControllerBehavior.")
|
24
|
+
include Hydra::Controller::ControllerBehavior
|
22
25
|
end
|
23
|
-
|
24
|
-
# Use params[:id] to load an object from Fedora. Inspects the object for known models and mixes in any of those models' behaviors.
|
25
|
-
# Sets @document_fedora with the loaded object
|
26
|
-
# Sets @file_assets with file objects that are children of the loaded object
|
27
|
-
def load_fedora_document
|
28
|
-
@document_fedora = ActiveFedora::Base.find(params[:id], :cast=>true)
|
29
|
-
unless @document_fedora.class.include?(Hydra::ModelMethods)
|
30
|
-
@document_fedora.class.send :include, Hydra::ModelMethods
|
31
|
-
end
|
32
|
-
|
33
|
-
@file_assets = @document_fedora.parts(:response_format=>:solr)
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
# get the currently configured user identifier. Can be overridden to return whatever (ie. login, email, etc)
|
38
|
-
# defaults to using whatever you have set as the Devise authentication_key
|
39
|
-
def user_key
|
40
|
-
current_user.send(Devise.authentication_keys.first)
|
41
|
-
end
|
42
|
-
|
43
26
|
end
|
@@ -0,0 +1,142 @@
|
|
1
|
+
# @deprecated Create Model-specific Controllers instead ie. ArticlesController, ETDController, etc.
|
2
|
+
# Also see Hydra::Controller::AssetsControllerBehavior for more info.
|
3
|
+
# will move to lib/hydra/controller / assets_controller_behavior.rb in release 5.x
|
4
|
+
require 'om'
|
5
|
+
|
6
|
+
module Hydra::Controller::AssetsControllerBehavior
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
include Blacklight::SolrHelper
|
10
|
+
include Hydra::Controller::RepositoryControllerBehavior
|
11
|
+
include Hydra::AssetsControllerHelper
|
12
|
+
include ReleaseProcessHelper
|
13
|
+
include Blacklight::Catalog
|
14
|
+
|
15
|
+
included do
|
16
|
+
helper :hydra
|
17
|
+
include Hydra::UI::Controller
|
18
|
+
before_filter :search_session, :history_session
|
19
|
+
before_filter :load_document, :only => :update # allows other filters to operate on the document before the update method is called
|
20
|
+
|
21
|
+
include Hydra::SubmissionWorkflow
|
22
|
+
include Hydra::AccessControlsEnforcement
|
23
|
+
|
24
|
+
|
25
|
+
prepend_before_filter :sanitize_update_params, :only=>:update
|
26
|
+
before_filter :check_embargo_date_format, :only=>:update
|
27
|
+
before_filter :enforce_access_controls
|
28
|
+
end
|
29
|
+
|
30
|
+
def show
|
31
|
+
if params.has_key?("field")
|
32
|
+
|
33
|
+
@response, @document = get_solr_response_for_doc_id
|
34
|
+
result = @document["#{params["field"]}_t"]
|
35
|
+
unless result.nil?
|
36
|
+
if params.has_key?("field_index")
|
37
|
+
result = result[params["field_index"].to_i-1]
|
38
|
+
elsif result.kind_of?(Array)
|
39
|
+
result = result.first
|
40
|
+
end
|
41
|
+
end
|
42
|
+
respond_to do |format|
|
43
|
+
format.html { render :text=>result }
|
44
|
+
format.textile { render :text=> RedCloth.new(result, [:sanitize_html]).to_html }
|
45
|
+
end
|
46
|
+
else
|
47
|
+
redirect_to catalog_path(params[:id])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Uses the update_indexed_attributes method provided by ActiveFedora::Base
|
52
|
+
# This should behave pretty much like the ActiveRecord update_indexed_attributes method
|
53
|
+
# For more information, see the ActiveFedora docs.
|
54
|
+
#
|
55
|
+
# @example Appends a new "subject" value of "My Topic" to on the descMetadata datastream in in the _PID_ document.
|
56
|
+
# put :update, :id=>"_PID_", "asset"=>{"descMetadata"=>{"subject"=>{"-1"=>"My Topic"}}
|
57
|
+
# @example Sets the 1st and 2nd "medium" values on the descMetadata datastream in the _PID_ document, overwriting any existing values.
|
58
|
+
# put :update, :id=>"_PID_", "asset"=>{"descMetadata"=>{"medium"=>{"0"=>"Paper Document", "1"=>"Image"}}
|
59
|
+
def update
|
60
|
+
logger.debug("attributes submitted: #{@sanitized_params.inspect}")
|
61
|
+
|
62
|
+
@response = update_document(@document, @sanitized_params)
|
63
|
+
|
64
|
+
@document.save
|
65
|
+
flash[:notice] = "Your changes have been saved."
|
66
|
+
|
67
|
+
#logger.debug("returning #{@response.inspect}")
|
68
|
+
|
69
|
+
respond_to do |want|
|
70
|
+
want.html {
|
71
|
+
redirect_to next_step(params[:id])
|
72
|
+
}
|
73
|
+
want.js {
|
74
|
+
render :json=> tidy_response_from_update(@response)
|
75
|
+
}
|
76
|
+
want.textile {
|
77
|
+
if @response.kind_of?(Hash)
|
78
|
+
textile_response = tidy_response_from_update(@response).values.first
|
79
|
+
end
|
80
|
+
render :text=> RedCloth.new(textile_response, [:sanitize_html]).to_html
|
81
|
+
}
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def new
|
86
|
+
af_model = retrieve_af_model(params[:content_type])
|
87
|
+
raise "Can't find a model for #{params[:content_type]}" unless af_model
|
88
|
+
@asset = af_model.new
|
89
|
+
apply_depositor_metadata(@asset)
|
90
|
+
set_collection_type(@asset, params[:content_type])
|
91
|
+
@asset.save
|
92
|
+
model_display_name = af_model.to_s.camelize.scan(/[A-Z][^A-Z]*/).join(" ")
|
93
|
+
msg = "Created a #{model_display_name} with pid #{@asset.pid}. Now it's ready to be edited."
|
94
|
+
flash[:notice]= msg
|
95
|
+
session[:scripts] = params[:combined] == "true"
|
96
|
+
|
97
|
+
redirect_to edit_catalog_path(@asset.pid, :new_asset=>true)
|
98
|
+
end
|
99
|
+
|
100
|
+
def destroy
|
101
|
+
af = ActiveFedora::Base.find(params[:id], :cast=>true)
|
102
|
+
assets = af.destroy_child_assets
|
103
|
+
af.delete
|
104
|
+
msg = "Deleted #{params[:id]}"
|
105
|
+
msg.concat(" and associated file_asset(s): #{assets.join(", ")}") unless assets.empty?
|
106
|
+
flash[:notice]= msg
|
107
|
+
redirect_to catalog_index_path()
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
# This is a method to simply remove the item from SOLR but keep the object in fedora.
|
112
|
+
alias_method :withdraw, :destroy
|
113
|
+
|
114
|
+
protected
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
def mods_assets_update_validation
|
119
|
+
desc_metadata = params[:asset][:descMetadata]
|
120
|
+
rights_metadata = params[:asset][:rightsMetadata]
|
121
|
+
if !rights_metadata.nil? and rights_metadata.has_key?(:embargo_embargo_release_date)
|
122
|
+
unless rights_metadata[:embargo_embargo_release_date]["0"].blank?
|
123
|
+
begin
|
124
|
+
parsed_date = Date.parse(rights_metadata[:embargo_embargo_release_date]["0"]).to_s
|
125
|
+
params[:asset][:rightsMetadata][:embargo_embargo_release_date]["0"] = parsed_date
|
126
|
+
rescue
|
127
|
+
flash[:error] = "You must enter a valid release date."
|
128
|
+
return false
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
if !desc_metadata.nil? and desc_metadata.has_key?(:title_info_main_title) and desc_metadata.has_key?(:journal_0_title_info_main_title)
|
134
|
+
if desc_metadata[:title_info_main_title]["0"].blank? or desc_metadata[:journal_0_title_info_main_title]["0"].blank?
|
135
|
+
flash[:error] = "The title fields are required."
|
136
|
+
return false
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
return true
|
141
|
+
end
|
142
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# *Using this Module is not necessary if you're writing Controllers in Rails3.*
|
2
|
+
# In a Rails3 app, simply define regular Rails Controllers to expose the Resources & Actions you need and use Hydra::Controller to add Hydra support.
|
3
|
+
# For search & discovery in those apps, use Blacklight and customize the "index" partials for each type of content to include links to the show/edit actions of the corresponding Controllers.
|
4
|
+
#
|
5
|
+
# This Module extends Blacklight Catalog behaviors to give you a "Hydra" Catalog with edit and show behaviors on top of the Blacklight search behaviors.
|
6
|
+
# Include this module into any of your Blacklight Catalog classes (ie. CatalogController) to add Hydra functionality.
|
7
|
+
#
|
8
|
+
# will move to lib/hydra/controller/catalog_controller_behavior in release 5.x
|
9
|
+
require 'deprecation'
|
10
|
+
module Hydra::Controller::CatalogControllerBehavior
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
extend Deprecation
|
13
|
+
|
14
|
+
self.deprecation_horizon = 'hydra-head 5.x'
|
15
|
+
|
16
|
+
|
17
|
+
included do
|
18
|
+
Deprecation.warn(Hydra::Controller::CatalogControllerBehavior, "CatalogControllerBehavior is deprecated. You should make your own controllers using the Hydra::Controller::ControllerBehavior")
|
19
|
+
# Other modules to auto-include
|
20
|
+
include Hydra::UI::Controller
|
21
|
+
|
22
|
+
# Controller filters
|
23
|
+
# Also see the generator (or generated CatalogController) to see more before_filters in action
|
24
|
+
before_filter :load_fedora_document, :only=>[:show,:edit]
|
25
|
+
|
26
|
+
# View Helpers
|
27
|
+
helper :hydra_uploader
|
28
|
+
helper :article_metadata
|
29
|
+
rescue_from ActiveFedora::ObjectNotFoundError, :with => :nonexistent_document
|
30
|
+
end
|
31
|
+
|
32
|
+
def edit
|
33
|
+
show
|
34
|
+
render "show"
|
35
|
+
end
|
36
|
+
#deprecation_deprecate :edit
|
37
|
+
|
38
|
+
# This will render the "delete" confirmation page and a form to submit a destroy request to the assets controller
|
39
|
+
def delete
|
40
|
+
show
|
41
|
+
render "show"
|
42
|
+
end
|
43
|
+
#deprecation_deprecate :delete
|
44
|
+
|
45
|
+
def nonexistent_document *args
|
46
|
+
if Rails.env == "development"
|
47
|
+
render "nonexistent_document"
|
48
|
+
else
|
49
|
+
flash[:notice] = "Sorry, you have requested a record that doesn't exist."
|
50
|
+
params.delete(:id)
|
51
|
+
index
|
52
|
+
render "index", :status => 404
|
53
|
+
end
|
54
|
+
end
|
55
|
+
#deprecation_deprecate :nonexistent_document
|
56
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Include this module into any of your Controller classes to add Hydra functionality
|
2
|
+
#
|
3
|
+
# The primary function of this module is to mix in a number of other Hydra Modules, including
|
4
|
+
# Hydra::AccessControlsEnforcement
|
5
|
+
#
|
6
|
+
# @example
|
7
|
+
# class CustomHydraController < ApplicationController
|
8
|
+
# include Hydra::Controller
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# will move to lib/hydra/controller/controller_behavior in release 5.x
|
12
|
+
require 'deprecation'
|
13
|
+
module Hydra::Controller::ControllerBehavior
|
14
|
+
extend ActiveSupport::Concern
|
15
|
+
extend Deprecation
|
16
|
+
self.deprecation_horizon = 'hydra-head 5.x'
|
17
|
+
|
18
|
+
included do
|
19
|
+
# Other modules to auto-include
|
20
|
+
include Hydra::AccessControlsEnforcement
|
21
|
+
include Hydra::Controller::RepositoryControllerBehavior
|
22
|
+
|
23
|
+
helper :hydra
|
24
|
+
helper :hydra_assets
|
25
|
+
|
26
|
+
# Catch permission errors
|
27
|
+
rescue_from Hydra::AccessDenied do |exception|
|
28
|
+
if (exception.action == :edit)
|
29
|
+
redirect_to({:action=>'show'}, :alert => exception.message)
|
30
|
+
elsif current_user and current_user.persisted?
|
31
|
+
redirect_to root_url, :alert => exception.message
|
32
|
+
else
|
33
|
+
session["user_return_to"] = request.url
|
34
|
+
redirect_to new_user_session_url, :alert => exception.message
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Use params[:id] to load an object from Fedora. Inspects the object for known models and mixes in any of those models' behaviors.
|
40
|
+
# Sets @document_fedora with the loaded object
|
41
|
+
# Sets @file_assets with file objects that are children of the loaded object
|
42
|
+
def load_fedora_document
|
43
|
+
@document_fedora = ActiveFedora::Base.find(params[:id], :cast=>true)
|
44
|
+
unless @document_fedora.class.include?(Hydra::ModelMethods)
|
45
|
+
@document_fedora.class.send :include, Hydra::ModelMethods
|
46
|
+
end
|
47
|
+
|
48
|
+
@file_assets = @document_fedora.parts(:response_format=>:solr)
|
49
|
+
end
|
50
|
+
deprecation_deprecate :load_fedora_document
|
51
|
+
|
52
|
+
|
53
|
+
# get the currently configured user identifier. Can be overridden to return whatever (ie. login, email, etc)
|
54
|
+
# defaults to using whatever you have set as the Devise authentication_key
|
55
|
+
def user_key
|
56
|
+
current_user.user_key if current_user
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|