fcrepo_admin 0.3.0 → 0.3.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 (37) hide show
  1. data/Gemfile +1 -0
  2. data/README.rdoc +9 -29
  3. data/app/controllers/fcrepo_admin/datastreams_controller.rb +34 -11
  4. data/app/controllers/fcrepo_admin/objects_controller.rb +51 -10
  5. data/app/helpers/fcrepo_admin/objects_helper.rb +9 -0
  6. data/app/views/fcrepo_admin/datastreams/_content.html.erb +4 -5
  7. data/app/views/fcrepo_admin/datastreams/_datastream_nav.html.erb +18 -0
  8. data/app/views/fcrepo_admin/datastreams/_datastreams.html +2 -0
  9. data/app/views/fcrepo_admin/datastreams/edit.html.erb +0 -4
  10. data/app/views/fcrepo_admin/datastreams/show.html.erb +0 -13
  11. data/app/views/fcrepo_admin/objects/_object_nav.html.erb +5 -0
  12. data/app/views/fcrepo_admin/objects/_object_nav_items.html.erb +9 -0
  13. data/app/views/fcrepo_admin/{audit_trail/index.html.erb → objects/audit_trail.html.erb} +1 -3
  14. data/app/views/fcrepo_admin/objects/show.html.erb +7 -11
  15. data/app/views/layouts/fcrepo_admin/datastreams.html.erb +9 -0
  16. data/app/views/layouts/fcrepo_admin/default.html.erb +63 -0
  17. data/app/views/layouts/fcrepo_admin/objects.html.erb +8 -0
  18. data/config/locales/fcrepo_admin.en.yml +16 -3
  19. data/config/routes.rb +2 -6
  20. data/lib/fcrepo_admin.rb +1 -0
  21. data/lib/fcrepo_admin/blacklight_helper_behavior.rb +11 -0
  22. data/lib/fcrepo_admin/controller_behavior.rb +5 -5
  23. data/lib/fcrepo_admin/version.rb +1 -1
  24. data/spec/controllers/objects_controller_spec.rb +12 -0
  25. data/spec/features/datastreams/show.html.erb_spec.rb +1 -1
  26. data/spec/features/{audit_trail/index.html.erb_spec.rb → objects/audit_trail.html.erb_spec.rb} +3 -3
  27. data/spec/features/objects/show.html.erb_spec.rb +1 -1
  28. data/spec/internal/app/helpers/blacklight_helper.rb +4 -0
  29. data/spec/internal/public/403.html +26 -0
  30. metadata +18 -16
  31. data/app/controllers/fcrepo_admin/audit_trail_controller.rb +0 -17
  32. data/app/views/fcrepo_admin/catalog/_datastreams.html.erb +0 -19
  33. data/app/views/fcrepo_admin/catalog/_show.html.erb +0 -2
  34. data/lib/assets/stylesheets/fcrepo_admin/fcrepo_admin.css +0 -4
  35. data/spec/controllers/audit_trail_controller_spec.rb +0 -20
  36. data/spec/features/catalog/show.html.erb_spec.rb +0 -21
  37. data/spec/internal/app/views/catalog/_show_default.html.erb +0 -12
data/Gemfile CHANGED
@@ -3,4 +3,5 @@ source 'https://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'active-fedora', github: 'projecthydra/active_fedora'
6
+ gem 'hydra-head', github: 'projecthydra/hydra-head'
6
7
  gem 'devise'
data/README.rdoc CHANGED
@@ -4,7 +4,8 @@ A Rails engine providing an administrative interface to a Fedora Commons reposit
4
4
 
5
5
  === Status
6
6
 
7
- This project is at an early stage of development. It should be considered experimental and not ready for production deployment.
7
+ This project should be considered *experimental* and not ready for production deployment.
8
+ Versions earlier than 1.0 may change API and/or UI without notice or regard for backward compatibility.
8
9
 
9
10
  === Requirements
10
11
 
@@ -37,42 +38,21 @@ See https://github.com/projecthydra/hydra-head/wiki/Installation-Prerequisites.
37
38
  You may replace <code>'/admin'</code> with any mount point (except perhaps <code>'/catalog'</code>),
38
39
  including <code>'/'</code>. All routes include <code>objects</code> as a subpath.
39
40
 
40
- * Add abilities to your Ability class
41
-
42
- In app/models/ability.rb add this line after the Hydra abilities:
43
-
44
- include FcrepoAdmin::DatastreamAbility
45
-
46
- * Extend the SolrDocument model
47
-
48
- In app/models/solr_document.rb add this line:
49
-
50
- use_extension FcrepoAdmin::SolrDocumentExtension
51
-
52
- (This may only be necessary if customizing the catalog show page as indicated below.)
53
-
54
41
  * Add Javascript
55
42
 
56
43
  In app/assets/javascripts/application.js add this line:
57
44
 
58
45
  //= require bootstrap-tab
59
46
 
60
- * Add CSS
61
-
62
- In app/assets/stylesheets/application.css add this line:
63
-
64
- //= require fcrepo_admin/fcrepo_admin
65
-
66
- * Customize catalog show page (optional)
67
-
68
- If you would like to add Fedora object information to the catalog show page,
69
- copy the partial <code>app/views/catalog/_show_default.html.erb</code> from the Blacklight
70
- gem to your application, then add to the bottom of the file:
47
+ * Customize catalog search results (optional)
71
48
 
72
- <%= render :partial => 'fcrepo_admin/catalog/show', :locals => {:document => document} %>
49
+ If you would like items from the catalog search results list to the object admin view
50
+ instead of the catalog show view, create app/helpers/blacklight_helper.rb with this content:
73
51
 
