fcrepo_admin 0.4.0 → 0.4.1

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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.rdoc +13 -9
  3. data/README.rdoc +37 -33
  4. data/app/controllers/fcrepo_admin/associations_controller.rb +51 -4
  5. data/app/controllers/fcrepo_admin/datastreams_controller.rb +102 -1
  6. data/app/controllers/fcrepo_admin/objects_controller.rb +26 -3
  7. data/app/views/fcrepo_admin/associations/_associations.html.erb +3 -3
  8. data/app/views/fcrepo_admin/associations/show.html.erb +8 -4
  9. data/app/views/fcrepo_admin/datastreams/_active_fedora.html.erb +1 -0
  10. data/app/views/fcrepo_admin/datastreams/_context_nav_items.html.erb +27 -10
  11. data/app/views/fcrepo_admin/datastreams/_datastreams.html.erb +2 -32
  12. data/app/views/fcrepo_admin/datastreams/_datastreams_list.html.erb +30 -0
  13. data/app/views/fcrepo_admin/datastreams/_profile.html.erb +16 -9
  14. data/app/views/fcrepo_admin/datastreams/_version.html.erb +1 -0
  15. data/app/views/fcrepo_admin/datastreams/history.html.erb +25 -0
  16. data/app/views/fcrepo_admin/datastreams/show.html.erb +2 -0
  17. data/app/views/fcrepo_admin/objects/_datastreams.html.erb +3 -0
  18. data/app/views/fcrepo_admin/objects/_inherited_permissions.html.erb +1 -5
  19. data/app/views/fcrepo_admin/objects/_properties.html.erb +2 -1
  20. data/app/views/fcrepo_admin/objects/show.html.erb +8 -2
  21. data/app/views/layouts/fcrepo_admin/datastreams.html.erb +9 -2
  22. data/config/locales/fcrepo_admin.en.yml +6 -10
  23. data/config/routes.rb +1 -0
  24. data/lib/fcrepo_admin.rb +0 -4
  25. data/lib/fcrepo_admin/ability.rb +1 -0
  26. data/lib/fcrepo_admin/controller/controller_behavior.rb +16 -16
  27. data/lib/fcrepo_admin/helpers/associations_helper_behavior.rb +4 -7
  28. data/lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb +10 -4
  29. data/lib/fcrepo_admin/helpers/fcrepo_admin_helper_behavior.rb +10 -0
  30. data/lib/fcrepo_admin/helpers/objects_helper_behavior.rb +13 -0
  31. data/lib/fcrepo_admin/version.rb +1 -1
  32. data/spec/features/associations/index.html.erb_spec.rb +2 -2
  33. data/spec/features/datastreams/show.html.erb_spec.rb +2 -2
  34. metadata +7 -6
  35. data/lib/fcrepo_admin/controller/associations_controller_behavior.rb +0 -49
  36. data/lib/fcrepo_admin/controller/catalog_controller_behavior.rb +0 -9
  37. data/lib/fcrepo_admin/controller/datastreams_controller_behavior.rb +0 -73
  38. data/lib/fcrepo_admin/controller/objects_controller_behavior.rb +0 -42
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 037b085bbd970e56f0258962a525d716e7126de3
4
- data.tar.gz: b5198489fc6a71de84f2ccd823d9f9b989aa4ea4
3
+ metadata.gz: 305ef9978b750b747db1086587bf2d1728a59db9
4
+ data.tar.gz: 6c1b3182517d5540696c72f69a8eb5eb8e360925
5
5
  SHA512:
6
- metadata.gz: 58d1033182af3051b5115b6d812bcbf5f04a52ed082e2feb1f3deb47a1eaf9f14fd564bd0e4966aa2d0d6da40587d778cbe00341398edad8d596562a7fe5afe7
7
- data.tar.gz: 0fa62de534dd7ce460a2dec042f3fd8e0c291443dc8a426d8c1c44fde9cc53195faea74c26cd2115a1e5db1d504d088c408d3d12adbe82e29458f5f36e9eaf80
6
+ metadata.gz: b2c10fdd7964b34923d6486be2fb8b1c05215e9430d0f8cf75e04007f80ab658660f83220502b9469a94f1467d49a364a80714b209ddad2efc726d0fed71e887
7
+ data.tar.gz: 277b2fc6f1dd3a411ace6984eec531d60cd2e5d4ac9b906e9774f9064d283c84d82e6abf8630dc0110328de7803cf95e79d460a641f704e4c1b80a149a6e5af1
data/HISTORY.rdoc CHANGED
@@ -1,14 +1,18 @@
1
- === 0.4.0
1
+ ==== 0.4.1 (2013-05-14)
2
+
3
+ * Feature: Datastream history view
4
+
5
+ === 0.4.0 (2013-05-03)
2
6
 
3
7
  * Feature: Display object's associations.
4
8
  * Require inclusion of CanCan action aliases in application's Ability class.
5
9
  * Tabbed object show view ("summary") replaced with separate views.
6
10
 
7
- === 0.3.5
11
+ ==== 0.3.5 (2013-04-30)
8
12
 
9
13
  * Requires active-fedora 6.1.
10
14
 
11
- === 0.3.4
15
+ ==== 0.3.4 (2013-04-29)
12
16
 
13
17
  * Moved FcrepoAdmin::BlacklightHelperBehavior to FcrepoAdmin::Helpers::BlacklightHelperBehavior.
14
18
  * FcrepoAdmin::ObjectsHelper methods can now be easily overridden.
@@ -17,29 +21,29 @@
17
21
  * Objects and datastreams controller behaviors are now easily overrideable.
18
22
  * Refactored object and datastream context navs for greater reusability.
19
23
 
20
- === 0.3.3
24
+ ==== 0.3.3 (2013-04-25)
21
25
 
22
26
  * Audit trail functionality fails gracefully (i.e., if object does not implement ActiveFedora::Auditable)
23
27
 
24
- === 0.3.2
28
+ ==== 0.3.2 (2013-04-19)
25
29
 
26
30
  * Separated datastream and object context navigation menus.
27
31
  * Added object helpers.
28
32
 
29
- === 0.3.1
33
+ ==== 0.3.1 (2013-04-18)
30
34
 
31
35
  * Object and datastream context nav menus added.
32
36
  * Audit trail moved into objects controller.
33
37
 
34
- == 0.3.0
38
+ === 0.3.0 (2013-04-16)
35
39
 
36
40
  * Feature: Permissions and inherited permissions added to object show view.
37
41
 
