fcrepo_admin 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.rdoc +6 -0
- data/README.rdoc +3 -3
- data/app/controllers/fcrepo_admin/associations_controller.rb +16 -8
- data/app/controllers/fcrepo_admin/datastreams_controller.rb +0 -2
- data/app/controllers/fcrepo_admin/objects_controller.rb +8 -2
- data/app/views/fcrepo_admin/associations/_document_header.html.erb +12 -0
- data/app/views/fcrepo_admin/associations/show.html.erb +10 -6
- data/app/views/fcrepo_admin/objects/_inherited_permissions.html.erb +1 -1
- data/app/views/fcrepo_admin/objects/permissions.html.erb +1 -1
- data/app/views/fcrepo_admin/objects/show.html.erb +3 -0
- data/lib/fcrepo_admin.rb +3 -47
- data/lib/fcrepo_admin/configurable.rb +55 -0
- data/lib/fcrepo_admin/controller/controller_behavior.rb +1 -23
- data/lib/fcrepo_admin/decorators/active_fedora/base_decorator.rb +1 -3
- data/lib/fcrepo_admin/helpers/associations_helper_behavior.rb +4 -0
- data/lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb +1 -1
- data/lib/fcrepo_admin/helpers/objects_helper_behavior.rb +27 -2
- data/lib/fcrepo_admin/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d96f1bb3976444ea4f8397a4e929415d07637a93
|
4
|
+
data.tar.gz: 2a297f927e6d1d723502f857bd4e2fe6947574fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d00acee3472c6f98978af43063abc5d7c47c4dcebbe68cb8ce9327bd32a04a8daf9739a8eee8ddbc0d6178cbdc3b8816283a47e34af514002af8bdee7250cb18
|
7
|
+
data.tar.gz: 80d93b9748fc1021c2128b2076765b5e8640f107ff7ece56b2fa1bb51e555f9be664ac6e32938c0e55340ec36c70918a3891032f659849d6866d8374df46e67e
|
data/HISTORY.rdoc
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
==== 0.5.1 (2013-05-21)
|
2
|
+
|
3
|
+
* Association show view paginated (Fixes #18).
|
4
|
+
* Association show view uses blacklight document list rendering.
|
5
|
+
* Object show view loads Solr document for object and incorporates Blacklight document show fields.
|
6
|
+
|
1
7
|
=== 0.5.0 (2013-05-17)
|
2
8
|
|
3
9
|
* Feature: Configurable settings.
|
data/README.rdoc
CHANGED
@@ -4,8 +4,8 @@ A Rails engine providing an administrative interface to a Fedora Commons reposit
|
|
4
4
|
|
5
5
|
=== Status
|
6
6
|
|
7
|
-
This project should be considered *experimental
|
8
|
-
|
7
|
+
This project should be considered *experimental*. Versions earlier than 1.0 may change API and/or UI without notice
|
8
|
+
or regard for backward compatibility.
|
9
9
|
|
10
10
|
=== Requirements
|
11
11
|
|
@@ -90,7 +90,7 @@ You should start with this content:
|
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
Refer to the default configuration settings at https://github.com/projecthydra/fcrepo-admin/blob/master/lib/fcrepo_admin.rb.
|
93
|
+
Refer to the default configuration settings at https://github.com/projecthydra/fcrepo-admin/blob/master/lib/fcrepo_admin/configurable.rb.
|
94
94
|
|
95
95
|
All configuration options are set by module methods prefixed by FcrepoAdmin, for example:
|
96
96
|
|
@@ -3,8 +3,6 @@ module FcrepoAdmin
|
|
3
3
|
|
4
4
|
layout 'fcrepo_admin/objects'
|
5
5
|
|
6
|
-
include Hydra::Controller::ControllerBehavior
|
7
|
-
include Hydra::PolicyAwareAccessControlsEnforcement
|
8
6
|
include FcrepoAdmin::Controller::ControllerBehavior
|
9
7
|
|
10
8
|
before_filter :load_and_authorize_object
|
@@ -14,9 +12,12 @@ module FcrepoAdmin
|
|
14
12
|
end
|
15
13
|
|
16
14
|
def show
|
15
|
+
render(:text => "Association not found", :status => 404) if @association.nil?
|
17
16
|
if @association.collection?
|
18
17
|
get_collection_from_solr
|
19
|
-
else
|
18
|
+
else
|
19
|
+
# This shouldn't normally happen b/c UI links directly to target object view in this case
|
20
|
+
# but we'll handle it gracefully anyway.
|
20
21
|
target = @object.send("#{@association.name}_id")
|
21
22
|
if target
|
22
23
|
redirect_to :controller => 'objects', :action => 'show', :id => target, :use_route => 'fcrepo_admin'
|
@@ -34,20 +35,27 @@ module FcrepoAdmin
|
|
34
35
|
end
|
35
36
|
|
36
37
|
def get_collection_query_result
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
ActiveFedora::SolrService.query(construct_collection_query, collection_query_args)
|
39
|
+
end
|
40
|
+
|
41
|
+
def collection_query_args
|
42
|
+
page = params[:page] ||= 1
|
43
|
+
rows = FcrepoAdmin.associated_objects_per_page
|
44
|
+
start = (page.to_i - 1) * rows
|
45
|
+
args = {raw: true, start: start, rows: rows}
|
46
|
+
apply_gated_discovery(args, nil) # add args to enforce Hydra access controls
|
47
|
+
args
|
40
48
|
end
|
41
49
|
|
42
50
|
def construct_collection_query
|
43
51
|
# Copied from ActiveFedora::Associations::AssociationCollection#construct_query
|
44
52
|
clauses = {@association.options[:property] => @object.internal_uri}
|
45
53
|
clauses[:has_model] = @association.class_name.constantize.to_class_uri if @association.class_name && @association.class_name != 'ActiveFedora::Base'
|
46
|
-
|
54
|
+
ActiveFedora::SolrService.construct_query_for_rel(clauses)
|
47
55
|
end
|
48
56
|
|
49
57
|
def load_association
|
50
|
-
@association = @object.reflections[params[:id].to_sym]
|
58
|
+
@association = @object.reflections[params[:id].to_sym]
|
51
59
|
end
|
52
60
|
|
53
61
|
end
|
@@ -6,8 +6,6 @@ module FcrepoAdmin
|
|
6
6
|
layout 'fcrepo_admin/datastreams', :except => :index
|
7
7
|
layout 'fcrepo_admin/objects', :only => :index
|
8
8
|
|
9
|
-
include Hydra::Controller::ControllerBehavior
|
10
|
-
include Hydra::PolicyAwareAccessControlsEnforcement
|
11
9
|
include FcrepoAdmin::Controller::ControllerBehavior
|
12
10
|
|
13
11
|
before_filter :load_and_authorize_object
|
@@ -3,11 +3,10 @@ module FcrepoAdmin
|
|
3
3
|
|
4
4
|
layout 'fcrepo_admin/objects'
|
5
5
|
|
6
|
-
include Hydra::Controller::ControllerBehavior
|
7
|
-
include Hydra::PolicyAwareAccessControlsEnforcement
|
8
6
|
include FcrepoAdmin::Controller::ControllerBehavior
|
9
7
|
|
10
8
|
before_filter :load_and_authorize_object
|
9
|
+
before_filter :load_solr_document, :only => :show
|
11
10
|
|
12
11
|
def show
|
13
12
|
end
|
@@ -25,5 +24,12 @@ module FcrepoAdmin
|
|
25
24
|
def permissions
|
26
25
|
end
|
27
26
|
|
27
|
+
protected
|
28
|
+
|
29
|
+
def load_solr_document
|
30
|
+
query = ActiveFedora::SolrService.construct_query_for_pids([@object.pid])
|
31
|
+
@document = SolrDocument.new(ActiveFedora::SolrService.query(query).first, nil)
|
32
|
+
end
|
33
|
+
|
28
34
|
end
|
29
35
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
<% # header bar for doc items in index view -%>
|
3
|
+
<div class="documentHeader clearfix">
|
4
|
+
|
5
|
+
<% # main title container for doc partial view -%>
|
6
|
+
<h5 class="index_title"><%= t('blacklight.search.documents.counter', :counter => (document_counter + 1 + @response.params[:start].to_i)) %><%= link_to_document document, :label=>document_show_link_field(document), :counter => (document_counter + 1 + @response.params[:start].to_i) %></h5>
|
7
|
+
|
8
|
+
|
9
|
+
<% # bookmark functions for items/docs -%>
|
10
|
+
<%= render_index_doc_actions document, :wrapping_class => "documentFunctions span2" %>
|
11
|
+
</div>
|
12
|
+
|
@@ -1,12 +1,16 @@
|
|
1
1
|
<h3><%= t("fcrepo_admin.object.associations.title") %>: <%= @association.name %></h3>
|
2
2
|
|
3
3
|
<% if @response.total > 0 %>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
<% if @response.total > associated_objects_per_page %>
|
5
|
+
<div class="pagination">
|
6
|
+
<%= render_pagination_info @response %>
|
7
|
+
</div>
|
8
|
+
<% end %>
|
9
|
+
<%= render :partial => 'catalog/document_list', :locals => {:documents => @documents} %>
|
10
|
+
<% if @response.total > associated_objects_per_page %>
|
11
|
+
<div class="pagination">
|
12
|
+
<%= paginate_rsolr_response @response, :layout => 'blacklight' %>
|
13
|
+
</div>
|
10
14
|
<% end %>
|
11
15
|
<% else %>
|
12
16
|
<div class="alert">
|
data/lib/fcrepo_admin.rb
CHANGED
@@ -4,54 +4,8 @@ require 'hydra/head'
|
|
4
4
|
|
5
5
|
module FcrepoAdmin
|
6
6
|
|
7
|
-
#
|
8
|
-
# FcrepoAdmin configuration settings
|
9
|
-
#
|
10
|
-
mattr_accessor :read_only
|
11
|
-
self.read_only = false
|
12
|
-
|
13
|
-
# MIME types representing text content that do not have "text" media type.
|
14
|
-
mattr_accessor :extra_text_mime_types
|
15
|
-
self.extra_text_mime_types = ['application/xml', 'application/rdf+xml', 'application/json']
|
16
|
-
|
17
|
-
# Datastream profile keys for values to display on datastream index view
|
18
|
-
mattr_accessor :datastream_index_columns
|
19
|
-
self.datastream_index_columns = ["dsLabel", "dsMIME", "dsSize", "dsCreateDate"]
|
20
|
-
|
21
|
-
# Datastream profile keys for values to display on datastream history view
|
22
|
-
mattr_accessor :datastream_history_columns
|
23
|
-
self.datastream_history_columns = ["dsCreateDate"]
|
24
|
-
|
25
|
-
# Datastream context navigation items
|
26
|
-
mattr_accessor :datastream_nav_items
|
27
|
-
self.datastream_nav_items = [:dsid, :version, :current_version, :summary, :content, :download, :edit, :upload, :history]
|
28
|
-
|
29
|
-
mattr_accessor :datastream_show_profile_keys
|
30
|
-
self.datastream_show_profile_keys = ["dsLabel", "dsMIME", "dsVersionID", "dsCreateDate", "dsState",
|
31
|
-
"dsFormatURI", "dsControlGroup", "dsSize", "dsVersionable",
|
32
|
-
"dsInfoType", "dsLocation", "dsLocationType", "dsChecksumType",
|
33
|
-
"dsChecksum"]
|
34
|
-
|
35
|
-
# Sanity check on amount of text data to make editable via web form
|
36
|
-
mattr_accessor :max_editable_datastream_size
|
37
|
-
self.max_editable_datastream_size = 1024 * 64
|
38
|
-
|
39
|
-
# Object context navigation items
|
40
|
-
mattr_accessor :object_nav_items
|
41
|
-
self.object_nav_items = [:pid, :summary, :datastreams, :permissions, :associations, :audit_trail]
|
42
|
-
|
43
|
-
# Datastream profile values to display on object show view
|
44
|
-
mattr_accessor :object_show_datastream_columns
|
45
|
-
self.object_show_datastream_columns = ["dsLabel"]
|
46
|
-
|
47
|
-
# Methods on ActiveFedora::Base objects that represent Fcrepo object properties
|
48
|
-
mattr_accessor :object_properties
|
49
|
-
self.object_properties = [:label, :state, :create_date, :modified_date, :owner_id]
|
50
|
-
|
51
|
-
#
|
52
|
-
# Autoloading
|
53
|
-
#
|
54
7
|
autoload :Ability, 'fcrepo_admin/ability'
|
8
|
+
autoload :Configurable, 'fcrepo_admin/configurable'
|
55
9
|
|
56
10
|
module Helpers
|
57
11
|
autoload :BlacklightHelperBehavior, 'fcrepo_admin/helpers/blacklight_helper_behavior'
|
@@ -65,4 +19,6 @@ module FcrepoAdmin
|
|
65
19
|
autoload :ControllerBehavior, 'fcrepo_admin/controller/controller_behavior'
|
66
20
|
end
|
67
21
|
|
22
|
+
include FcrepoAdmin::Configurable
|
23
|
+
|
68
24
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module FcrepoAdmin::Configurable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
#
|
6
|
+
# FcrepoAdmin configuration settings
|
7
|
+
#
|
8
|
+
mattr_accessor :read_only
|
9
|
+
self.read_only = false
|
10
|
+
|
11
|
+
# MIME types representing text content that do not have "text" media type.
|
12
|
+
mattr_accessor :extra_text_mime_types
|
13
|
+
self.extra_text_mime_types = ['application/xml', 'application/rdf+xml', 'application/json']
|
14
|
+
|
15
|
+
# Datastream profile keys for values to display on datastream index view
|
16
|
+
mattr_accessor :datastream_index_columns
|
17
|
+
self.datastream_index_columns = ["dsLabel", "dsMIME", "dsSize", "dsCreateDate"]
|
18
|
+
|
19
|
+
# Datastream profile keys for values to display on datastream history view
|
20
|
+
mattr_accessor :datastream_history_columns
|
21
|
+
self.datastream_history_columns = ["dsCreateDate"]
|
22
|
+
|
23
|
+
# Datastream context navigation items
|
24
|
+
mattr_accessor :datastream_nav_items
|
25
|
+
self.datastream_nav_items = [:dsid, :version, :current_version, :summary, :content, :download, :edit, :upload, :history]
|
26
|
+
|
27
|
+
# Datastream profile keys to display on datastream show page
|
28
|
+
mattr_accessor :datastream_show_profile_keys
|
29
|
+
self.datastream_show_profile_keys = ["dsLabel", "dsMIME", "dsVersionID", "dsCreateDate", "dsState",
|
30
|
+
"dsFormatURI", "dsControlGroup", "dsSize", "dsVersionable",
|
31
|
+
"dsInfoType", "dsLocation", "dsLocationType", "dsChecksumType",
|
32
|
+
"dsChecksum"]
|
33
|
+
|
34
|
+
# Sanity check on amount of text data to make editable via web form
|
35
|
+
mattr_accessor :max_editable_datastream_size
|
36
|
+
self.max_editable_datastream_size = 1024 * 64
|
37
|
+
|
38
|
+
# Object context navigation items
|
39
|
+
mattr_accessor :object_nav_items
|
40
|
+
self.object_nav_items = [:pid, :summary, :datastreams, :permissions, :associations, :audit_trail, :bookmark]
|
41
|
+
|
42
|
+
# Datastream profile values to display on object show view
|
43
|
+
mattr_accessor :object_show_datastream_columns
|
44
|
+
self.object_show_datastream_columns = ["dsLabel"]
|
45
|
+
|
46
|
+
# Methods on ActiveFedora::Base objects that represent Fcrepo object properties
|
47
|
+
mattr_accessor :object_properties
|
48
|
+
self.object_properties = [:label, :state, :create_date, :modified_date, :owner_id]
|
49
|
+
|
50
|
+
# Number of objects to display per page on object associations show view
|
51
|
+
mattr_accessor :associated_objects_per_page
|
52
|
+
self.associated_objects_per_page = 10
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -3,8 +3,6 @@ module FcrepoAdmin::Controller
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
included do
|
6
|
-
helper_method :object_is_auditable?
|
7
|
-
helper_method :object_is_governable?
|
8
6
|
helper_method :object_is_governed_by
|
9
7
|
end
|
10
8
|
|
@@ -28,28 +26,8 @@ module FcrepoAdmin::Controller
|
|
28
26
|
authorize! params[:action].to_sym, @object
|
29
27
|
end
|
30
28
|
|
31
|
-
def object_is_auditable?
|
32
|
-
begin
|
33
|
-
@object && @object.is_a?(ActiveFedora::Auditable)
|
34
|
-
rescue
|
35
|
-
false
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
29
|
def object_is_governed_by
|
40
|
-
@object_is_governed_by ||=
|
41
|
-
end
|
42
|
-
|
43
|
-
def object_is_governable?
|
44
|
-
!is_governed_by_association_name.nil?
|
45
|
-
end
|
46
|
-
|
47
|
-
def is_governed_by_association_name
|
48
|
-
@object.reflections.each do |name, reflection|
|
49
|
-
if reflection.macro == :belongs_to && reflection.options[:property] == :is_governed_by # TODO add policy class
|
50
|
-
return reflection.name
|
51
|
-
end
|
52
|
-
end
|
30
|
+
@object_is_governed_by ||= @object.send(@object.governed_by_association.name) rescue nil
|
53
31
|
end
|
54
32
|
|
55
33
|
# #solr_response_for_raw_result and #solr_documents_for_response
|
@@ -17,11 +17,9 @@ ActiveFedora::Base.class_eval do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def governable?
|
20
|
-
!
|
20
|
+
!governed_by_association.nil?
|
21
21
|
end
|
22
22
|
|
23
|
-
private
|
24
|
-
|
25
23
|
def governed_by_association
|
26
24
|
self.reflections.each do |name, reflection|
|
27
25
|
# FIXME add class name condition, i.e.:
|
@@ -139,7 +139,7 @@ module FcrepoAdmin::Helpers
|
|
139
139
|
def format_datastream_profile_value(ds, key)
|
140
140
|
case
|
141
141
|
when key == "dsSize" then number_to_human_size(ds.dsSize)
|
142
|
-
when key == "dsCreateDate" then ds.dsCreateDate.
|
142
|
+
when key == "dsCreateDate" then ds.dsCreateDate.localtime
|
143
143
|
when key == "dsLocation" && ds.content_is_url? then link_to(ds.dsLocation, ds.dsLocation)
|
144
144
|
when key == "dsState" then format_datastream_state(ds)
|
145
145
|
when key == "dsControlGroup" then format_datastream_control_group(ds)
|
@@ -10,7 +10,30 @@ module FcrepoAdmin::Helpers
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def object_properties
|
13
|
-
FcrepoAdmin.object_properties.inject(Hash.new) { |
|
13
|
+
FcrepoAdmin.object_properties.inject(Hash.new) { |hash, prop| hash[prop] = object_property(prop); hash }
|
14
|
+
end
|
15
|
+
|
16
|
+
def object_property(prop)
|
17
|
+
case
|
18
|
+
when prop == :state then object_state
|
19
|
+
when prop == :create_date then object_date(@object.create_date)
|
20
|
+
when prop == :modified_date then object_date(@object.modified_date)
|
21
|
+
else @object.send(prop)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def object_date(dt)
|
26
|
+
Time.parse(dt).localtime
|
27
|
+
end
|
28
|
+
|
29
|
+
def object_state
|
30
|
+
state = @object.state
|
31
|
+
value = case
|
32
|
+
when state == 'A' then "A (Active)"
|
33
|
+
when state == 'I' then "I (Inactive)"
|
34
|
+
when state == 'D' then "D (Deleted)"
|
35
|
+
end
|
36
|
+
value
|
14
37
|
end
|
15
38
|
|
16
39
|
def object_show_datastream_columns
|
@@ -37,6 +60,8 @@ module FcrepoAdmin::Helpers
|
|
37
60
|
when item == :permissions then link_to_object item, @object.has_permissions? && can?(:permissions, @object)
|
38
61
|
when item == :associations then link_to_object item
|
39
62
|
when item == :audit_trail then link_to_object item, @object.auditable? && can?(:audit_trail, @object)
|
63
|
+
when item == :bookmark
|
64
|
+
render(:partial => 'catalog/bookmark_control', :locals => {:document=> @document}) if @document
|
40
65
|
else custom_object_nav_item item
|
41
66
|
end
|
42
67
|
end
|
@@ -61,6 +86,6 @@ module FcrepoAdmin::Helpers
|
|
61
86
|
def custom_object_nav_item(item)
|
62
87
|
# Override this method with your custom item behavior
|
63
88
|
end
|
64
|
-
|
89
|
+
|
65
90
|
end
|
66
91
|
end
|
data/lib/fcrepo_admin/version.rb
CHANGED
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.5.
|
4
|
+
version: 0.5.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-
|
14
|
+
date: 2013-05-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: hydra-head
|
@@ -250,6 +250,7 @@ files:
|
|
250
250
|
- app/mailers/.gitkeep
|
251
251
|
- app/models/.gitkeep
|
252
252
|
- app/views/fcrepo_admin/associations/_associations.html.erb
|
253
|
+
- app/views/fcrepo_admin/associations/_document_header.html.erb
|
253
254
|
- app/views/fcrepo_admin/associations/index.html.erb
|
254
255
|
- app/views/fcrepo_admin/associations/show.html.erb
|
255
256
|
- app/views/fcrepo_admin/catalog/_document.html.erb
|
@@ -286,6 +287,7 @@ files:
|
|
286
287
|
- lib/assets/.gitkeep
|
287
288
|
- lib/fcrepo_admin.rb
|
288
289
|
- lib/fcrepo_admin/ability.rb
|
290
|
+
- lib/fcrepo_admin/configurable.rb
|
289
291
|
- lib/fcrepo_admin/controller/controller_behavior.rb
|
290
292
|
- lib/fcrepo_admin/decorators/active_fedora/base_decorator.rb
|
291
293
|
- lib/fcrepo_admin/decorators/active_fedora/datastream_decorator.rb
|