Module: Spotlight::ApplicationHelper
Instance Method Summary
collapse
#default_masthead_jcrop_options, #default_thumbnail_jcrop_options
#administration_page_title, #curation_page_title, #header_with_count, #page_title, #set_html_page_title
#action_label, #cancel_link, #create_link, #delete_link, #edit_link, #exhibit_create_link, #exhibit_delete_link, #exhibit_edit_link, #exhibit_view_link, #view_link
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Can search for named routes directly in the main app, omitting the “main_app.” prefix
19
20
21
22
23
24
25
|
# File 'app/helpers/spotlight/application_helper.rb', line 19
def method_missing method, *args, &block
if main_app_url_helper?(method)
main_app.send(method, *args)
else
super
end
end
|
Instance Method Details
103
104
105
106
107
108
109
110
|
# File 'app/helpers/spotlight/application_helper.rb', line 103
def
('summary') do |card|
card.url exhibit_root_url(current_exhibit)
card.title current_exhibit.title
card.description current_exhibit.subtitle
card.image carrierwave_url(current_exhibit.thumbnail.image.thumb) if current_exhibit.thumbnail
end
end
|
#application_name ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'app/helpers/spotlight/application_helper.rb', line 7
def application_name
name = super
if current_exhibit
t :'spotlight.application_name', exhibit: current_exhibit.title, application_name: name
else
name
end
end
|
#available_view_fields ⇒ Object
138
139
140
|
# File 'app/helpers/spotlight/application_helper.rb', line 138
def available_view_fields
current_exhibit.blacklight_configuration.default_blacklight_config.view.to_h.reject { |k,v| v.if === false}
end
|
#blacklight_view_config_for_search_block(block) ⇒ Object
Return a copy of the blacklight configuration that only includes views conifgured by our block
67
68
69
70
71
72
|
# File 'app/helpers/spotlight/application_helper.rb', line 67
def blacklight_view_config_for_search_block block
blacklight_config.view.select do |view,_|
block.view.include? view.to_s
end
end
|
#block_document_index_view_type(block) ⇒ Object
74
75
76
77
78
79
80
81
82
|
# File 'app/helpers/spotlight/application_helper.rb', line 74
def block_document_index_view_type block
views = blacklight_view_config_for_search_block(block)
if views.has_key? document_index_view_type
document_index_view_type
else
views.keys.first
end
end
|
#carrierwave_url(upload) ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
|
# File 'app/helpers/spotlight/application_helper.rb', line 112
def carrierwave_url upload
url = upload.url
if url.nil? or url.starts_with? "http"
url
else
(Rails.application.config.asset_host || root_url).sub(/\/$/, "") + url
end
end
|
#document_action_path(action_opts, url_opts = nil) ⇒ Object
41
42
43
44
45
46
47
|
# File 'app/helpers/spotlight/application_helper.rb', line 41
def document_action_path action_opts, url_opts = nil
if current_exhibit
spotlight.send(action_opts.path || "exhibit_#{action_opts.key}_#{controller_name}_path", url_opts)
else
super
end
end
|
#render_document_class(document = @document) ⇒ Object
Overridden from Blacklight to inject a private class
59
60
61
62
63
|
# File 'app/helpers/spotlight/application_helper.rb', line 59
def render_document_class(document = @document)
types = super || ""
types << " #{document_class_prefix}private" if document.private?(current_exhibit)
types
end
|
#render_save_this_search? ⇒ Boolean
124
125
126
127
|
# File 'app/helpers/spotlight/application_helper.rb', line 124
def render_save_this_search?
(current_exhibit and can?( :curate, current_exhibit)) &&
!(params[:controller] == "spotlight/catalog" && params[:action] == "admin")
end
|
#respond_to?(method, *args) ⇒ Boolean
27
28
29
|
# File 'app/helpers/spotlight/application_helper.rb', line 27
def respond_to?(method, *args)
main_app_url_helper?(method) or super
end
|
91
92
93
94
95
96
97
98
99
100
101
|
# File 'app/helpers/spotlight/application_helper.rb', line 91
def select_deselect_button
button_tag(
t(:".deselect_all"),
class: "btn btn-default btn-xs metadata-select",
data: {
:behavior => "metadata-select",
:'deselect-text' => t(:".deselect_all"),
:'select-text' => t(:".select_all")
}
)
end
|
#selected_search_block_views(block) ⇒ Object
Return the list of views that are configured to display for a block
85
86
87
88
89
|
# File 'app/helpers/spotlight/application_helper.rb', line 85
def selected_search_block_views block
block.as_json[:data].select do |key, value|
value == "on"
end.keys.map { |x| x.to_s }
end
|
#uploaded_field_label(config) ⇒ Object
129
130
131
132
|
# File 'app/helpers/spotlight/application_helper.rb', line 129
def uploaded_field_label config
solr_field = Array(config.solr_field || config.field_name).first.to_s
config.label || blacklight_config.index_fields[solr_field].try(:label) || t(".#{solr_field}")
end
|
#url_for_document(document) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'app/helpers/spotlight/application_helper.rb', line 31
def url_for_document document
return nil if document.nil?
if current_exhibit
[spotlight, current_exhibit, document]
else
document
end
end
|
#url_to_tag_facet(tag) ⇒ Object
49
50
51
52
53
54
55
|
# File 'app/helpers/spotlight/application_helper.rb', line 49
def url_to_tag_facet tag
if current_exhibit
search_action_url(add_facet_params(Spotlight::SolrDocument.solr_field_for_tagger(current_exhibit), tag, {}))
else
search_action_url(q: tag)
end
end
|
#view_label(view) ⇒ Object
134
135
136
|
# File 'app/helpers/spotlight/application_helper.rb', line 134
def view_label view
t(:"blacklight.search.view.#{view}", default: blacklight_config.view[view].title || view.to_s)
end
|