38
- == 0.2.0
42
+ === 0.2.0 (2013-04-12)
39
43
 
40
44
  * Feature: Datastream content editing.
41
45
 
42
- == 0.1.0
46
+ === 0.1.0 (2013-04-11)
43
47
 
44
48
  Initial release to RubyGems.
45
49
 
data/README.rdoc CHANGED
@@ -1,18 +1,18 @@
1
- == Hydra Administrative Tool for a Fedora Repository
1
+ = Hydra Administrative Tool for a Fedora Repository
2
2
 
3
3
  A Rails engine providing an administrative interface to a Fedora Commons repository built on the Hydra project framework.
4
4
 
5
- === Status
5
+ == Status
6
6
 
7
7
  This project should be considered *experimental* and not ready for production deployment.
8
8
  Versions earlier than 1.0 may change API and/or UI without notice or regard for backward compatibility.
9
9
 
10
- === Requirements
10
+ == Requirements
11
11
 
12
12
  fcrepo_admin is designed for installation on hydra-head 6.0 or higher (requires active-fedora 6.1 or higher).
13
13
  See https://github.com/projecthydra/hydra-head/wiki/Installation-Prerequisites.
14
14
 
15
- === Installation
15
+ == Installation
16
16
 
17
17
  (In the future, we hope to automate some of these tasks with a generator.)
18
18
 
@@ -75,57 +75,61 @@ See https://github.com/projecthydra/hydra-head/wiki/Installation-Prerequisites.
75
75
 
76
76
  include ActiveFedora::Auditable
77
77
 
78
- === Overriding fcrepo_admin behaviors
78
+ == Overriding fcrepo_admin behaviors
79
79
 
80
80
  The following are examples of possible customizations. This list is not necessarily exhaustive.
81
81
 
82
- * Helpers
82
+ === Helpers
83
83
 
84
- Override objects helpers by creating app/helpers/fcrepo_admin/objects_helper.rb with this content:
84
+ Override objects helpers by creating app/helpers/fcrepo_admin/objects_helper.rb with this content:
85
85
 
86
86
  module FcrepoAdmin::ObjectsHelper
87
87
  include FcrepoAdmin::Helpers::ObjectsHelperBehavior
88
- # override and/or add methods here
88
+ # override methods here
89
89
  end
90
90
 
91
- In particular you may want to override #object_title.
91
+ In particular you may want to override #object_title.
92
92
 
93
- The contents of the object context navigation menu can be customized by overriding #object_context_nav_items,
94
- or by copying and modifying the partial fcrepo_admin/objects/context_nav_items.
95
-
96
- Override datastreams helpers by creating app/helpers/fcrepo_admin/datastreams_helper.rb with this content:
93
+ Override datastreams helpers by creating app/helpers/fcrepo_admin/datastreams_helper.rb with this content:
97
94
 
98
95
  module FcrepoAdmin::DatastreamsHelper
99
96
  include FcrepoAdmin::Helpers::DatastreamsHelperBehavior
100
- # override and/or add methods here
97
+ # override methods here
101
98
  end
102
99
 
103
- The contents of the datastream context navigation menu can be customized by overriding #datastream_context_nav_items,
104
- or by copying and modifying the partial fcrepo_admin/datastreams/context_nav_items.
100
+ === Context Navigation Menus
105
101
 
106
- * Controllers
102
+ The contents of the object context navigation menu can be customized by overriding the #object_context_nav_items
103
+ helper method, or by copying and modifying the partial fcrepo_admin/objects/context_nav_items.
107
104
 
108
- To override/extend the objects controller, create app/controllers/fcrepo_admin/objects_controller.rb:
105
+ The contents of the datastream context navigation menu can be customized by overriding the
106
+ #datastream_context_nav_items helper method, or by copying and modifying the partial fcrepo_admin/datastreams/context_nav_items.
109
107
 
110
- module FcrepoAdmin
111
- class ObjectsController < CatalogController
112
- include FcrepoAdmin::Controller::ObjectsControllerBehavior
113
- # add your customizations
114
- end
115
- end
108
+ === Controllers
116
109
 
117
- NOTE: This controller subclasses CatalogController, not ApplicationController.
110
+ To override or extend controller behaviors, please consult Rails engine documentation and guides, such as
111
+ http://edgeguides.rubyonrails.org/engines.html.
118
112
 
119
- To override/extend the datastreams controller, create app/controllers/fcrepo_admin/datastreams_controller.rb:
113
+ IMPORTANT: If you add a non-RESTful action to a controller, you will probably have to add a CanCan action alias
114
+ to your Ability class. For this, you can use Hydra's #custom_permissions callback:
115
+
116
+ class Ability
117
+ include Hydra::Ability
118
+ include Hydra::PolicyAwareAbility
119
+ include FcrepoAdmin::Ability
120
120
 
121
- module FcrepoAdmin
122
- class DatastreamsController < ApplicationController
123
- include FcrepoAdmin::Controller::DatastreamsControllerBehavior
124
- # add your customizations
121
+ def custom_permissions
122
+ alias_action :my_method, :to => :read
125
123
  end
126
- end
127
124
 
128
- === Contributing
125
+ end
126
+
127
+ == Internationalization (i18n)
128
+
129
+ An effort has been made to support i18n on headings, menus, etc. See https://github.com/projecthydra/fcrepo-admin/blob/master/config/locales/fcrepo_admin.en.yml
130
+ for the keys and consult the Rails documentation on how to provide your own translations or alternate text values.
131
+
132
+ == Contributing
129
133
 
130
134
  * Consider first posting to hydra-tech@googlegroups.com with a question or bug report, or submit an issue
131
135
  to the Github issue tracker at https://github.com/projecthydra/fcrepo-admin/issues.
@@ -134,7 +138,7 @@ The following are examples of possible customizations. This list is not necessa
134
138
 
135
139
  Thanks!
136
140
 
137
- === License
141
+ == License
138
142
 
139
143
  See the LICENSE file in the root directory of the project for copyright and license information.
140
144
 
@@ -1,7 +1,54 @@
1
1
  module FcrepoAdmin
