storefront 0.3.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -4
- data/lib/storefront.rb +22 -35
- data/lib/storefront/components/base.rb +99 -0
- data/lib/storefront/components/breadcrumb.rb +7 -0
- data/lib/storefront/components/button.rb +37 -0
- data/lib/storefront/components/definition_list.rb +34 -0
- data/lib/storefront/components/definition_list_item.rb +63 -0
- data/lib/storefront/components/flash.rb +12 -0
- data/lib/storefront/components/footer.rb +19 -0
- data/lib/storefront/components/form.rb +82 -0
- data/lib/storefront/{form → components/form}/base.rb +3 -3
- data/lib/storefront/{form → components/form}/builder.rb +3 -3
- data/lib/storefront/{form → components/form}/errors.rb +1 -3
- data/lib/storefront/{form → components/form}/field.rb +1 -1
- data/lib/storefront/{form → components/form}/fieldset.rb +0 -0
- data/lib/storefront/{form → components/form}/hint.rb +0 -0
- data/lib/storefront/{form → components/form}/input.rb +7 -5
- data/lib/storefront/components/form/inputs.rb +7 -0
- data/lib/storefront/{form → components/form}/inputs/checkbox.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/date.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/file.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/hidden.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/radio.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/range.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/select.rb +6 -6
- data/lib/storefront/{form → components/form}/inputs/string.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/submit.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/textarea.rb +0 -0
- data/lib/storefront/{form → components/form}/inputs/value.rb +0 -0
- data/lib/storefront/{form → components/form}/label.rb +1 -1
- data/lib/storefront/components/header.rb +73 -0
- data/lib/storefront/components/image.rb +12 -0
- data/lib/storefront/components/javascript_template.rb +21 -0
- data/lib/storefront/components/list.rb +27 -0
- data/lib/storefront/components/menu.rb +41 -0
- data/lib/storefront/components/nav.rb +78 -0
- data/lib/storefront/components/sidebar.rb +23 -0
- data/lib/storefront/components/table.rb +232 -0
- data/lib/storefront/components/text.rb +29 -0
- data/lib/storefront/configuration.rb +53 -5
- data/lib/storefront/helpers/cache_helper.rb +37 -19
- data/lib/storefront/helpers/component_helper.rb +80 -41
- data/lib/storefront/helpers/content_helper.rb +211 -0
- data/lib/storefront/helpers/dom_helper.rb +136 -0
- data/lib/storefront/helpers/head_helper.rb +277 -205
- data/lib/storefront/helpers/model_helper.rb +21 -0
- data/lib/storefront/helpers/request_helper.rb +301 -53
- data/lib/storefront/helpers/tag_helper.rb +29 -0
- data/lib/storefront/{proxies/attribute_proxy.rb → models/attribute.rb} +1 -1
- data/lib/storefront/{proxies/model_proxy.rb → models/model.rb} +4 -6
- data/lib/storefront/railtie.rb +3 -16
- metadata +48 -64
- data/lib/storefront/dashboard.rb +0 -185
- data/lib/storefront/form.rb +0 -82
- data/lib/storefront/helpers/attribute_helper.rb +0 -81
- data/lib/storefront/helpers/body_helper.rb +0 -18
- data/lib/storefront/helpers/browser_helper.rb +0 -54
- data/lib/storefront/helpers/collection_helper.rb +0 -14
- data/lib/storefront/helpers/dashboard_helper.rb +0 -29
- data/lib/storefront/helpers/debug_helper.rb +0 -11
- data/lib/storefront/helpers/definition_list_helper.rb +0 -110
- data/lib/storefront/helpers/error_helper.rb +0 -11
- data/lib/storefront/helpers/flash_helper.rb +0 -14
- data/lib/storefront/helpers/form_helper.rb +0 -13
- data/lib/storefront/helpers/format_helper.rb +0 -59
- data/lib/storefront/helpers/image_helper.rb +0 -30
- data/lib/storefront/helpers/list_helper.rb +0 -135
- data/lib/storefront/helpers/locale_helper.rb +0 -245
- data/lib/storefront/helpers/open_graph_helper.rb +0 -5
- data/lib/storefront/helpers/page_helper.rb +0 -91
- data/lib/storefront/helpers/presenter_helper.rb +0 -5
- data/lib/storefront/helpers/semantic/location_helper.rb +0 -18
- data/lib/storefront/helpers/semantic/time_helper.rb +0 -14
- data/lib/storefront/helpers/sidebar_helper.rb +0 -27
- data/lib/storefront/helpers/system_helper.rb +0 -18
- data/lib/storefront/helpers/table_helper.rb +0 -38
- data/lib/storefront/helpers/template_helper.rb +0 -11
- data/lib/storefront/helpers/time_helper.rb +0 -21
- data/lib/storefront/helpers/url_helper.rb +0 -32
- data/lib/storefront/helpers/user_helper.rb +0 -15
- data/lib/storefront/helpers/widget_helper.rb +0 -142
- data/lib/storefront/helpers/workflow_helper.rb +0 -50
- data/lib/storefront/model_helper.rb +0 -17
- data/lib/storefront/table.rb +0 -198
- data/rails/init.rb +0 -1
- data/test/form_helper_test.rb +0 -5
- data/test/support/mock_controller.rb +0 -15
- data/test/support/mock_response.rb +0 -14
- data/test/support/models.rb +0 -0
- data/test/test_helper.rb +0 -34
@@ -1,135 +0,0 @@
|
|
1
|
-
module Storefront
|
2
|
-
module ListHelper
|
3
|
-
def list_widget(*args, &block)
|
4
|
-
options = list_widget_options("list-widget", *args)
|
5
|
-
|
6
|
-
capture_haml do
|
7
|
-
haml_tag :nav, options[:outer_html] do
|
8
|
-
@list_context = :list
|
9
|
-
|
10
|
-
header = header_widget(options)
|
11
|
-
haml_concat header if header.present?
|
12
|
-
|
13
|
-
haml_tag options[:tag], options[:inner_html], &block
|
14
|
-
|
15
|
-
footer_widget(options[:footer_html]) if options[:footer_html].present?
|
16
|
-
|
17
|
-
@list_context = nil
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def list_widget_options(*args)
|
23
|
-
options = widget_options(*args)
|
24
|
-
|
25
|
-
options[:tag] ||= :ul
|
26
|
-
|
27
|
-
if storefront_config.include_aria
|
28
|
-
options[:outer_html][:role] ||= :list
|
29
|
-
end
|
30
|
-
|
31
|
-
options[:inner_html] ||= {}
|
32
|
-
|
33
|
-
merge_class! options[:inner_html], *[
|
34
|
-
"list-items"
|
35
|
-
]
|
36
|
-
|
37
|
-
options
|
38
|
-
end
|
39
|
-
|
40
|
-
def menu_widget(*args, &block)
|
41
|
-
options = menu_widget_options("menu-widget", *args)
|
42
|
-
|
43
|
-
capture_haml do
|
44
|
-
haml_tag :nav, options[:outer_html] do
|
45
|
-
@list_context = :menu
|
46
|
-
header = header_widget(options)
|
47
|
-
haml_concat header if header.present?
|
48
|
-
|
49
|
-
haml_tag options[:tag], options[:inner_html], &block
|
50
|
-
|
51
|
-
footer_widget(options[:footer_html]) if options[:footer_html].present?
|
52
|
-
@list_context = nil
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
alias nav_widget menu_widget
|
57
|
-
|
58
|
-
def menu_widget_options(*args)
|
59
|
-
options = widget_options(*args)
|
60
|
-
|
61
|
-
if storefront_config.include_aria
|
62
|
-
options[:outer_html][:role] ||= :menu
|
63
|
-
end
|
64
|
-
|
65
|
-
options[:inner_html] ||= {}
|
66
|
-
|
67
|
-
options[:tag] ||= :ol
|
68
|
-
|
69
|
-
merge_class! options[:inner_html], *[
|
70
|
-
"list-items"
|
71
|
-
]
|
72
|
-
|
73
|
-
options
|
74
|
-
end
|
75
|
-
|
76
|
-
def list_item(key, path = nil, attributes = {}, &block)
|
77
|
-
locale_options = attributes.delete(:locale_options) || {}
|
78
|
-
text = t?(key, locale_options.reverse_merge(:scope => :"widgets.nav"))
|
79
|
-
|
80
|
-
as = attributes.delete(:as) || :span
|
81
|
-
separator = attributes.delete(:separator)
|
82
|
-
|
83
|
-
if attributes.has_key?(:current)
|
84
|
-
current = attributes.delete(:current) == true
|
85
|
-
else
|
86
|
-
current = on_current_page?(path)
|
87
|
-
end
|
88
|
-
|
89
|
-
inner_html = attributes.delete(:inner_html) || {}
|
90
|
-
outer_html = attributes.delete(:outer_html) || {}
|
91
|
-
|
92
|
-
inner_html.merge! clone_attributes(attributes)
|
93
|
-
|
94
|
-
merge_class! outer_html, *[
|
95
|
-
storefront_config.nav_class,
|
96
|
-
current ? storefront_config.active_class : nil
|
97
|
-
].compact.uniq
|
98
|
-
|
99
|
-
if storefront_config.include_aria
|
100
|
-
outer_html[:role] ||= case @list_context
|
101
|
-
when :list
|
102
|
-
:listitem
|
103
|
-
when :menu
|
104
|
-
:menuitem
|
105
|
-
else
|
106
|
-
:listitem
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
text.strip!
|
111
|
-
|
112
|
-
outer_html[:id] ||= [text.underscore.parameterize, storefront_config.nav_class].join(storefront_config.separator).gsub(/[\s|_]+/, storefront_config.separator).squeeze(storefront_config.separator)
|
113
|
-
|
114
|
-
capture_haml do
|
115
|
-
haml_tag storefront_config.nav_tag, outer_html do
|
116
|
-
if block_given?
|
117
|
-
case block.arity
|
118
|
-
when 1
|
119
|
-
yield(text.strip)
|
120
|
-
else
|
121
|
-
yield
|
122
|
-
end
|
123
|
-
elsif current && as == :span
|
124
|
-
haml_tag :span, text, inner_html
|
125
|
-
else
|
126
|
-
inner_html[:title] ||= "Link to the #{text.strip} page."
|
127
|
-
haml_concat link_to(text, path, inner_html)
|
128
|
-
end
|
129
|
-
haml_tag :span, separator if separator
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
alias nav list_item
|
134
|
-
end
|
135
|
-
end
|
@@ -1,245 +0,0 @@
|
|
1
|
-
module Storefront
|
2
|
-
module LocaleHelper
|
3
|
-
SCOPES_WITH_NAMESPACE_AND_NESTED_MODEL = [
|
4
|
-
'%{namespace}.%{model}.%{nested_model}.%{action}.%{attribute}',
|
5
|
-
'%{model}.%{nested_model}.%{action}.%{attribute}',
|
6
|
-
'%{namespace}.%{model}.%{action}.%{attribute}',
|
7
|
-
'%{model}.%{action}.%{attribute}',
|
8
|
-
'%{namespace}.%{model}.%{nested_model}.%{attribute}',
|
9
|
-
'%{model}.%{nested_model}.%{attribute}',
|
10
|
-
'%{namespace}.%{model}.%{attribute}',
|
11
|
-
'%{model}.%{attribute}',
|
12
|
-
'%{namespace}.%{nested_model}.%{attribute}',
|
13
|
-
'%{nested_model}.%{attribute}',
|
14
|
-
'%{namespace}.%{attribute}',
|
15
|
-
'%{attribute}'
|
16
|
-
]
|
17
|
-
|
18
|
-
SCOPES_WITH_NESTED_MODEL = [
|
19
|
-
'%{model}.%{nested_model}.%{action}.%{attribute}',
|
20
|
-
'%{model}.%{action}.%{attribute}',
|
21
|
-
'%{model}.%{nested_model}.%{attribute}',
|
22
|
-
'%{model}.%{attribute}',
|
23
|
-
'%{nested_model}.%{attribute}',
|
24
|
-
'%{attribute}'
|
25
|
-
]
|
26
|
-
|
27
|
-
SCOPES_WITH_NAMESPACE = [
|
28
|
-
'%{namespace}.%{model}.%{action}.%{attribute}',
|
29
|
-
'%{namespace}.%{model}.%{attribute}',
|
30
|
-
'%{model}.%{action}.%{attribute}',
|
31
|
-
'%{model}.%{attribute}',
|
32
|
-
'%{namespace}.%{attribute}',
|
33
|
-
'%{attribute}'
|
34
|
-
]
|
35
|
-
|
36
|
-
SCOPES = [
|
37
|
-
'%{model}.%{action}.%{attribute}',
|
38
|
-
'%{model}.%{attribute}',
|
39
|
-
'%{attribute}'
|
40
|
-
]
|
41
|
-
|
42
|
-
# t?(:"what.summary", :scope => :"reports.titles", :model => deal)
|
43
|
-
def t?(key, options = {})
|
44
|
-
return key if key.is_a?(::String) || key.blank?
|
45
|
-
|
46
|
-
models = Storefront::ModelProxy.model_names(options[:model] || options[:models] || options[:model_names] || storefront_config.current_scope[:resource] || [])
|
47
|
-
models << "" if models.blank?
|
48
|
-
namespaces = Array(options[:namespaces] || options[:namespace] || storefront_config.current_scope[:namespace])
|
49
|
-
namespaces << "" if namespaces.blank? && !!storefront_config.localize_with_namespace
|
50
|
-
action_name = options[:action] || storefront_config.current_scope[:action]
|
51
|
-
defaults = []
|
52
|
-
allow_blank = options.delete(:allow_blank) == true
|
53
|
-
count = options.delete(:count)
|
54
|
-
# none, one, many, other
|
55
|
-
count_key = count != 1 ? :other : :one
|
56
|
-
|
57
|
-
keys = [key.to_s]
|
58
|
-
|
59
|
-
if options.has_key?(:present) || options.has_key?(:past) || options.has_key?(:future)
|
60
|
-
if options[:future] == true
|
61
|
-
tense_key = :future
|
62
|
-
else
|
63
|
-
tense_key = (options.delete(:present) == true || options.delete(:past) == false) ? :present : :past
|
64
|
-
end
|
65
|
-
else
|
66
|
-
tense_key = nil
|
67
|
-
end
|
68
|
-
|
69
|
-
if options.has_key?(:nested_model)
|
70
|
-
with_nested_model = !!options[:nested_model]
|
71
|
-
else
|
72
|
-
with_nested_model = !!storefront_config.localize_with_nested_model
|
73
|
-
end
|
74
|
-
|
75
|
-
if options.has_key?(:namespace)
|
76
|
-
with_namespace = !!options[:namespace]
|
77
|
-
else
|
78
|
-
with_namespace = !!storefront_config.localize_with_namespace
|
79
|
-
end
|
80
|
-
|
81
|
-
if with_nested_model && with_namespace
|
82
|
-
# TODO, need to performance test before we do this many operations
|
83
|
-
SCOPES_WITH_NAMESPACE_AND_NESTED_MODEL
|
84
|
-
elsif with_nested_model
|
85
|
-
# TODO
|
86
|
-
SCOPES_WITH_NESTED_MODEL
|
87
|
-
elsif with_namespace
|
88
|
-
namespaces.each do |namespace|
|
89
|
-
models.each do |model|
|
90
|
-
keys.each do |_key|
|
91
|
-
SCOPES_WITH_NAMESPACE.each do |path|
|
92
|
-
path = path.dup
|
93
|
-
path.gsub!('%{namespace}', namespace)
|
94
|
-
path.gsub!('%{model}', model)
|
95
|
-
path.gsub!('%{action}', action_name)
|
96
|
-
path.gsub!('%{attribute}', _key)
|
97
|
-
path.gsub!('..', '.')
|
98
|
-
defaults << path
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
else
|
104
|
-
models.each do |model|
|
105
|
-
keys.each do |_key|
|
106
|
-
SCOPES.each do |path|
|
107
|
-
path = path.dup
|
108
|
-
path.gsub!('%{model}', model)
|
109
|
-
path.gsub!('%{action}', action_name)
|
110
|
-
path.gsub!('%{attribute}', _key)
|
111
|
-
path.gsub!('..', '.')
|
112
|
-
defaults << path
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
defaults.map!(&:to_sym)
|
119
|
-
defaults << ''
|
120
|
-
|
121
|
-
value = I18n.t(defaults.shift, options.merge(:default => defaults))
|
122
|
-
|
123
|
-
if value.is_a?(::Hash)
|
124
|
-
if value.has_key?(count_key)
|
125
|
-
value = value[count_key]
|
126
|
-
elsif value.has_key?(tense_key)
|
127
|
-
value = value[tense_key]
|
128
|
-
if value.is_a?(::Hash) && value.has_key?(count_key)
|
129
|
-
value = value[count_key]
|
130
|
-
end
|
131
|
-
elsif value.has_key?(count_key)
|
132
|
-
value = value[count_key]
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
if value.is_a?(::Hash)
|
137
|
-
if value.has_key?(:one)
|
138
|
-
value = value[:one]
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
if value.is_a?(::Hash)
|
143
|
-
if value.has_key?(:present)
|
144
|
-
value = value[:present]
|
145
|
-
elsif value.has_key?(:past)
|
146
|
-
value = value[:past]
|
147
|
-
elsif value.has_key?(:future)
|
148
|
-
value = value[:future]
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
value.blank? && !allow_blank ? key.to_s.split(".").last.titleize : value
|
153
|
-
end
|
154
|
-
|
155
|
-
# interpolate_hash(report, :scope => "reports", :begins_at_level => 3, :keys => {:bookmark => :selected})
|
156
|
-
def interpolate_hash(hash, options = {})
|
157
|
-
result = {}
|
158
|
-
hash.each do |key, value|
|
159
|
-
result[key.to_sym] = _interpolate_hash(key, value, {}, options)
|
160
|
-
end
|
161
|
-
result
|
162
|
-
end
|
163
|
-
|
164
|
-
protected
|
165
|
-
# This:
|
166
|
-
# {
|
167
|
-
# :who => {
|
168
|
-
# :title => "Who",
|
169
|
-
# :subtitle => "again?",
|
170
|
-
# :averages => {
|
171
|
-
# :title => "Averages",
|
172
|
-
# :first_time => {
|
173
|
-
# :title => "First Time",
|
174
|
-
# :value => 10
|
175
|
-
# }
|
176
|
-
# },
|
177
|
-
# :best => {
|
178
|
-
# :location => {
|
179
|
-
# :key => "work",
|
180
|
-
# :value => 80.0
|
181
|
-
# }
|
182
|
-
# }
|
183
|
-
# }
|
184
|
-
# }
|
185
|
-
#
|
186
|
-
# becomes...
|
187
|
-
#
|
188
|
-
# {
|
189
|
-
# :who => {
|
190
|
-
# :title => "Who",
|
191
|
-
# :subtitle => "again?",
|
192
|
-
# :averages => {
|
193
|
-
# :title => "Averages",
|
194
|
-
# :first_time => {
|
195
|
-
# :title => "First Time",
|
196
|
-
# :value => 10.0
|
197
|
-
# }
|
198
|
-
# },
|
199
|
-
# :best => {
|
200
|
-
# :title => "Most Popular"
|
201
|
-
# :location => {
|
202
|
-
# :title => "Location",
|
203
|
-
# :value => "Work (80%)"
|
204
|
-
# }
|
205
|
-
# }
|
206
|
-
# }
|
207
|
-
# }
|
208
|
-
#
|
209
|
-
# who.summary.title.past
|
210
|
-
# who.summary.title
|
211
|
-
# who.summary.past
|
212
|
-
# who.summary
|
213
|
-
def _interpolate_hash(key, object, result, options = {})
|
214
|
-
return object unless object.is_a?(::Hash)
|
215
|
-
key = key.to_s
|
216
|
-
title = object[:title] || object[:label]
|
217
|
-
subtitle = object[:subtitle]
|
218
|
-
|
219
|
-
title = t?(:"#{key}", options.merge(:try => :title))
|
220
|
-
title = key.to_s.split(".").last.titleize if title.blank? || title.is_a?(::Hash)
|
221
|
-
subtitle = t?(:"#{key}.subtitle", options.merge(:allow_blank => true))
|
222
|
-
|
223
|
-
# everything has to have a title
|
224
|
-
result[:title] = title
|
225
|
-
|
226
|
-
# not everything has to have a subtitle
|
227
|
-
result[:subtitle] = subtitle if subtitle.present?
|
228
|
-
|
229
|
-
# it's a leaf if we're at this point?
|
230
|
-
if object.has_key?(:value)
|
231
|
-
result[:value] = object[:value]
|
232
|
-
else
|
233
|
-
object.each do |child_key, child_value|
|
234
|
-
if child_value.is_a?(::Hash)
|
235
|
-
result[child_key.to_sym] = _interpolate_hash("#{key}.#{child_key}", child_value, {}, options)
|
236
|
-
else
|
237
|
-
result[child_key.to_sym] = child_value
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
result
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
module Storefront
|
2
|
-
module PageHelper
|
3
|
-
|
4
|
-
# calls <tt>model.to_title</tt>
|
5
|
-
def page(*args)
|
6
|
-
options = args.extract_options!
|
7
|
-
title = args.shift
|
8
|
-
options[:action] ||= storefront_config.current_scope[:action]
|
9
|
-
|
10
|
-
title = case title
|
11
|
-
when ::String
|
12
|
-
title
|
13
|
-
when ::Symbol
|
14
|
-
t?(title, :scope => :"pages.titles")
|
15
|
-
else
|
16
|
-
if options[:title].present?
|
17
|
-
options[:title]
|
18
|
-
else
|
19
|
-
parent_name = !!options[:parent] ? resource_to_title(storefront_config.current_scope[:parent], options) : nil
|
20
|
-
resource_name = resource_to_title(storefront_config.current_scope[:resource], options)
|
21
|
-
[parent_name, resource_name].compact.join(storefront_config.breadcrumb)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
self.title options[:browser] || title
|
26
|
-
|
27
|
-
options = header_widget_options(options.merge(:title => title))
|
28
|
-
|
29
|
-
options[:header_html].reverse_merge!(:id => storefront_config.page_header_id) if storefront_config.page_header_id.present?
|
30
|
-
options[:title_html].reverse_merge!(:id => storefront_config.page_title_id) if storefront_config.page_title_id.present?
|
31
|
-
options[:subtitle_html].reverse_merge!(:id => storefront_config.page_subtitle_id) if storefront_config.page_subtitle_id.present?
|
32
|
-
options[:level] = 1
|
33
|
-
options[:skip_format] = true
|
34
|
-
|
35
|
-
header_widget options.merge(:title => title)
|
36
|
-
end
|
37
|
-
|
38
|
-
def title_widget(*args, &block)
|
39
|
-
options = args.extract_options!
|
40
|
-
options[:header_html] ||= {}
|
41
|
-
merge_class! options[:header_html], *widget_classes("title-widget")
|
42
|
-
header_widget(options, &block)
|
43
|
-
end
|
44
|
-
|
45
|
-
def title_widget_options
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
def resource_to_title(resource, options = {})
|
50
|
-
if resource.present?
|
51
|
-
|
52
|
-
# handle subdomains as well
|
53
|
-
t?(options[:action].to_sym,
|
54
|
-
:scope => :"pages.titles",
|
55
|
-
:model => Storefront::ModelProxy.model_names(resource),
|
56
|
-
:namespaces => storefront_config.current_scope[:namespace],
|
57
|
-
:allow_blank => true,
|
58
|
-
:action => "",
|
59
|
-
:name => resource.is_a?(::Class) ? resource.name.titleize.pluralize : resource.to_title,
|
60
|
-
:clazz => resource.is_a?(::Class) ? resource.name.titleize : resource.class.name
|
61
|
-
)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def configure_storefront
|
66
|
-
action = params[:action].to_s
|
67
|
-
|
68
|
-
begin
|
69
|
-
resource_object = self.resource rescue nil
|
70
|
-
resource_object = resource_instance_name.to_s.camelize.constantize rescue nil
|
71
|
-
rescue Exception => e
|
72
|
-
resource_object = nil
|
73
|
-
end
|
74
|
-
begin
|
75
|
-
parent_object = self.parent rescue nil
|
76
|
-
rescue Exception => e
|
77
|
-
parent_object = nil
|
78
|
-
end
|
79
|
-
|
80
|
-
namespace = params[:controller].split("/")
|
81
|
-
namespace = namespace.length > 1 ? namespace[0..-2].join(".") : nil
|
82
|
-
|
83
|
-
storefront_config.current_scope = {
|
84
|
-
:action => action,
|
85
|
-
:resource => resource_object,
|
86
|
-
:parent => parent_object,
|
87
|
-
:namespace => namespace
|
88
|
-
}
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|