Class: Hyrax::WorkShowPresenter
Instance Attribute Summary collapse
Instance Method Summary
collapse
#attribute_to_html, #display_microdata?, #microdata_type_to_html, #permission_badge, #permission_badge_class
Methods included from ModelProxy
#persisted?, #to_model, #to_partial_path
Constructor Details
#initialize(solr_document, current_ability, request = nil) ⇒ WorkShowPresenter
Returns a new instance of WorkShowPresenter.
22
23
24
25
26
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 22
def initialize(solr_document, current_ability, request = nil)
@solr_document = solr_document
@current_ability = current_ability
@request = request
end
|
Instance Attribute Details
#current_ability ⇒ Object
Returns the value of attribute current_ability.
5
6
7
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 5
def current_ability
@current_ability
end
|
#request ⇒ Object
Returns the value of attribute request.
5
6
7
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 5
def request
@request
end
|
#solr_document ⇒ Object
Returns the value of attribute solr_document.
5
6
7
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 5
def solr_document
@solr_document
end
|
Instance Method Details
#display_feature_link? ⇒ Boolean
119
120
121
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 119
def display_feature_link?
work_featurable? && FeaturedWork.can_create_another? && !featured?
end
|
#display_unfeature_link? ⇒ Boolean
123
124
125
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 123
def display_unfeature_link?
work_featurable? && featured?
end
|
#editor? ⇒ Boolean
88
89
90
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 88
def editor?
current_ability.can?(:edit, solr_document)
end
|
#export_as_jsonld ⇒ Object
80
81
82
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 80
def export_as_jsonld
graph.dump(:jsonld, standard_prefixes: true)
end
|
#export_as_nt ⇒ Object
76
77
78
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 76
def export_as_nt
graph.dump(:ntriples)
end
|
#export_as_ttl ⇒ Object
84
85
86
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 84
def export_as_ttl
graph.dump(:ttl)
end
|
#grouped_presenters(filtered_by: nil, except: nil) ⇒ Object
Returns presenters grouped by model name, used to show the parents of this object.
106
107
108
109
110
111
112
113
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 106
def grouped_presenters(filtered_by: nil, except: nil)
grouped = member_of_collection_presenters.group_by(&:model_name).transform_keys { |key| key.to_s.underscore }
grouped.select! { |obj| obj.downcase == filtered_by } unless filtered_by.nil?
grouped.except!(*except) unless except.nil?
grouped
end
|
#inspect_work ⇒ Object
46
47
48
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 46
def inspect_work
@inspect_workflow ||= InspectWorkPresenter.new(solr_document, current_ability)
end
|
#link_name ⇒ Object
72
73
74
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 72
def link_name
current_ability.can?(:read, id) ? to_s : 'File'
end
|
#member_of_collection_presenters ⇒ Array<CollectionPresenter>
Get presenters for the collections this work is a member of via the member_of_collections association.
66
67
68
69
70
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 66
def member_of_collection_presenters
PresenterFactory.build_presenters(member_of_collection_ids,
collection_presenter_class,
*presenter_factory_arguments)
end
|
#page_title ⇒ Object
28
29
30
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 28
def page_title
title.first
end
|
#presenter_types ⇒ Object
#representative_presenter ⇒ Object
Returns FileSetPresenter presenter for the representative FileSets.
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 51
def representative_presenter
return nil if representative_id.blank?
@representative_presenter ||=
begin
result = member_presenters([representative_id]).first
if result.respond_to?(:representative_presenter)
result.representative_presenter
else
result
end
end
end
|
#stats_path ⇒ Object
127
128
129
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 127
def stats_path
Hyrax::Engine.routes.url_helpers.stats_work_path(self)
end
|
92
93
94
95
96
97
98
99
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 92
def
user = ::User.find_by_user_key(depositor)
if user.try(:twitter_handle).present?
"@#{user.twitter_handle}"
else
I18n.translate('hyrax.product_twitter_handle')
end
end
|
#work_featurable? ⇒ Boolean
115
116
117
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 115
def work_featurable?
user_can_feature_works? && solr_document.public?
end
|
#workflow ⇒ Object
42
43
44
|
# File 'app/presenters/hyrax/work_show_presenter.rb', line 42
def workflow
@workflow ||= WorkflowPresenter.new(solr_document, current_ability)
end
|