2
- # NOTE: This controller subclasses CatalogController, not ApplicationController
3
- class AssociationsController < CatalogController
4
- include FcrepoAdmin::Controller::CatalogControllerBehavior
5
- include FcrepoAdmin::Controller::AssociationsControllerBehavior
2
+ class AssociationsController < ApplicationController
3
+
4
+ layout 'fcrepo_admin/objects'
5
+
6
+ include Hydra::Controller::ControllerBehavior
7
+ include Hydra::PolicyAwareAccessControlsEnforcement
8
+ include FcrepoAdmin::Controller::ControllerBehavior
9
+
10
+ before_filter :load_and_authorize_object
11
+ before_filter :load_association, :only => :show
12
+
13
+ def index
14
+ end
15
+
16
+ def show
17
+ if @association.collection?
18
+ get_collection_from_solr
19
+ else
20
+ target = @object.send("#{@association.name}_id")
21
+ if target
22
+ redirect_to :controller => 'objects', :action => 'show', :id => target, :use_route => 'fcrepo_admin'
23
+ else
24
+ render :text => "Target not found", :status => 404
25
+ end
26
+ end
27
+ end
28
+
29
+ protected
30
+
31
+ def get_collection_from_solr
32
+ @response = solr_response_for_raw_result(get_collection_query_result)
33
+ @documents = solr_documents_for_response(@response)
34
+ end
35
+
36
+ def get_collection_query_result
37
+ args = {raw: true}
38
+ apply_gated_discovery(args, {}) # add args to enforce Hydra permissions and admin policies
39
+ ActiveFedora::SolrService.query(construct_collection_query, args)
40
+ end
41
+
42
+ def construct_collection_query
43
+ # Copied from ActiveFedora::Associations::AssociationCollection#construct_query
44
+ clauses = {@association.options[:property] => @object.internal_uri}
45
+ clauses[:has_model] = @association.class_name.constantize.to_class_uri if @association.class_name && @association.class_name != 'ActiveFedora::Base'
46
+ query = ActiveFedora::SolrService.construct_query_for_rel(clauses)
47
+ end
48
+
49
+ def load_association
50
+ @association = @object.reflections[params[:id].to_sym] # XXX raise exception if nil
51
+ end
52
+
6
53
  end
7
54
  end
@@ -1,6 +1,107 @@
1
+ require 'mime/types'
2
+
1
3
  module FcrepoAdmin
2
4
  class DatastreamsController < ApplicationController
3
- include FcrepoAdmin::Controller::DatastreamsControllerBehavior
5
+
6
+ layout 'fcrepo_admin/datastreams', :except => :index
7
+ layout 'fcrepo_admin/objects', :only => :index
8
+
9
+ include Hydra::Controller::ControllerBehavior
10
+ include Hydra::PolicyAwareAccessControlsEnforcement
11
+ include FcrepoAdmin::Controller::ControllerBehavior
12
+
13
+ before_filter :load_and_authorize_object
14
+ before_filter :load_datastream, :except => :index
15
+
16
+ helper_method :ds_is_current_version?
17
+ helper_method :ds_content_is_text?
18
+ helper_method :ds_content_is_editable?
19
+ helper_method :ds_content_is_uploadable?
20
+
21
+ # TODO Migrate to config initializer
22
+ EXTRA_TEXT_MIME_TYPES = ['application/xml', 'application/rdf+xml', 'application/json']
23
+ MAX_EDITABLE_SIZE = 1024 * 64
24
+
25
+ def index
26
+ end
27
+
28
+ def show
29
+ end
30
+
31
+ def content
32
+ end
33
+
34
+ def history
35
+ end
36
+
37
+ def download
38
+ # XXX Replace with Hydra download behavior?
39
+ mimetypes = MIME::Types[@datastream.mimeType]
40
+ send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}"
41
+ end
42
+
43
+ def edit
44
+ end
45
+
46
+ def upload
47
+ unless ds_content_is_uploadable?
48
+ render :text => "This datstream does not support file content", :status => 403
49
+ end
50
+ end
51
+
52
+ def update
53
+ if params[:file] # file uploaded
54
+ @datastream.content = params[:file].read
55
+ else # content submitted
56
+ @datastream.content = params[:content]
57
+ end
58
+ @object.save
59
+ flash[:notice] = "Datastream content updated." # i18n
60
+ redirect_to fcrepo_admin.object_datastream_url(@object, @datastream.dsid)
61
+ end
62
+
63
+ private
64
+
65
+ def load_datastream
66
+ @datastream = @object.datastreams[params[:id]]
67
+ @datastream = @datastream.asOfDateTime(params[:asOfDateTime]) if params[:asOfDateTime]
68
+ end
69
+
70
+ protected
71
+
72
+ # XXX Use Rubydora::Datastream#current_version? when it becomes available
73
+ # https://github.com/projecthydra/rubydora/pull/25
74
+ def ds_is_current_version?
75
+ @current_version ||= (@datastream.new? || @datastream.dsVersionID == @datastream.versions.first.dsVersionID)
76
+ end
77
+
78
+ def ds_content_is_url?
79
+ @datastream.external? || @datastream.redirect?
80
+ end
81
+
82
+ def ds_content_is_editable?
83
+ !ds_content_is_url? && ds_content_is_text? && ds_editable_content_size_ok?
84
+ end
85
+
86
+ def ds_editable_content_size_ok?
87
+ @datastream.dsSize <= MAX_EDITABLE_SIZE
88
+ end
89
+
90
+ def ds_content_is_uploadable?
91
+ @datastream.managed? || @datastream.inline?
92
+ end
93
+
94
+ private
95
+
96
+ def ds_content_is_text?
97
+ mimetype_is_text(@datastream.mimeType)
98
+ end
99
+
100
+ def mimetype_is_text(mimetype)
101
+ return false if mimetype.blank?
102
+ mimetype.start_with?('text/') || EXTRA_TEXT_MIME_TYPES.include?(mimetype)
103
+ end
104
+
4
105
  end
5
106
  end
6
107
 
@@ -1,6 +1,29 @@
1
1
  module FcrepoAdmin
2
- class ObjectsController < CatalogController
3
- include FcrepoAdmin::Controller::CatalogControllerBehavior
4
- include FcrepoAdmin::Controller::ObjectsControllerBehavior
2
+ class ObjectsController < ApplicationController
3
+
4
+ layout 'fcrepo_admin/objects'
5
+
6
+ include Hydra::Controller::ControllerBehavior
7
+ include Hydra::PolicyAwareAccessControlsEnforcement
8
+ include FcrepoAdmin::Controller::ControllerBehavior
9
+
10
+ before_filter :load_and_authorize_object
11
+
12
+ def show
13
+ end
14
+
15
+ def audit_trail
16
+ if object_is_auditable?
17
+ if params[:download] # TODO use format instead download param
18
+ send_data @object.audit_trail.to_xml, :disposition => 'inline', :type => 'text/xml'
19
+ end
20
+ else
21
+ render :text => I18n.t("fcrepo_admin.object.audit_trail.not_implemented"), :status => 404
22
+ end
23
+ end
24
+
25
+ def permissions
26
+ end
27
+
5
28
  end