74
- Use Blacklight's config options in CatalogController to control the basic content on the show page
75
- (HTML title, page title, and list of the fields/values at the top of the page).
52
+ module BlacklightHelper
53
+ include Blacklight::BlacklightHelperBehavior # Default Blacklight behaviors
54
+ include FcrepoAdmin::BlacklightHelperBehavior # fcrepo_admin overrides
55
+ end
76
56
 
77
57
  === License
78
58
 
@@ -3,26 +3,32 @@ require 'mime/types'
3
3
  module FcrepoAdmin
4
4
  class DatastreamsController < ApplicationController
5
5
 
6
- include FcrepoAdmin::ControllerBehavior
6
+ # include FcrepoAdmin::ControllerBehavior
7
7
 
8
+ layout 'fcrepo_admin/datastreams'
9
+
10
+ # Additional types of content that should be displayed inline
8
11
  TEXT_MIME_TYPES = ['application/xml', 'application/rdf+xml', 'application/json']
9
12
 
10
- before_filter :load_and_authz_object, :only => :index
11
- before_filter :load_and_authz_datastream, :except => [:index, :download]
12
- before_filter :load_datastream, :only => :download
13
+ # before_filter :load_and_authorize_object, :only => :index
14
+ before_filter :load_and_authorize_datastream # , :except => :index
15
+ # before_filter :load_datastream, :only => :download
13
16
  before_filter :inline_filter, :only => [:show, :edit]
14
17
 
15
- def index
16
- end
18
+ # def index
19
+ # end
17
20
 
18
21
  def show
22
+ if params[:download]
23
+ mimetypes = MIME::Types[@datastream.mimeType]
24
+ send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}"
25
+ end
19
26
  end
20
27
 
21
- def download
22
- authorize! :read, @datastream
23
- mimetypes = MIME::Types[@datastream.mimeType]
24
- send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}"
25
- end
28
+ # def download
29
+ # mimetypes = MIME::Types[@datastream.mimeType]
30
+ # send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}"
31
+ # end
26
32
 
27
33
  def edit
28
34
  end
@@ -38,6 +44,23 @@ module FcrepoAdmin
38
44
  redirect_to fcrepo_admin.object_datastream_url(@object, @datastream.dsid)
39
45
  end
40
46
 
47
+ private
48
+
49
+ def load_and_authorize_datastream
50
+ load_datastream
51
+ authorize_datastream
52
+ end
53
+
54
+ def load_datastream
55
+ @object = ActiveFedora::Base.find(params[:object_id], :cast => true)
56
+ @datastream = @object.datastreams[params[:id]]
57
+ end
58
+
59
+ def authorize_datastream
60
+ # Datastream permissions are solely based on object permissions
61
+ authorize! params[:action].to_sym, @object
62
+ end
63
+
41
64
  protected
42
65
 
43
66
  def inline_filter
@@ -1,19 +1,46 @@
1
1
  module FcrepoAdmin
2
2
  class ObjectsController < ApplicationController
3
3
 
4
- include FcrepoAdmin::ControllerBehavior
4
+ layout 'fcrepo_admin/objects'
5
5
 
6
6
  PROPERTIES = [:owner_id, :state, :create_date, :modified_date, :label]
7
7
 
8
8
  helper_method :apo_enforcement_enabled?
9
9
  helper_method :object_properties
10
+ helper_method :admin_policy_object?
11
+ helper_method :object_type
12
+ helper_method :has_permissions?
10
13
 
11
- before_filter { |c| c.load_and_authz_object :id }
12
- before_filter :load_apo_info # depends on load_and_authz_object
14
+ before_filter :load_and_authorize_object
15
+ before_filter :load_apo_info, :only => :show # depends on load_and_authz_object
13
16
 
14
17
  def show
15
18
  end
16
19
 
20
+ def audit_trail
21
+ # XXX Update when new version of ActiveFedora released
22
+ @audit_trail = @object.respond_to?(:audit_trail) ? @object.audit_trail : @object.inner_object.audit_trail
23
+ if params[:download]
24
+ send_data @audit_trail.to_xml, :disposition => 'inline', :type => 'text/xml'
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def load_and_authorize_object
31
+ load_object
32
+ authorize_object
33
+ end
34
+
35
+ def load_object
36
+ @object = ActiveFedora::Base.find(params[:id], :cast => true)
37
+ end
38
+
39
+ def authorize_object
40
+ action = params[:action] == 'audit_trail' ? :read : params[:action].to_sym
41
+ authorize! action, @object
42
+ end
43
+
17
44
  protected
18
45
 
19
46
  def apo_enforcement_enabled?
@@ -28,23 +55,37 @@ module FcrepoAdmin
28
55
  properties
29
56
  end
30
57
 
58
+ def object_type
59
+ @object.class.to_s
60
+ end
61
+
31
62
  def load_apo_info
32
63
  @apo_relationship_name = nil
33
64
  @apo = nil
34
- # XXX Ideally we would use Hydra::PolicyAwareAccessControlsEnforcement#policy_class,
35
- # but it's only available if it's been included in the application controller, i.e.,
36
- # if APO access control enforcement is enabled. We want to know the name of the
37
- # relationship regardless of whether policy enforcement is enabled.
38
- apo_class = Hydra.config[:permissions].fetch(:policy_class, Hydra::AdminPolicy)
39
65
  @object.reflections.each_value do |reflection|
40
66
  if reflection.options[:property] == :is_governed_by \