6
29
  end
@@ -5,7 +5,7 @@
5
5
  <th scope="col"><%= t("fcrepo_admin.object.associations.header.macro") %></th>
6
6
  <th scope="col"><%= t("fcrepo_admin.object.associations.header.name") %></th>
7
7
  <th scope="col"><%= t("fcrepo_admin.object.associations.header.target") %></th>
8
- <th scope="col"><%= t("fcrepo_admin.object.associations.header.class_name") %></th>
8
+ <!-- <th scope="col"><%= t("fcrepo_admin.object.associations.header.class_name") %></th> -->
9
9
  <th scope="col"><%= t("fcrepo_admin.object.associations.header.property") %></th>
10
10
  </tr>
11
11
  </thead>
@@ -14,8 +14,8 @@
14
14
  <tr>
15
15
  <td><%= association.macro %></td>
16
16
  <td><%= association.name %></td>
17
- <td><%= link_to_target association %></td>
18
- <td><%= association.class_name %></td>
17
+ <td><%= link_to_association_target association %></td>
18
+ <!-- <td><%= association.class_name %></td> -->
19
19
  <td>
20
20
  <%= association.options[:property] %><% if association.options[:inbound] %> (inbound)<% end %>
21
21
  </td>
@@ -1,9 +1,13 @@
1
1
  <h3><%= t("fcrepo_admin.object.associations.title") %>: <%= @association.name %></h3>
2
2
 
3
- <!-- <pre><%= @response %></pre> -->
4
-
5
- <% unless @documents.blank? %>
6
- <%= render_document_index @documents %>
3
+ <% if @response.total > 0 %>
4
+ <%= content_tag :ol, :start => @response.params[:start].to_i + 1 do %>
5
+ <% @documents.each do |doc| %>
6
+ <li>
7
+ <%= link_to doc.id, fcrepo_admin.object_path(doc.id) %>
8
+ </li>
9
+ <% end %>
10
+ <% end %>
7
11
  <% else %>
8
12
  <div class="alert">
9
13
  No associated objects found.
@@ -0,0 +1 @@
1
+ <p class="muted"><%= datastream.class.to_s %></p>
@@ -1,21 +1,38 @@
1
- <li>
2
- <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.summary"), fcrepo_admin.object_datastream_path(object, datastream.dsid) %>
3
- </li>
4
- <% if ds_content_is_text? %>
1
+ <% unless ds_is_current_version? %>
5
2
  <li>
6
- <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.content"), fcrepo_admin.content_object_datastream_path(object, datastream.dsid) %>
3
+ <%= render :partial => 'version', :locals => {:datastream => datastream} %>
4
+ </li>
5
+ <li>
6
+ <%= link_to t("fcrepo_admin.nav.items.current_version"), fcrepo_admin.object_datastream_path(object, datastream.dsid) %>
7
7
  </li>
8
8
  <% end %>
9
9
  <li>
10
- <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.download"), fcrepo_admin.download_object_datastream_path(object, datastream.dsid) %>
10
+ <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.summary"), fcrepo_admin.object_datastream_path(object, datastream.dsid, datastream_params) %>
11
11
  </li>
12
- <% if can_edit_datastream? && ds_content_is_editable? %>
12
+ <% unless datastream.new? %>
13
+ <% if ds_content_is_text? %>
14
+ <li>
15
+ <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.content"), fcrepo_admin.content_object_datastream_path(object, datastream.dsid, datastream_params) %>
16
+ </li>
17
+ <% end %>
13
18
  <li>
14
- <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.edit"), fcrepo_admin.edit_object_datastream_path(object, datastream.dsid) %>
19
+ <%= link_to t("fcrepo_admin.datastream.nav.items.download"), fcrepo_admin.download_object_datastream_path(object, datastream.dsid, datastream_params) %>
15
20
  </li>
16
21
  <% end %>
17
- <% if can_upload_datastream? %>
22
+ <% if ds_is_current_version? %>
23
+ <% if ds_content_is_editable? && can?(:edit, object) %>
24
+ <li>
25
+ <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.edit"), fcrepo_admin.edit_object_datastream_path(object, datastream.dsid) %>
26
+ </li>
27
+ <% end %>
28
+ <% if can?(:upload, object) %>
29
+ <li>
30
+ <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.upload"), fcrepo_admin.upload_object_datastream_path(object, datastream.dsid) %>
31
+ </li>
32
+ <% end %>
33
+ <% end %>
34
+ <% unless datastream.new? %>
18
35
  <li>
19
- <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.upload"), fcrepo_admin.upload_object_datastream_path(object, datastream.dsid) %>
36
+ <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.history"), fcrepo_admin.history_object_datastream_path(object, datastream.dsid) %>
20
37
  </li>
21
38
  <% end %>
@@ -1,33 +1,3 @@
1
1
  <h3><%= t("fcrepo_admin.datastreams.title") %></h3>
2
- <table class="table table-bordered table-condensed">
3
- <thead>
4
- <tr>
5
- <th scope="col"><%= t("fcrepo_admin.datastreams.header.id") %></th>
6
- <th scope="col"><%= t("fcrepo_admin.datastreams.header.label") %></th>
7
- <th scope="col"><%= t("fcrepo_admin.datastreams.header.mimetype") %></th>
8
- <th scope="col"><%= t("fcrepo_admin.datastreams.header.create_date") %></th>
9
- </tr>
10
- </thead>
11
- <tbody>
12
- <% object.datastreams.each do |dsid, ds| %>
13
- <tr>
14
- <td>
15
- <%=
16
- link_to_unless ds.profile.empty?, dsid, fcrepo_admin.object_datastream_path(ds.pid, dsid) do |name|
17
- name
18
- end
19
- %>
20
- </td>
21
- <td><%= ds.profile["dsLabel"] %></td>
22
- <td><%= ds.profile["dsMIME"] %></td>
23
- <td>
24
- <% unless ds.profile.empty? %>
25
- <%= ds.profile["dsCreateDate"] %>
26
- <% else %>
27
- [<%= t("fcrepo_admin.datastreams.not_persisted") %>]
28
- <% end %>
29
- </td>
30
- </tr>
31
- <% end %>
32
- </tbody>
33
- </table>
2
+
3
+ <%= render :partial => 'datastreams_list', :locals => {:object => object, :columns => datastream_index_columns} %>
@@ -0,0 +1,30 @@
1
+ <table class="table table-bordered table-condensed table-striped">
2
+ <thead>
3
+ <tr>
4
+ <th scope="col"><%= t("fcrepo_admin.datastreams.header.id") %></th>
5
+ <% columns.each do |col| %>
6
+ <th scope="col"><%= t("fcrepo_admin.datastream.profile.#{col}") %></th>
7
+ <% end %>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+ <% object.datastreams.each do |dsid, ds| %>
12
+ <tr>
13
+ <td>
14
+ <%= link_to dsid, fcrepo_admin.object_datastream_path(object, dsid) %>
15
+ </td>
16
+ <% unless ds.new? %>
17
+ <% columns.each do |col| %>
18
+ <td>
19
+ <%= format_ds_profile_value ds, col %>
20
+ </td>
21
+ <% end %>
22
+ <% else %>
23
+ <%= content_tag :td, :colspan => columns.size do %>
24
+ <em><%= t("fcrepo_admin.datastream.not_persisted") %></em>
25
+ <% end %>
26
+ <% end %>
27
+ </tr>
28
+ <% end %>
29
+ </tbody>
30
+ </table>
@@ -1,9 +1,16 @@
1
- <h4>Profile</h4>
2
- <table class="table table-condensed table-striped" style="width: auto">
3
- <% datastream.profile.each do |key, value| %>
4
- <tr>
5
- <th scope="row"><%= t("fcrepo_admin.datastream.profile.#{key}") %></th>
6
- <td><%= value.blank? ? " " : value %></td>
7
- </tr>
8
- <% end %>
9
- </table>
1
+ <% unless datastream.new? %>
2
+ <h4><%= t("fcrepo_admin.datastream.profile.title") %></h4>
3
+
4
+ <table class="table table-bordered table-condensed table-striped" style="width: auto">
5
+ <% datastream.profile.each_key do |key| %>
6
+ <tr>
7
+ <th scope="row"><%= t("fcrepo_admin.datastream.profile.#{key}") %></th>
8
+ <td><%= format_ds_profile_value datastream, key %></td>
9
+ </tr>
10
+ <% end %>
11
+ </table>
12
+ <% else %>
13
+ <div class="alert alert-info">
14
+ This datastream has not been persisted to Fedora.
15
+ </div>
16
+ <% end %>
@@ -0,0 +1 @@
1
+ <span class="label label-important"><%= t("fcrepo_admin.datastream.version") %> <%= datastream.profile["dsVersionID"] %></span>
@@ -0,0 +1,25 @@
1
+ <h4>History</h4>
2
+ <table class="table table-condensed table-bordered" style="width: auto">
3
+ <thead>
4
+ <tr>
5
+ <th scope="col"><%= t("fcrepo_admin.datastream.profile.dsVersionID") %></th>
6
+ <% datastream_history_columns.each do |col| %>
7
+ <th scope="col"><%= t("fcrepo_admin.datastream.profile.#{col}") %></th>
8
+ <% end %>
9
+ </tr>
10
+ </thead>
11
+ <tbody>
12
+ <% @datastream.versions.each_with_index do |ds, i| %>
13
+ <tr>
14
+ <td><%=
15
+ link_to_unless i == 0, ds.profile["dsVersionID"], "#{fcrepo_admin.object_datastream_path(@object, ds.dsid)}?asOfDateTime=#{ds.asOfDateTime}" do |name|
16
+ "#{name} (current version)"
17
+ end
18
+ -%>
19
+ </td>
20
+ <% datastream_history_columns.each do |col| %>
21
+ <td><%= ds.profile[col] %></td>
22
+ <% end %>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
@@ -1 +1,3 @@
1
+ <%= render :partial => 'active_fedora', :locals => {:datastream => @datastream} %>
1
2
  <%= render :partial => 'profile', :locals => {:datastream => @datastream} %>
3
+
@@ -0,0 +1,3 @@
1
+ <h3><%= t("fcrepo_admin.datastreams.title") %></h3>
2
+
3
+ <%= render :partial => 'fcrepo_admin/datastreams/datastreams_list', :locals => {:object => object, :columns => object_show_datastream_columns} %>
@@ -1,9 +1,5 @@
1
1
  <h4><%= t("fcrepo_admin.object.permissions.inherited") %></h4>
2
- <% unless admin_policy_enforcement_enabled? %>
3
- <p class="alert">
4
- <%= t("fcrepo_admin.object.apo.enforcement_disabled") %>.
5
- </p>
6
- <% end %>
2
+
7
3
  <% if object_is_governable? %>
8
4
  <div class="alert alert-info">
9
5
  <% if object_is_governed_by %>
@@ -1,5 +1,6 @@
1
1
  <h3><%= t("fcrepo_admin.object.properties.title") %></h3>
2
- <table class="table" style="width: auto">
2
+
3
+ <table class="table table-condensed table-bordered">
3
4
  <% object_properties.each do |key, value| %>
4
5
  <tr>
5
6
  <th scope="row"><%= t("fcrepo_admin.object.properties.keys.#{key}") %>:</th>
@@ -1,3 +1,9 @@
1
- <%= render_document_partial @document, :show %>
2
- <%= render 'properties' %>
1
+ <div class="row">
2
+ <div class="span5">
3
+ <%= render :partial => 'datastreams', :locals => {:object => @object} %>
4
+ </div>
5
+ <div class="span4">
6
+ <%= render 'properties' %>
7
+ </div>
8
+ </div>
3
9
 
@@ -1,10 +1,17 @@
1
1
  <% content_for :main do %>
2
2
  <h1><%= object_title %></h1>
3
- <h3><%= t("fcrepo_admin.datastream.title") %>: <%= @datastream.dsid %></h3>
3
+ <h3>
4
+ <%= t("fcrepo_admin.datastream.title") %>: <%= @datastream.dsid %>
5
+ </h3>
6
+ <% unless ds_is_current_version? %>
7
+ <p>
8
+ <%= render :partial => 'version', :locals => {:datastream => @datastream} %>
9
+ </p>
10
+ <% end %>
4
11
  <%= yield %>
5
12
  <% end %>
6
13
  <% content_for :sidebar do %>
7
14
  <%= render 'fcrepo_admin/objects/context_nav' %>
8
- <%= render 'fcrepo_admin/datastreams/context_nav' %>
15
+ <%= render 'context_nav' %>
9
16
  <% end %>