41
- && reflection.macro == :belongs_to #&& reflection.class_name == apo_class.to_s
67
+ && reflection.macro == :belongs_to
42
68
  @apo_relationship_name = reflection.name
43
69
  @apo = @object.send(@apo_relationship_name)
44
70
  break
45
71
  end
46
72
  end
47
-
73
+ end
74
+
75
+ def has_permissions?
76
+ @object.is_a?(Hydra::ModelMixins::RightsMetadata)
77
+ end
78
+
79
+ def admin_policy_object?
80
+ @object.is_a?(apo_class)
81
+ end
82
+
83
+ def apo_class
84
+ # XXX Ideally we would use Hydra::PolicyAwareAccessControlsEnforcement#policy_class,
85
+ # but it's only available if it's been included in the application controller, i.e.,
86
+ # if APO access control enforcement is enabled. We want to know the name of the
87
+ # relationship regardless of whether policy enforcement is enabled.
88
+ Hydra.config[:permissions].fetch(:policy_class, Hydra::AdminPolicy)
48
89
  end
49
90
 
50
91
  end
@@ -0,0 +1,9 @@
1
+ module FcrepoAdmin
2
+ module ObjectsHelper
3
+
4
+ def object_title
5
+ "#{@object.class.to_s} #{@object.pid}"
6
+ end
7
+
8
+ end
9
+ end
@@ -1,4 +1,3 @@
1
- <div id="fcrepo-admin-dscontent">
2
1
  <% if inline %>
3
2
  <pre class="prettyprint pre-scrollable"><%= datastream.content %></pre>
4
3
  <% else %>
@@ -6,7 +5,7 @@
6
5
  <%= t("fcrepo_admin.datastream.content_not_text") %>.
7
6
  </p>
8
7
  <% end %>
9
- <p>
10
- <%= link_to t("fcrepo_admin.datastream.download"), fcrepo_admin.download_object_datastream_path(datastream.pid, datastream.dsid), :class => "btn btn-primary" %>
11
- </p>
12
- </div>
8
+ <p>
9
+ <%= link_to t("fcrepo_admin.datastream.download"), "#{fcrepo_admin.object_datastream_path(datastream.pid, datastream.dsid)}?download=true", :class => "btn btn-primary" %>
10
+ </p>
11
+
@@ -0,0 +1,18 @@
1
+ <div class="well">
2
+ <ul class="nav nav-list">
3
+ <li class="nav-header">
4
+ <%= t("fcrepo_admin.datastream.nav.header") %>
5
+ </li>
6
+ <li>
7
+ <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.summary"), fcrepo_admin.object_datastream_path(datastream.pid, datastream.dsid) %>
8
+ </li>
9
+ <li>
10
+ <%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.edit"), fcrepo_admin.edit_object_datastream_path(datastream.pid, datastream.dsid) %>
11
+ </li>
12
+ <li>
13
+ <%= link_to t("fcrepo_admin.datastream.nav.items.download"), "#{fcrepo_admin.object_datastream_path(datastream.pid, datastream.dsid)}?download=true" %>
14
+ </li>
15
+ <li class="divider"></li>
16
+ <%= render :partial => 'fcrepo_admin/objects/object_nav_items', :locals => {:object => object} %>
17
+ </ul>
18
+ </div>
@@ -4,6 +4,7 @@
4
4
  <th scope="col"><%= t("fcrepo_admin.datastreams.header.id") %></th>
5
5
  <th scope="col"><%= t("fcrepo_admin.datastreams.header.label") %></th>
6
6
  <th scope="col"><%= t("fcrepo_admin.datastreams.header.mimetype") %></th>
7
+ <th scope="col"><%= t("fcrepo_admin.datastreams.header.create_date") %></th>
7
8
  </tr>
8
9
  </thead>
9
10
  <tbody>
@@ -12,6 +13,7 @@
12
13
  <td><%= link_to dsid, fcrepo_admin.object_datastream_path(ds.pid, dsid) %></td>
13
14
  <td><%= ds.profile["dsLabel"] %></td>
14
15
  <td><%= ds.profile["dsMIME"] %></td>
16
+ <td><%= ds.profile["dsCreateDate"] %></td>
15
17
  </tr>
16
18
  <% end %>
17
19
  </tbody>
@@ -1,7 +1,3 @@
1
- <h1><%= @datastream.pid %></h1>
2
-
3
- <h3><%= t("fcrepo_admin.datastream.title") %>: <%= @datastream.dsid %></h3>
4
-
5
1
  <%= form_tag fcrepo_admin.object_datastream_path(@datastream.pid, @datastream.dsid), :method => :put, :multipart => true do %>
6
2
  <div>
7
3
  <%= label_tag "file", t("fcrepo_admin.datastream.edit.file") %>
@@ -1,15 +1,3 @@
1
- <h1><%= @datastream.pid %></h1>
2
-
3
- <ul class="pull-right nav nav-pills">
4
- <% if can? :edit, @datastream %>
5
- <li>
6
- <%= link_to content_tag(:i, "", :class => "icon-pencil"), fcrepo_admin.edit_object_datastream_path(@datastream.pid, @datastream.dsid) %>
7
- </li>
8
- <% end %>
9
- </ul>
10
-
11
- <h3><%= t("fcrepo_admin.datastream.title") %>: <%= @datastream.dsid %></h3>
12
-
13
1
  <div class="tabbable">
14
2
  <ul class="nav nav-tabs">
15
3
  <li class="active"><a href="#tab1" data-toggle="tab"><%= t("fcrepo_admin.datastream.tabs.content") %></a></li>