10
17
  <%= render :template => 'layouts/fcrepo_admin/default' %>
@@ -1,18 +1,12 @@
1
1
  en:
2
2
  fcrepo_admin:
3
3
  object:
4
- tabs:
5
- datastreams: 'Datastreams'
6
- properties: 'Properties'
7
- permissions: 'Permissions'
8
- associations: 'Associations'
9
4
  nav:
10
5
  header: 'Object Admin'
11
6
  items:
12
- summary: 'Basic View'
7
+ summary: 'Summary'
13
8
  audit_trail: 'Audit Trail'
14
9
  permissions: 'Permissions'
15
- properties: 'Properties'
16
10
  datastreams: 'Datastreams'
17
11
  associations: 'Associations'
18
12
  properties:
@@ -70,21 +64,23 @@ en:
70
64
  create_date: 'Create Date'
71
65
  datastream:
72
66
  title: 'Datastream'
67
+ not_persisted: 'Not persisted to Fedora'
68
+ version: 'Version'
73
69
  nav:
74
70
  header: 'Datastream Admin'
75
71
  items:
72
+ current_version: 'Current Version'
76
73
  summary: 'Profile'
77
74
  content: 'View Content'
78
75
  edit: 'Edit Content'
79
76
  upload: 'Upload Content'
80
77
  download: 'Download Content'
81
78
  object: 'Object Admin'
82
- tabs:
83
- content: 'Content'
84
- profile: 'Profile'
79
+ history: 'History'
85
80
  download: 'Download'
86
81
  content_not_text: 'The datastream content is not text'
87
82
  profile:
83
+ title: 'Profile'
88
84
  dsLabel: 'Label'
89
85
  dsMIME: 'MIME Type'
90
86
  dsVersionID: 'Version'
data/config/routes.rb CHANGED
@@ -12,6 +12,7 @@ FcrepoAdmin::Engine.routes.draw do
12
12
  get 'content'
13
13
  get 'upload'
14
14
  get 'download'
15
+ get 'history'
15
16
  end
16
17
  end
17
18
  end
data/lib/fcrepo_admin.rb CHANGED
@@ -14,9 +14,5 @@ module FcrepoAdmin
14
14
  end
15
15
  module Controller
16
16
  autoload :ControllerBehavior, 'fcrepo_admin/controller/controller_behavior'
17
- autoload :ObjectsControllerBehavior, 'fcrepo_admin/controller/objects_controller_behavior'
18
- autoload :DatastreamsControllerBehavior, 'fcrepo_admin/controller/datastreams_controller_behavior'
19
- autoload :AssociationsControllerBehavior, 'fcrepo_admin/controller/associations_controller_behavior'
20
- autoload :CatalogControllerBehavior, 'fcrepo_admin/controller/catalog_controller_behavior'
21
17
  end
22
18
  end
@@ -11,6 +11,7 @@ module FcrepoAdmin
11
11
  alias_action :audit_trail, :to => :read
12
12
  alias_action :permissions, :to => :read
13
13
  alias_action :content, :to => :read
14
+ alias_action :history, :to => :read
14
15
  alias_action :upload, :to => :update
15
16
  end
16
17
 
@@ -6,7 +6,6 @@ module FcrepoAdmin::Controller
6
6
  helper_method :object_is_auditable?
7
7
  helper_method :object_is_governable?
8
8
  helper_method :object_is_governed_by
9
- helper_method :admin_policy_enforcement_enabled?
10
9
  end
11
10
 
12
11
  protected
@@ -17,8 +16,12 @@ module FcrepoAdmin::Controller
17
16
  end
18
17
 
19
18
  def load_object
20
- id = params[:object_id] || params[:id]
21
- @object = ActiveFedora::Base.find(id, :cast => true)
19
+ pid = params[:object_id] || params[:id]
20
+ begin
21
+ @object = ActiveFedora::Base.find(pid, :cast => true)
22
+ rescue ActiveFedora::ObjectNotFoundError
23
+ render :text => "Object not found", :status => 404
24
+ end
22
25
  end
23
26
 
24
27
  def authorize_object
@@ -33,12 +36,6 @@ module FcrepoAdmin::Controller
33
36
  end
34
37
  end
35
38
 
36
- def admin_policy_enforcement_enabled?
37
- # Including Hydra::PolicyAwareAccessControlsEnforcement in ApplicationController
38
- # appears to be the only way that APO access control enforcement can be enabled.
39
- self.class.ancestors.include?(Hydra::PolicyAwareAccessControlsEnforcement)
40
- end
41
-
42
39
  def object_is_governed_by
43
40
  @object_is_governed_by ||= object_is_governable? && @object.send(is_governed_by_association_name)
44
41
  end
@@ -49,18 +46,21 @@ module FcrepoAdmin::Controller
49
46
 
50
47
  def is_governed_by_association_name
51
48
  @object.reflections.each do |name, reflection|
52
- if reflection.macro == :belongs_to && reflection.options[:property] == :is_governed_by # && reflection.class_name == admin_policy_class.to_s
49
+ if reflection.macro == :belongs_to && reflection.options[:property] == :is_governed_by # TODO add policy class
53
50
  return reflection.name
54
51
  end
55
52
  end
56
53
  end
57
54
 
58
- def admin_policy_class
59
- # XXX Ideally we would use Hydra::PolicyAwareAccessControlsEnforcement#policy_class,
60
- # but it's only available if it's been included in the application controller, i.e.,
61
- # if APO access control enforcement is enabled. We want to know the name of the
62
- # relationship regardless of whether policy enforcement is enabled.
63
- Hydra.config[:permissions].fetch(:policy_class, Hydra::AdminPolicy)
55
+ # #solr_response_for_raw_result and #solr_documents_for_response
56
+ # duplicate Blacklight functionality outside of a full Blacklight
57
+ # catalog controller context.
58
+ def solr_response_for_raw_result(solr_result)
59
+ Blacklight::SolrResponse.new(solr_result, {})
60
+ end
61
+
62
+ def solr_documents_for_response(solr_response)
63
+ solr_response.docs.collect { |doc| SolrDocument.new(doc, solr_response) }
64
64
  end
65
65
 
66
66
  end
@@ -1,20 +1,17 @@
1
1
  module FcrepoAdmin::Helpers
2
2
  module AssociationsHelperBehavior
3
3
 
4
- def link_to_target(association)
4
+ def link_to_association_target(association)
5
5
  target = @object.send(association.name)
6
6
  if association.collection?
7
- text = "#{target.size} #{target.size == 1 ? 'object' : 'objects'}"
8
- if target.size > 0
9
- link_to text, fcrepo_admin.object_association_path(@object, association.name)
10
- else
7
+ link_to_unless target.size == 0, "#{association.class_name} (#{target.size})", fcrepo_admin.object_association_path(@object, association.name) do |text|
11
8
  text
12
9
  end
13
10
  else # not a collection
14
11
  if target
15
- link_to target.pid, fcrepo_admin.object_path(target)
12
+ link_to "#{association.class_name} #{target.pid}", fcrepo_admin.object_path(target)
16
13
  else
17
- "[not assigned]"
14
+ "#{association.class_name} (not assigned)"
18
15
  end
19
16
  end
20
17
  end
@@ -10,12 +10,18 @@ module FcrepoAdmin::Helpers
10
10
  render :partial => 'fcrepo_admin/datastreams/context_nav_items', :locals => {:object => @object, :datastream => @datastream}
11
11
  end
12
12
 
13
- def can_edit_datastream?
14
- can? :edit, @object
13
+ # List of ds profile keys for ds index view
14
+ def datastream_index_columns
15
+ ["dsLabel", "dsMIME", "dsSize", "dsCreateDate"]
15
16
  end
16
17
 
17
- def can_upload_datastream?
18
- can? :upload, @object
18
+ # List of ds profile keys for ds history view
19
+ def datastream_history_columns
20
+ ["dsCreateDate"]
21
+ end
22
+
23
+ def datastream_params
24
+ params.has_key?(:asOfDateTime) ? {:asOfDateTime => params[:asOfDateTime]} : {}
19
25
  end
20
26
 
21
27
  end
@@ -13,5 +13,15 @@ module FcrepoAdmin::Helpers
13
13
  render :partial => 'fcrepo_admin/objects/context_nav_items', :locals => {:object => @object}
14
14
  end
15
15
 
16
+ def format_ds_profile_value(ds, key)
17
+ value = ds.profile[key]
18
+ case
19
+ when key == "dsSize" then number_to_human_size(value)
20
+ when key == "dsCreateDate" then value.strftime("%Y-%m-%dT%H:%M:%S.%LZ")
21
+ when key == "dsLocation" && (ds.external? || ds.redirect?) then link_to(value, value)
22
+ else value
23
+ end
24
+ end
25
+
16
26
  end
17
27
  end
@@ -9,6 +9,19 @@ module FcrepoAdmin::Helpers
9
9
  def object_type
10
10
  @object.class.to_s
11
11
  end
12
+
13
+ def object_properties_keys
14
+ [:owner_id, :state, :create_date, :modified_date, :label]
15
+ end
16
+
17
+ def object_properties
18
+ object_properties_keys.inject(Hash.new) { |h, p| h[p] = @object.send(p); h }
19
+ end
20
+
21
+ # List of ds profile keys for for object show view
22
+ def object_show_datastream_columns
23
+ ["dsLabel"]
24
+ end
12
25
 
13
26
  end
14
27
  end
@@ -1,3 +1,3 @@
1
1
  module FcrepoAdmin
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -12,7 +12,7 @@ describe "associations/index.html.erb" do
12
12
  end
13
13
  it "should link to the show view of the association" do
14
14
  visit fcrepo_admin.object_associations_path(object)
15
- page.should have_link("1 object", :href => fcrepo_admin.object_association_path(object, "parts"))
15
+ page.should have_link("Part (1)", :href => fcrepo_admin.object_association_path(object, "parts"))
16
16
  end
17
17
  end
18
18
  context "association is not a collection" do
@@ -22,7 +22,7 @@ describe "associations/index.html.erb" do
22
22
  it "should link to the show view of the target object" do
23
23
  pending "Bug in Capybara?"
24
24
  visit fcrepo_admin.object_associations_path(object)
25
- page.should have_link(collection.pid, :href => fcrepo_admin.object_path(collection))
25
+ page.should have_link("Collection #{collection.pid}", :href => fcrepo_admin.object_path(collection))
26
26
  end
27
27
  end
28
28
  end
@@ -10,10 +10,10 @@ describe "datastreams/show.html.erb" do
10
10
  before { visit fcrepo_admin.object_datastream_path(object, dsid) }
11
11
  after { object.delete }
12
12
  it "should display all attributes of the datastream profile" do
13
- object.datastreams[dsid].profile.each do |key, value|
13
+ profile = object.datastreams[dsid].profile
14
+ profile.each do |key, value|
14
15
  # TODO use paths
15
16
  page.should have_content(I18n.t("fcrepo_admin.datastream.profile.#{key}"))
16
- page.should have_content(value)
17
17
  end
18
18
  end
19
19
  it "should have a link to download the datastream content" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fcrepo_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chandek-Stark
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-05-03 00:00:00.000000000 Z
14
+ date: 2013-05-14 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: hydra-head
@@ -253,19 +253,24 @@ files:
253
253
  - app/views/fcrepo_admin/associations/index.html.erb
254
254
  - app/views/fcrepo_admin/associations/show.html.erb
255
255
  - app/views/fcrepo_admin/catalog/_document.html.erb
256
+ - app/views/fcrepo_admin/datastreams/_active_fedora.html.erb
256
257
  - app/views/fcrepo_admin/datastreams/_content.html.erb
257
258
  - app/views/fcrepo_admin/datastreams/_context_nav.html.erb
258
259
  - app/views/fcrepo_admin/datastreams/_context_nav_items.html.erb
259
260
  - app/views/fcrepo_admin/datastreams/_datastreams.html.erb
261
+ - app/views/fcrepo_admin/datastreams/_datastreams_list.html.erb
260
262
  - app/views/fcrepo_admin/datastreams/_profile.html.erb
263
+ - app/views/fcrepo_admin/datastreams/_version.html.erb
261
264
  - app/views/fcrepo_admin/datastreams/content.html.erb
262
265
  - app/views/fcrepo_admin/datastreams/edit.html.erb
266
+ - app/views/fcrepo_admin/datastreams/history.html.erb
263
267
  - app/views/fcrepo_admin/datastreams/index.html.erb
264
268
  - app/views/fcrepo_admin/datastreams/show.html.erb
265
269
  - app/views/fcrepo_admin/datastreams/upload.html.erb
266
270
  - app/views/fcrepo_admin/objects/_context_nav.html.erb
267
271
  - app/views/fcrepo_admin/objects/_context_nav_datastreams.html.erb
268
272
  - app/views/fcrepo_admin/objects/_context_nav_items.html.erb