@@ -24,4 +12,3 @@
24
12
  </div>
25
13
  </div>
26
14
  </div>
27
-
@@ -0,0 +1,5 @@
1
+ <div class="well">
2
+ <ul class="nav nav-list">
3
+ <%= render :partial => 'fcrepo_admin/objects/object_nav_items', :locals => {:object => object} %>
4
+ </ul>
5
+ </div>
@@ -0,0 +1,9 @@
1
+ <li class="nav-header">
2
+ <%= t("fcrepo_admin.object.nav.header") %>
3
+ </li>
4
+ <li>
5
+ <%= link_to_unless_current t("fcrepo_admin.object.nav.items.summary"), fcrepo_admin.object_path(object) %>
6
+ </li>
7
+ <li>
8
+ <%= link_to_unless_current t("fcrepo_admin.object.nav.items.audit_trail"), fcrepo_admin.audit_trail_object_path(object) %>
9
+ </li>
@@ -1,9 +1,7 @@
1
- <h1><%= @object.pid %></h1>
2
-
3
1
  <h3><%= t("fcrepo_admin.audit_trail.title") %></h3>
4
2
 
5
3
  <p>
6
- <%= link_to t("fcrepo_admin.audit_trail.download"), "#{fcrepo_admin.object_audit_trail_index_path(@object)}?download=true", :class => "btn btn-primary" %>
4
+ <%= link_to t("fcrepo_admin.audit_trail.download"), "#{fcrepo_admin.audit_trail_object_path(@object)}?download=true", :class => "btn btn-primary" %>
7
5
  </p>
8
6
 
9
7
  <table class="table table-bordered table-condensed table-striped">
@@ -1,9 +1,3 @@
1
- <h1><%= @object.pid %></h1>
2
-
3
- <p>
4
- Object Type: <%= @object.class.to_s %>
5
- </p>
6
-
7
1
  <div class="tabbable">
8
2
  <ul class="nav nav-tabs">
9
3
  <li class="active"><a href="#tab-datastreams" data-toggle="tab"><%= t("fcrepo_admin.object.tabs.datastreams") %></a></li>
@@ -18,12 +12,13 @@
18
12
  <%= render :partial => 'properties', :locals => {:properties => object_properties} %>
19
13
  </div>
20
14
  <div class="tab-pane" id="tab-permissions">
15
+ <% if has_permissions? %>
21
16
  <h4>Direct Permissions</h4>
22
17
  <%= render :partial => 'permissions', :locals => {:permissions => @object.permissions} %>
23
18
  <h4>Inherited Permissions</h4>
24
19
  <% unless apo_enforcement_enabled? %>
25
20
  <p class="alert">
26
- <%= t("fcrepo_admin.object.apo.enforcement_disabled") %>
21
+ <%= t("fcrepo_admin.object.apo.enforcement_disabled") %>.
27
22
  </p>
28
23
  <% end %>
29
24
  <% if @apo_relationship_name %>
@@ -40,11 +35,12 @@
40
35
  <% end %>
41
36
  <% else %>
42
37
  <p class="alert alert-info">
43
- <%= t("fcrepo_admin.object.apo.relationship_undefined") %>
38
+ <%= t("fcrepo_admin.object.apo.relationship_undefined") %>: <%= object_type %>.
44
39
  </p>
45
40
  <% end %>
46
- </div>
41
+ <% else %>
42
+ <%= t("fcrepo_admin.object.permissions.not_supported") %>: <%= object_type %>.
43
+ <% end %>
44
+ </div> <!-- /tab-permissions -->
47
45
  </div>
48
46
  </div>
49
-
50
- <%= render :partial => 'more_info', :locals => {:pid => @object.pid} %>
@@ -0,0 +1,9 @@
1
+ <% content_for :main do %>
2
+ <h1><%= object_title %></h1>
3
+ <h3><%= t("fcrepo_admin.datastream.title") %>: <%= @datastream.dsid %></h3>
4
+ <%= yield %>
5
+ <% end %>
6
+ <% content_for :sidebar do %>
7
+ <%= render :partial => 'fcrepo_admin/datastreams/datastream_nav', :locals => {:datastream => @datastream, :object => @object} %>
8
+ <% end %>
9
+ <%= render :template => 'layouts/fcrepo_admin/default' %>
@@ -0,0 +1,63 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="no-js">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
6
+
7
+ <!-- Mobile viewport optimization h5bp.com/ad -->
8
+ <meta name="HandheldFriendly" content="True">
9
+ <meta name="viewport" content="width=device-width,initial-scale=1.0">
10
+
11
+ <!-- Mobile IE allows us to activate ClearType technology for smoothing fonts for easy reading -->
12
+ <!--[if IEMobile]>
13
+ <meta http-equiv="cleartype" content="on">
14
+ <![endif]-->
15
+
16
+ <title><%= h(@page_title || application_name) %></title>
17
+ <link href="<%= opensearch_catalog_path(:format => 'xml', :only_path => false) %>" title="<%= application_name%>" type="application/opensearchdescription+xml" rel="search"/>
18
+ <%= favicon_link_tag asset_path('favicon.ico') %>
19
+ <%= stylesheet_link_tag "application" %>
20
+ <%= javascript_include_tag "application" %>
21
+ <%= csrf_meta_tags %>
22
+ <%= raw(render_head_content) %>
23
+
24
+ <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
25
+ <!--[if lt IE 9]>
26
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
27
+ <![endif]-->
28
+
29
+ </head>
30
+ <% onload_text = "$('input#q').focus();" if params[:q].to_s.empty? and params[:f].to_s.empty? and params[:id].nil? %>
31
+ <body onload="<%= onload_text %>" class="<%= render_body_class %>">
32
+ <%= render :partial => 'shared/header_navbar' %>
33
+
34
+ <div id="ajax-modal" class="modal hide fade" tabindex="-1"></div>
35
+
36
+ <div id="main-container" class="container">
37
+ <!-- Top bar -->
38
+ <div id="search-found" class="row hidden-phone">
39
+ <%= topbar_items.join('').html_safe %>
40
+ </div>
41
+ <!-- /Top bar -->
42
+ <div class="row">
43
+ <div class="span12">
44
+ <div id="main-flashes">
45
+ <%= render :partial=>'/flash_msg' %>
46
+ </div>
47
+ </div>
48
+ </div>
49
+
50
+ <div class="row">
51
+ <div class="span9">
52
+ <%= yield :main %>
53
+ </div>
54
+ <div class="span3">
55
+ <%= yield :sidebar %>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ <!-- /container -->
60
+
61
+ <%= render :partial => 'shared/footer' %>
62
+ </body>
63
+ </html>
@@ -0,0 +1,8 @@
1
+ <% content_for :main do %>
2
+ <h1><%= object_title %></h1>
3
+ <%= yield %>
4
+ <% end %>
5
+ <% content_for :sidebar do %>
6
+ <%= render :partial => 'fcrepo_admin/objects/object_nav', :locals => {:object => @object} %>
7
+ <% end %>
8
+ <%= render :template => 'layouts/fcrepo_admin/default' %>
@@ -1,11 +1,15 @@
1
1
  en:
2
2
  fcrepo_admin:
3
3
  object:
4
- more_info: 'More Information'
5
4
  tabs:
6
5
  datastreams: 'Datastreams'
7
6
  properties: 'Properties'
8
7
  permissions: 'Permissions'
8
+ nav:
9
+ header: 'Object Admin'
10
+ items:
11
+ summary: 'Object Summary'
12
+ audit_trail: 'Audit Trail'
9
13
  properties:
10
14
  title: 'Properties'
11
15
  keys:
@@ -16,6 +20,7 @@ en:
16
20
  label: 'Label'
17
21
  permissions:
18
22
  no_permissions: 'No permissions.'
23
+ not_supported: 'This object type does not support Hydra permissions'
19
24
  header:
20
25
  type: 'Type'
21
26
  name: 'Name'
@@ -23,8 +28,8 @@ en:
23
28
  apo:
24
29
  governed_by: 'Governed By'
25
30
  not_assigned: 'Not Assigned'
26
- enforcement_disabled: 'Admin policy access control enforcement is disabled.'
27
- relationship_undefined: 'This object type does not define an admin policy relationship.'
31
+ enforcement_disabled: 'Admin policy access control enforcement is disabled'
32
+ relationship_undefined: 'This object type does not define an admin policy relationship'
28
33
  audit_trail:
29
34
  title: 'Audit Trail'
30
35
  download: 'Download'
@@ -42,8 +47,16 @@ en:
42
47
  id: 'Datastream ID'
43
48
  label: 'Label'
44
49
  mimetype: 'MIME Type'
50
+ create_date: 'Create Date'
45
51
  datastream:
46
52
  title: 'Datastream'
53
+ nav:
54
+ header: 'Datastream Admin'
55
+ items:
56
+ summary: 'Datastream Summary'
57
+ edit: 'Edit Content'
58
+ download: 'Download Content'
59
+ object: 'Object Admin'
47
60
  tabs:
48
61
  content: 'Content'
49
62
  profile: 'Profile'
data/config/routes.rb CHANGED
@@ -2,12 +2,8 @@ FcrepoAdmin::Engine.routes.draw do
2
2
 
3
3
  scope :module => "fcrepo_admin" do
4
4
  resources :objects, :only => :show do
5
- resources :datastreams, :only => [:index, :show, :edit, :update] do
6
- member do
7
- get 'download'
8
- end
9
- end
10
- resources :audit_trail, :only => :index
5
+ get 'audit_trail', :on => :member
6
+ resources :datastreams, :only => [:show, :edit, :update]
11
7
  end
12
8
  end
13
9
 
data/lib/fcrepo_admin.rb CHANGED
@@ -6,4 +6,5 @@ module FcrepoAdmin
6
6
  autoload :SolrDocumentExtension, 'fcrepo_admin/solr_document_extension'
7
7
  autoload :ControllerBehavior, 'fcrepo_admin/controller_behavior'
8
8
  autoload :DatastreamAbility, 'fcrepo_admin/datastream_ability'
9
+ autoload :BlacklightHelperBehavior, 'fcrepo_admin/blacklight_helper_behavior'
9
10
  end
@@ -0,0 +1,11 @@
1
+ module FcrepoAdmin
2
+ module BlacklightHelperBehavior
3
+
4
+ def link_to_document(doc, opts={:label=>nil, :counter => nil, :results_view => true})
5
+ opts[:label] ||= blacklight_config.index.show_link.to_sym
6
+ label = render_document_index_label doc, opts
7
+ link_to label, fcrepo_admin.object_path(doc.id), { :'data-counter' => opts[:counter] }.merge(opts.reject { |k,v| [:label, :counter, :results_view].include? k })
8
+ end
9
+
10
+ end
11
+ end
@@ -1,13 +1,13 @@
1
1
  module FcrepoAdmin
2
2
  module ControllerBehavior
3
3
 