273
+ - app/views/fcrepo_admin/objects/_datastreams.html.erb
269
274
  - app/views/fcrepo_admin/objects/_direct_permissions.html.erb
270
275
  - app/views/fcrepo_admin/objects/_inherited_permissions.html.erb
271
276
  - app/views/fcrepo_admin/objects/_permissions_list.html.erb
@@ -285,11 +290,7 @@ files:
285
290
  - lib/assets/.gitkeep
286
291
  - lib/fcrepo_admin.rb
287
292
  - lib/fcrepo_admin/ability.rb
288
- - lib/fcrepo_admin/controller/associations_controller_behavior.rb
289
- - lib/fcrepo_admin/controller/catalog_controller_behavior.rb
290
293
  - lib/fcrepo_admin/controller/controller_behavior.rb
291
- - lib/fcrepo_admin/controller/datastreams_controller_behavior.rb
292
- - lib/fcrepo_admin/controller/objects_controller_behavior.rb
293
294
  - lib/fcrepo_admin/engine.rb
294
295
  - lib/fcrepo_admin/helpers/associations_helper_behavior.rb
295
296
  - lib/fcrepo_admin/helpers/blacklight_helper_behavior.rb
@@ -1,49 +0,0 @@
1
- module FcrepoAdmin::Controller
2
- module AssociationsControllerBehavior
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- layout 'fcrepo_admin/objects'
7
-
8
- include FcrepoAdmin::Controller::ControllerBehavior
9
-
10
- before_filter :load_and_authorize_object
11
- before_filter :load_association, :only => :show
12
- end
13
-
14
- def index
15
- end
16
-
17
- def show
18
- if @association.collection?
19
- self.solr_search_params_logic += [:association_filter]
20
- @response, @documents = get_search_results({:qt => 'standard'})
21
- else
22
- target = @object.send("#{@association.name}_id")
23
- if target
24
- redirect_to :controller => 'objects', :action => 'show', :id => target, :use_route => 'fcrepo_admin'
25
- else
26
- render :text => "Target not found", :status => 404
27
- end
28
- end
29
- end
30
-
31
- def association_filter(solr_params, user_params)
32
- solr_params[:q] = construct_query
33
- end
34
-
35
- protected
36
-
37
- # Copied from ActiveFedora::Associations::AssociationCollection
38
- def construct_query
39
- clauses = {@association.options[:property] => @object.internal_uri}
40
- clauses[:has_model] = @association.class_name.constantize.to_class_uri if @association.class_name && @association.class_name != 'ActiveFedora::Base'
41
- ActiveFedora::SolrService.construct_query_for_rel(clauses)
42
- end
43
-
44
- def load_association
45
- @association = @object.reflections[params[:id].to_sym] # XXX raise exception if nil
46
- end
47
-
48
- end
49
- end
@@ -1,9 +0,0 @@
1
- module FcrepoAdmin::Controller
2
- module CatalogControllerBehavior
3
-
4
- def search_action_url
5
- url_for(:controller => '/catalog', :action => 'index', :only_path => true)
6
- end
7
-
8
- end
9
- end
@@ -1,73 +0,0 @@
1
- require 'mime/types'
2
-
3
- module FcrepoAdmin::Controller
4
- module DatastreamsControllerBehavior
5
- extend ActiveSupport::Concern
6
-
7
- included do
8
- layout 'fcrepo_admin/datastreams', :except => :index
9
- layout 'fcrepo_admin/objects', :only => :index
10
-
11
- include FcrepoAdmin::Controller::ControllerBehavior
12
-
13
- before_filter :load_and_authorize_object
14
- before_filter :load_datastream, :except => :index
15
-
16
- helper_method :ds_content_is_text?
17
- helper_method :ds_content_is_editable?
18
- end
19
-
20
- # Additional types of content that should be displayed inline
21
- TEXT_MIME_TYPES = ['application/xml', 'application/rdf+xml', 'application/json']
22
- MAX_INLINE_SIZE = 1024 * 64
23
-
24
- def index
25
- end
26
-
27
- def show
28
- end
29
-
30
- def content
31
- end
32
-
33
- def download
34
- mimetypes = MIME::Types[@datastream.mimeType]
35
- send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}"
36
- end
37
-
38
- def edit
39
- end
40
-
41
- def upload
42
- end
43
-
44
- def update
45
- if params[:file] # file uploaded
46
- @datastream.content = params[:file].read
47
- else # content submitted
48
- @datastream.content = params[:content]
49
- end
50
- @object.save
51
- flash[:notice] = "Datastream content updated." # i18n
52
- redirect_to fcrepo_admin.object_datastream_url(@object, @datastream.dsid)
53
- end
54
-
55
- private
56
-
57
- def load_datastream
58
- @datastream = @object.datastreams[params[:id]]
59
- end
60
-
61
- protected
62
-
63
- def ds_content_is_text?
64
- @datastream.mimeType.start_with?('text/') || TEXT_MIME_TYPES.include?(@datastream.mimeType)
65
- end
66
-
67
- def ds_content_is_editable?
68
- ds_content_is_text? && (@datastream.dsSize <= MAX_INLINE_SIZE)
69
- end
70
-
71
- end
72
- end
73
-
@@ -1,42 +0,0 @@
1
- module FcrepoAdmin::Controller
2
- module ObjectsControllerBehavior
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- layout 'fcrepo_admin/objects'
7
-
8
- include FcrepoAdmin::Controller::ControllerBehavior
9
-
10
- helper_method :object_properties
11
-
12
- before_filter :load_and_authorize_object, :except => :show
13
- end
14
-
15
- PROPERTIES = [:owner_id, :state, :create_date, :modified_date, :label]
16
-
17
- def show
18
- @response, @document = get_solr_response_for_doc_id(params[:id])
19
- @object = ActiveFedora::SolrService.reify_solr_results([@document], :load_from_solr => true).first
20
- end
21
-
22
- def audit_trail
23
- if object_is_auditable?
24
- if params[:download]
25
- send_data @object.audit_trail.to_xml, :disposition => 'inline', :type => 'text/xml'
26
- end
27
- else
28
- render :text => I18n.t("fcrepo_admin.object.audit_trail.not_implemented"), :status => 404
29
- end
30
- end
31
-
32
- def permissions
33
- end
34
-
35
- protected
36
-
37
- def object_properties
38
- @object_properties ||= PROPERTIES.inject(Hash.new) { |h, p| h[p] = @object.send(p); h }
39
- end
40
-
41
- end
42
- end