4
- def load_and_authz_object(param = :object_id)
5
- load_object param
4
+ def load_and_authz_object
5
+ load_object
6
6
  authorize_object
7
7
  end
8
8
 
9
- def load_object(param = :object_id)
10
- @object = ActiveFedora::Base.find(params[param], :cast => true)
9
+ def load_object
10
+ @object = ActiveFedora::Base.find(params[:id], :cast => true)
11
11
  end
12
12
 
13
13
  def authorize_object
@@ -20,7 +20,7 @@ module FcrepoAdmin
20
20
  end
21
21
 
22
22
  def load_datastream
23
- load_object unless @object
23
+ @object ||= ActiveFedora::Base.find(params[:object_id], :cast => true)
24
24
  @datastream = @object.datastreams[params[:id]]
25
25
  end
26
26
 
@@ -1,3 +1,3 @@
1
1
  module FcrepoAdmin
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -7,4 +7,16 @@ describe FcrepoAdmin::ObjectsController do
7
7
  after { object.delete }
8
8
  it { should render_template(:show) }
9
9
  end
10
+ context "#audit_trail" do
11
+ let(:object) { FactoryGirl.create(:content_model) }
12
+ after { object.delete }
13
+ subject { get :audit_trail, :id => object, :use_route => 'fcrepo_admin' }
14
+ it { should render_template(:audit_trail) }
15
+ end
16
+ context "#audit_trail?download=true" do
17
+ subject { get :audit_trail, :id => object, :download => 'true', :use_route => 'fcrepo_admin' }
18
+ let(:object) { FactoryGirl.create(:content_model) }
19
+ after { object.delete }
20
+ its(:response_code) { should eq(200) }
21
+ end
10
22
  end
@@ -17,7 +17,7 @@ describe "datastreams/show.html.erb" do
17
17
  end
18
18
  end
19
19
  it "should have a link to download the datastream content" do
20
- page.should have_link(I18n.t("fcrepo_admin.datastream.download"), :href => fcrepo_admin.download_object_datastream_path(object, dsid))
20
+ page.should have_link(I18n.t("fcrepo_admin.datastream.download"), :href => "#{fcrepo_admin.object_datastream_path(object, dsid)}?download=true")
21
21
  end
22
22
  context "user can edit" do
23
23
  let(:user) { FactoryGirl.create(:user) }
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "audit_trail/index.html.erb" do
3
+ describe "audit_trail.html.erb" do
4
4
  let(:object) { FactoryGirl.create(:content_model) }
5
5
  after { object.delete }
6
6
  it "should display the audit trail" do
7
- visit fcrepo_admin.object_audit_trail_index_path(object)
7
+ visit fcrepo_admin.audit_trail_object_path(object)
8
8
  page.should have_content(object.pid)
9
- page.should have_link(I18n.t("fcrepo_admin.audit_trail.download"), :href => "#{fcrepo_admin.object_audit_trail_index_path(object)}?download=true")
9
+ page.should have_link(I18n.t("fcrepo_admin.audit_trail.download"), :href => "#{fcrepo_admin.audit_trail_object_path(object)}?download=true")
10
10
  end
11
11
  end
@@ -20,7 +20,7 @@ describe "objects/show.html.erb" do
20
20
  end
21
21
  it "should link to its audit trail" do
22
22
  visit fcrepo_admin.object_path(object)
23
- page.should have_link(I18n.t("fcrepo_admin.audit_trail.title"), :href => fcrepo_admin.object_audit_trail_index_path(object))
23
+ page.should have_link(I18n.t("fcrepo_admin.audit_trail.title"), :href => fcrepo_admin.audit_trail_object_path(object))
24
24
  end
25
25
  it "should display the object's permissions"
26
26
  end
@@ -0,0 +1,4 @@
1
+ module BlacklightHelper
2
+ include Blacklight::BlacklightHelperBehavior
3
+ include FcrepoAdmin::BlacklightHelperBehavior
4
+ end
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The action you wanted to perform was forbidden (403)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/403.html -->
21
+ <div class="dialog">
22
+ <h1>The action you wanted to perform was forbidden.</h1>
23
+ <p>Maybe you tried to perform an action you didn't have permissions for.</p>
24
+ </div>
25
+ </body>
26
+ </html>
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.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-04-16 00:00:00.000000000 Z
15
+ date: 2013-04-18 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: hydra-head
@@ -256,33 +256,37 @@ files:
256
256
  - LICENSE
257
257
  - README.rdoc
258
258
  - Rakefile
259
- - app/controllers/fcrepo_admin/audit_trail_controller.rb
260
259
  - app/controllers/fcrepo_admin/datastreams_controller.rb
261
260
  - app/controllers/fcrepo_admin/objects_controller.rb
261
+ - app/helpers/fcrepo_admin/objects_helper.rb
262
262
  - app/mailers/.gitkeep
263
263
  - app/models/.gitkeep
264
- - app/views/fcrepo_admin/audit_trail/index.html.erb
265
- - app/views/fcrepo_admin/catalog/_datastreams.html.erb
266
- - app/views/fcrepo_admin/catalog/_show.html.erb
267
264
  - app/views/fcrepo_admin/datastreams/_content.html.erb
265
+ - app/views/fcrepo_admin/datastreams/_datastream_nav.html.erb
268
266
  - app/views/fcrepo_admin/datastreams/_datastreams.html
269
267
  - app/views/fcrepo_admin/datastreams/_profile.html.erb
270
268
  - app/views/fcrepo_admin/datastreams/edit.html.erb
271
269
  - app/views/fcrepo_admin/datastreams/index.html.erb
272
270
  - app/views/fcrepo_admin/datastreams/show.html.erb
273
271
  - app/views/fcrepo_admin/objects/_more_info.html.erb
272
+ - app/views/fcrepo_admin/objects/_object_nav.html.erb
273
+ - app/views/fcrepo_admin/objects/_object_nav_items.html.erb
274
274
  - app/views/fcrepo_admin/objects/_permissions.html.erb
275
275
  - app/views/fcrepo_admin/objects/_permissions_header.html.erb
276
276
  - app/views/fcrepo_admin/objects/_permissions_row.html.erb
277
277
  - app/views/fcrepo_admin/objects/_properties.html.erb
278
+ - app/views/fcrepo_admin/objects/audit_trail.html.erb
278
279
  - app/views/fcrepo_admin/objects/show.html.erb
280
+ - app/views/layouts/fcrepo_admin/datastreams.html.erb
281
+ - app/views/layouts/fcrepo_admin/default.html.erb
282
+ - app/views/layouts/fcrepo_admin/objects.html.erb
279
283
  - config/locales/fcrepo_admin.en.yml
280
284
  - config/routes.rb
281
285
  - doc/README_FOR_APP
282
286
  - fcrepo_admin.gemspec
283
287
  - lib/assets/.gitkeep
284
- - lib/assets/stylesheets/fcrepo_admin/fcrepo_admin.css
285
288
  - lib/fcrepo_admin.rb
289
+ - lib/fcrepo_admin/blacklight_helper_behavior.rb
286
290
  - lib/fcrepo_admin/controller_behavior.rb
287
291
  - lib/fcrepo_admin/datastream_ability.rb
288
292
  - lib/fcrepo_admin/engine.rb
@@ -290,15 +294,13 @@ files:
290
294
  - lib/fcrepo_admin/version.rb
291
295
  - lib/tasks/.gitkeep
292
296
  - lib/tasks/fcrepo_admin.rake
293
- - spec/controllers/audit_trail_controller_spec.rb
294
297
  - spec/controllers/datastreams_controller_spec.rb
295
298
  - spec/controllers/objects_controller_spec.rb
296
299
  - spec/factories/fcrepo_admin_factories.rb
297
300
  - spec/factories/user_factories.rb
298
- - spec/features/audit_trail/index.html.erb_spec.rb
299
- - spec/features/catalog/show.html.erb_spec.rb
300
301
  - spec/features/datastreams/edit.html.erb_spec.rb
301
302
  - spec/features/datastreams/show.html.erb_spec.rb
303
+ - spec/features/objects/audit_trail.html.erb_spec.rb
302
304
  - spec/features/objects/show.html.erb_spec.rb
303
305
  - spec/fixtures/auditable.foxml.xml
304
306
  - spec/internal/README.rdoc
@@ -309,6 +311,7 @@ files:
309
311
  - spec/internal/app/controllers/application_controller.rb
310
312
  - spec/internal/app/controllers/catalog_controller.rb
311
313
  - spec/internal/app/helpers/application_helper.rb
314
+ - spec/internal/app/helpers/blacklight_helper.rb
312
315
  - spec/internal/app/mailers/.gitkeep
313
316
  - spec/internal/app/models/.gitkeep
314
317
  - spec/internal/app/models/ability.rb
@@ -316,7 +319,6 @@ files:
316
319
  - spec/internal/app/models/content_model.rb
317
320
  - spec/internal/app/models/solr_document.rb
318
321
  - spec/internal/app/models/user.rb
319
- - spec/internal/app/views/catalog/_show_default.html.erb
320
322
  - spec/internal/app/views/layouts/application.html.erb
321
323
  - spec/internal/config.ru
322
324
  - spec/internal/config/application.rb
@@ -344,6 +346,7 @@ files:
344
346
  - spec/internal/db/schema.rb
345
347
  - spec/internal/lib/assets/.gitkeep
346
348
  - spec/internal/log/.gitkeep
349
+ - spec/internal/public/403.html
347
350
  - spec/internal/public/404.html
348
351
  - spec/internal/public/422.html
349
352
  - spec/internal/public/500.html
@@ -372,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
372
375
  version: '0'
373
376
  segments:
374
377
  - 0
375
- hash: -4159393718138306915
378
+ hash: 1033224864064252852
376
379
  requirements: []
377
380
  rubyforge_project:
378
381
  rubygems_version: 1.8.25
@@ -380,15 +383,13 @@ signing_key:
380
383
  specification_version: 3
381
384
  summary: Hydra-based Fedora Commons repository admin tool.
382
385
  test_files:
383
- - spec/controllers/audit_trail_controller_spec.rb
384
386
  - spec/controllers/datastreams_controller_spec.rb
385
387
  - spec/controllers/objects_controller_spec.rb
386
388
  - spec/factories/fcrepo_admin_factories.rb
387
389
  - spec/factories/user_factories.rb
388
- - spec/features/audit_trail/index.html.erb_spec.rb
389
- - spec/features/catalog/show.html.erb_spec.rb
390
390
  - spec/features/datastreams/edit.html.erb_spec.rb
391
391
  - spec/features/datastreams/show.html.erb_spec.rb
392
+ - spec/features/objects/audit_trail.html.erb_spec.rb
392
393
  - spec/features/objects/show.html.erb_spec.rb
393
394
  - spec/fixtures/auditable.foxml.xml
394
395
  - spec/internal/README.rdoc
@@ -399,6 +400,7 @@ test_files:
399
400
  - spec/internal/app/controllers/application_controller.rb
400
401
  - spec/internal/app/controllers/catalog_controller.rb
401
402
  - spec/internal/app/helpers/application_helper.rb
403
+ - spec/internal/app/helpers/blacklight_helper.rb
402
404
  - spec/internal/app/mailers/.gitkeep
403
405
  - spec/internal/app/models/.gitkeep
404
406
  - spec/internal/app/models/ability.rb
@@ -406,7 +408,6 @@ test_files:
406
408
  - spec/internal/app/models/content_model.rb
407
409
  - spec/internal/app/models/solr_document.rb
408
410
  - spec/internal/app/models/user.rb
409
- - spec/internal/app/views/catalog/_show_default.html.erb
410
411
  - spec/internal/app/views/layouts/application.html.erb
411
412
  - spec/internal/config.ru
412
413
  - spec/internal/config/application.rb
@@ -434,6 +435,7 @@ test_files:
434
435
  - spec/internal/db/schema.rb
435
436
  - spec/internal/lib/assets/.gitkeep
436
437
  - spec/internal/log/.gitkeep
438
+ - spec/internal/public/403.html
437
439
  - spec/internal/public/404.html
438
440
  - spec/internal/public/422.html
439
441
  - spec/internal/public/500.html
@@ -1,17 +0,0 @@
1
- module FcrepoAdmin
2
- class AuditTrailController < ApplicationController
3
-
4
- include FcrepoAdmin::ControllerBehavior
5
-
6
- before_filter :load_and_authz_object
7
-
8
- def index
9
- # XXX Update when new version of ActiveFedora released
10
- @audit_trail = @object.respond_to?(:audit_trail) ? @object.audit_trail : @object.inner_object.audit_trail
11
- if params[:download]
12
- send_data @audit_trail.to_xml, :disposition => 'inline', :type => 'text/xml'
13
- end
14
- end
15
-
16
- end
17
- end
@@ -1,19 +0,0 @@
1
- <h3><%= t("fcrepo_admin.datastream.title").pluralize %></h3>
2
- <table class="table table-bordered table-condensed">
3
- <thead>
4
- <tr>
5
- <th scope="col"><%= t("fcrepo_admin.datastream.id") %></th>
6
- <th scope="col"><%= t("fcrepo_admin.datastream.label") %></th>
7
- <th scope="col"><%= t("fcrepo_admin.datastream.mimetype") %></th>
8
- </tr>
9
- </thead>
10
- <tbody>
11
- <% datastreams.reject { |dsid, dsProfile| dsProfile.empty? }.each do |dsid, dsProfile| %>
12
- <tr>
13
- <td><%= link_to dsid, fcrepo_admin.object_datastream_path(pid, dsid) %></td>
14
- <td><%= dsProfile["dsLabel"] %></td>
15
- <td><%= dsProfile["dsMIME"] %></td>
16
- </tr>
17
- <% end %>
18
- </tbody>
19
- </table>
@@ -1,2 +0,0 @@
1
- <%= render :partial => 'fcrepo_admin/catalog/datastreams', :locals => {:datastreams => document.datastreams, :pid => document.id} %>
2
- <%= render :partial => 'fcrepo_admin/objects/more_info', :locals => {:pid => document.id} %>
@@ -1,4 +0,0 @@
1
- #fcrepo-admin-dsprofile {
2
- /* datastream profile table */
3
- width: 40em;
4
- }
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe FcrepoAdmin::AuditTrailController do
4
- context "#index" do
5
- let(:object) { FactoryGirl.create(:content_model) }
6
- after { object.delete }
7
- it "should render the index template" do
8
- get :index, :object_id => object, :use_route => 'fcrepo_admin'
9
- response.should render_template(:index)
10
- end
11
- end
12
- context "#index?download=true" do
13
- context "object does not respond to audit_trail" do
14
- subject { get :index, :object_id => object, :download => 'true', :use_route => 'fcrepo_admin' }
15
- let(:object) { FactoryGirl.create(:content_model) }
16
- after { object.delete }
17
- its(:response_code) { should eq(200) }
18
- end
19
- end
20
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "catalog/show.html.erb" do
4
- after { object.delete }
5
- context "basic object" do
6
- let(:object) { FactoryGirl.create(:content_model) }
7
- it "should link to all datastreams" do
8
- visit catalog_path(object)
9
- object.datastreams.reject { |dsid, ds| ds.profile.empty? }.each_key do |dsid|
10
- page.should have_link(dsid, :href => fcrepo_admin.object_datastream_path(object, dsid))
11
- end
12
- end
13
- it "should link to its audit trail" do
14
- visit catalog_path(object)
15
- page.should have_link(I18n.t("fcrepo_admin.audit_trail.title"))
16
- end
17
- end
18
- context "object has admin policy" do
19
- it "should link to the APO"
20
- end
21
- end
@@ -1,12 +0,0 @@
1
- <%# default partial to display solr document fields in catalog show view -%>
2
- <dl class="dl-horizontal dl-invert">
3
- <% document_show_fields.each do |solr_fname, field| -%>
4
- <% if should_render_show_field? document, field %>
5
- <dt class="blacklight-<%= solr_fname.parameterize %>"><%= render_document_show_field_label :field => solr_fname %></dt>
6
- <dd class="blacklight-<%= solr_fname.parameterize %>"><%= render_document_show_field_value :document => document, :field => solr_fname %></dd>
7
- <% end -%>
8
- <% end -%>
9
- </dl>
10
- <%# end blacklight default -%>
11
-
12
- <%= render :partial => 'fcrepo_admin/catalog/show', :locals => {:document => document} %>