storefront 0.3.2 → 0.5.0
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.
- 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
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Storefront
|
|
2
|
+
module Helpers
|
|
3
|
+
module ModelHelper
|
|
4
|
+
extend ActiveSupport::Concern
|
|
5
|
+
|
|
6
|
+
module ClassMethods
|
|
7
|
+
def to_title
|
|
8
|
+
name
|
|
9
|
+
end unless self.respond_to?(:to_title)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
module InstanceMethods
|
|
13
|
+
def to_title
|
|
14
|
+
return title if respond_to?(:title)
|
|
15
|
+
return name if respond_to?(:name)
|
|
16
|
+
to_s
|
|
17
|
+
end unless self.class.instance_methods.include?(:to_title)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -1,69 +1,317 @@
|
|
|
1
1
|
module Storefront
|
|
2
|
-
module
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
module Helpers
|
|
3
|
+
module RequestHelper
|
|
4
|
+
def configure_storefront
|
|
5
|
+
action = params[:action].to_s
|
|
6
|
+
|
|
7
|
+
begin
|
|
8
|
+
resource_object = self.resource rescue nil
|
|
9
|
+
resource_object ||= resource_instance_name.to_s.camelize.constantize rescue nil
|
|
10
|
+
rescue Exception => e
|
|
11
|
+
resource_object = nil
|
|
12
|
+
end
|
|
13
|
+
begin
|
|
14
|
+
parent_object = self.parent rescue nil
|
|
15
|
+
rescue Exception => e
|
|
16
|
+
parent_object = nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
namespace = params[:controller].split("/")
|
|
20
|
+
namespace = namespace.length > 1 ? namespace[0..-2].join(".") : nil
|
|
21
|
+
|
|
22
|
+
storefront_config.current_scope = {
|
|
23
|
+
:action => action,
|
|
24
|
+
:resource => resource_object,
|
|
25
|
+
:parent => parent_object,
|
|
26
|
+
:namespace => namespace,
|
|
27
|
+
:context => self
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def storefront_config
|
|
32
|
+
Storefront.configuration
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def render_not_found(exception)
|
|
36
|
+
Exceptional::Catcher.handle_with_controller(exception, self, request) if defined?(::Exceptional)
|
|
37
|
+
logger.error(exception)
|
|
38
|
+
puts exception.inspect
|
|
39
|
+
puts exception.backtrace.join("\n")
|
|
40
|
+
render :template => "/error/404.html", :status => 404, :layout => false
|
|
12
41
|
end
|
|
13
|
-
end
|
|
14
42
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
43
|
+
# check the current browser (via user agent) for the following:
|
|
44
|
+
# :mozilla / :firefox
|
|
45
|
+
# :ie6
|
|
46
|
+
# :ie7
|
|
47
|
+
# :ie
|
|
48
|
+
# :iphone
|
|
49
|
+
# :safari
|
|
50
|
+
def browser_is? name
|
|
51
|
+
name = name.to_s.strip
|
|
52
|
+
|
|
53
|
+
return true if browser_name == name
|
|
54
|
+
return true if (name == 'mozilla' or name == "firefox") && browser_name == 'gecko'
|
|
55
|
+
return true if name == 'ie6' && browser_name.index('ie6')
|
|
56
|
+
return true if name == 'ie7' && browser_name.index('ie7')
|
|
57
|
+
return true if name == 'ie' && browser_name.index('ie')
|
|
58
|
+
return true if name == 'iphone' && browser_name == 'iphone'
|
|
59
|
+
return true if name == 'webkit' && browser_name == 'safari'
|
|
60
|
+
|
|
61
|
+
false
|
|
62
|
+
end
|
|
18
63
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
64
|
+
# find the current browser name
|
|
65
|
+
def browser_name
|
|
66
|
+
@browser_name ||= begin
|
|
67
|
+
ua = request.user_agent.to_s.downcase
|
|
68
|
+
if ua.index('msie') && !ua.index('opera') && !ua.index('webtv')
|
|
69
|
+
'ie'+ua[ua.index('msie')+5].chr
|
|
70
|
+
elsif ua.index('gecko/')
|
|
71
|
+
'gecko'
|
|
72
|
+
elsif ua.index('opera')
|
|
73
|
+
'opera'
|
|
74
|
+
elsif ua.index('konqueror')
|
|
75
|
+
'konqueror'
|
|
76
|
+
elsif ua.index('iphone')
|
|
77
|
+
'iphone'
|
|
78
|
+
elsif ua.index('applewebkit/')
|
|
79
|
+
'safari'
|
|
80
|
+
elsif ua.index('mozilla/')
|
|
81
|
+
'gecko'
|
|
82
|
+
else
|
|
83
|
+
""
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
24
87
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
redirect_to(request.protocol + domain + request.request_uri) if request.env['HTTP_HOST'] != domain
|
|
29
|
-
true
|
|
30
|
-
end
|
|
88
|
+
def ip_address
|
|
89
|
+
request.env['REMOTE_ADDR']
|
|
90
|
+
end
|
|
31
91
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
92
|
+
def user_agent
|
|
93
|
+
@user_agent ||= UserAgent.parse(request.user_agent)
|
|
94
|
+
end
|
|
35
95
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if url_string.index("?")
|
|
40
|
-
fullpath = request.fullpath
|
|
41
|
-
else
|
|
42
|
-
fullpath = request.fullpath.split('?').first
|
|
96
|
+
def windows?
|
|
97
|
+
# Can't match for just 'win' cause it will match darwin as well.
|
|
98
|
+
(/win32|mswin|mingw/).match(RUBY_PLATFORM) ? true : false
|
|
43
99
|
end
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
100
|
+
|
|
101
|
+
# Works on Debian and Ubuntu, don't have anything else to test on.
|
|
102
|
+
def linux?
|
|
103
|
+
(/linux/).match(RUBY_PLATFORM) ? true : false
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Works on my MacBook Pro, don't have anything else to test on,
|
|
107
|
+
def mac?
|
|
108
|
+
(/darwin/).match(RUBY_PLATFORM) ? true : false
|
|
48
109
|
end
|
|
49
|
-
end
|
|
50
110
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
111
|
+
# requesting?(:deals)
|
|
112
|
+
# requesting?("/admin/users/:id")
|
|
113
|
+
# requesting?("admin/users#show")
|
|
114
|
+
def requesting?(expression)
|
|
115
|
+
case expression
|
|
116
|
+
when ::Symbol
|
|
117
|
+
(request.path =~ /#{expression}\/?$/).present?
|
|
118
|
+
else
|
|
119
|
+
(request.path =~ expression).present?
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# ensure_domain :production => "site.com", :staging => "site-development.heroku.com"
|
|
124
|
+
def self.ensure_domain(options = {})
|
|
125
|
+
@ensure_domain_options = options.symbolize_keys
|
|
126
|
+
true
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def ensure_domain
|
|
130
|
+
domain = self.class.ensure_domain_options[Rails.env.to_sym]
|
|
131
|
+
return true if domain.blank?
|
|
132
|
+
redirect_to(request.protocol + domain + request.request_uri) if request.env['HTTP_HOST'] != domain
|
|
133
|
+
true
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def self.ensure_domain_options
|
|
137
|
+
@ensure_domain_options
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def on_current_page?(options)
|
|
141
|
+
url_string = CGI.unescapeHTML(url_for(options))
|
|
142
|
+
request = controller.request
|
|
143
|
+
if url_string.index("?")
|
|
144
|
+
fullpath = request.fullpath
|
|
145
|
+
else
|
|
146
|
+
fullpath = request.fullpath.split('?').first
|
|
147
|
+
end
|
|
148
|
+
if url_string =~ /^\w+:\/\//
|
|
149
|
+
url_string == "#{request.protocol}#{request.host_with_port}#{fullpath}"
|
|
150
|
+
else
|
|
151
|
+
url_string == fullpath.gsub(/&sort_by=.*/, "").gsub(/&vendor_name=.*/, "")
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def with_subdomain(subdomain)
|
|
156
|
+
subdomain = (subdomain || "")
|
|
157
|
+
subdomain += "." unless subdomain.empty?
|
|
158
|
+
# needs to be dynamic!
|
|
159
|
+
[subdomain, request.domain, request.port_string].join
|
|
160
|
+
end
|
|
57
161
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
162
|
+
def url_for(options = {})
|
|
163
|
+
if options.kind_of?(Hash) && options.has_key?(:subdomain)
|
|
164
|
+
options[:host] = with_subdomain(options.delete(:subdomain))
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
if options.is_a?(Symbol) && options == :up
|
|
168
|
+
request.path.split("/")[0..-2].join("/")
|
|
169
|
+
else
|
|
170
|
+
super(options)
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def current_subdomain
|
|
175
|
+
subdomain = request.subdomain.to_s.split(".").first
|
|
176
|
+
subdomain = nil if subdomain == App.name
|
|
177
|
+
(subdomain.blank? || subdomain == "www") ? nil : subdomain
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
def path_namespace?(*args)
|
|
181
|
+
args.present? ? args.any? { |is| path_namespace == is.to_s } : path_namespace.present?
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def path_namespace
|
|
185
|
+
if @path_namespace.nil?
|
|
186
|
+
if current_subdomain.present?
|
|
187
|
+
@path_namespace = current_subdomain
|
|
188
|
+
elsif params[:path_namespace]
|
|
189
|
+
@path_namespace = params[:path_namespace]
|
|
190
|
+
else
|
|
191
|
+
parts = params[:controller].split("/")
|
|
192
|
+
@path_namespace = parts.length > 1 ? parts.first : ""
|
|
193
|
+
end
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
@path_namespace
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def with_current_params(path_method, *args)
|
|
200
|
+
send path_method, *(args << Rack::Utils.parse_query(request.query_string).merge(args.extract_options!))
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
def link_to_sort(title, attribute)
|
|
204
|
+
sort_param = sort_value(attribute, opposite_sort_direction(attribute))
|
|
205
|
+
link_to title, with_params(request.path, :sort => sort_param)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# gives you the other direction from the current, if exists
|
|
209
|
+
def opposite_sort_direction(key)
|
|
210
|
+
direction = sort_direction(key)
|
|
211
|
+
return "+" unless direction
|
|
212
|
+
direction == "+" ? "-" : "+"
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# sort_class(:name, "asc", "desc")
|
|
216
|
+
def sort_class(key, ascending = "ascending", descending = "descending", none = nil)
|
|
217
|
+
case sort_direction(key)
|
|
218
|
+
when nil
|
|
219
|
+
none
|
|
220
|
+
when "+"
|
|
221
|
+
ascending
|
|
222
|
+
when "-"
|
|
223
|
+
descending
|
|
224
|
+
end
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
def sort_direction(key)
|
|
228
|
+
return nil if params["sort"].blank?
|
|
229
|
+
params["sort"][key.to_s]
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def sort_hash
|
|
233
|
+
{}
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def sort_value(attribute = nil, operator = "+")
|
|
237
|
+
result = []
|
|
238
|
+
attribute = attribute.to_s
|
|
239
|
+
sort_hash.each do |key, value|
|
|
240
|
+
if attribute.present? && attribute == key
|
|
241
|
+
result << "#{key}#{operator}"
|
|
242
|
+
else
|
|
243
|
+
result << "#{key}#{value}"
|
|
244
|
+
end
|
|
245
|
+
end
|
|
246
|
+
if attribute.present? && !sort_hash.has_key?(attribute)
|
|
247
|
+
result << "#{attribute}#{operator}"
|
|
248
|
+
end
|
|
249
|
+
result.join(",")
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def with_params(*args)
|
|
253
|
+
path = args.shift
|
|
254
|
+
new_params = args.shift || {}
|
|
255
|
+
options = args.shift || {}
|
|
256
|
+
params = query_params.merge(new_params.stringify_keys)
|
|
257
|
+
params = params.except(options[:except]) if options[:except].present?
|
|
258
|
+
params = params.slice(options[:only]) if options[:only].present?
|
|
259
|
+
return path if params.blank?
|
|
260
|
+
query_string = ::Deli::Query.build_query(params)
|
|
261
|
+
|
|
262
|
+
"#{path}?#{query_string}"
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
def link_to_sort(title, attribute)
|
|
266
|
+
sort_param = sort_value(attribute, opposite_sort_direction(attribute))
|
|
267
|
+
link_to title, with_params(request.path, :sort => sort_param)
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# gives you the other direction from the current, if exists
|
|
271
|
+
def opposite_sort_direction(key)
|
|
272
|
+
direction = sort_direction(key)
|
|
273
|
+
return "+" unless direction
|
|
274
|
+
direction == "+" ? "-" : "+"
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# sort_class(:name, "asc", "desc")
|
|
278
|
+
def sort_class(key, ascending = "ascending", descending = "descending", none = nil)
|
|
279
|
+
case sort_direction(key)
|
|
280
|
+
when nil
|
|
281
|
+
none
|
|
282
|
+
when "+"
|
|
283
|
+
ascending
|
|
284
|
+
when "-"
|
|
285
|
+
descending
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
def sort_direction(key)
|
|
290
|
+
return nil if query_params["sort"].blank?
|
|
291
|
+
key = key.to_s
|
|
292
|
+
return nil unless sort_hash.has_key?(key)
|
|
293
|
+
sort_hash[key.to_s]
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
def sort_hash
|
|
297
|
+
return {} if query_params["sort"].blank?
|
|
298
|
+
@sort_hash ||= deli_parser.find("sort").hash(query_params["sort"])
|
|
61
299
|
end
|
|
62
300
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
301
|
+
def sort_value(attribute = nil, operator = "+")
|
|
302
|
+
result = []
|
|
303
|
+
attribute = attribute.to_s
|
|
304
|
+
sort_hash.each do |key, value|
|
|
305
|
+
if attribute.present? && attribute == key
|
|
306
|
+
result << "#{key}#{operator}"
|
|
307
|
+
else
|
|
308
|
+
result << "#{key}#{value}"
|
|
309
|
+
end
|
|
310
|
+
end
|
|
311
|
+
if attribute.present? && !sort_hash.has_key?(attribute)
|
|
312
|
+
result << "#{attribute}#{operator}"
|
|
313
|
+
end
|
|
314
|
+
result.join(",")
|
|
67
315
|
end
|
|
68
316
|
end
|
|
69
317
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Storefront
|
|
2
|
+
module Helpers
|
|
3
|
+
# This module is a replacement for some of the common core Rails tag helper methods. It is not included by default.
|
|
4
|
+
#
|
|
5
|
+
# It adds a few missing features to some of the tags, so you can configure them globally.
|
|
6
|
+
# It also runs them through haml instead, so the attribute string sequence is normalized.
|
|
7
|
+
module TagHelper
|
|
8
|
+
# def link_to(title, path, options = {})
|
|
9
|
+
#
|
|
10
|
+
# end
|
|
11
|
+
|
|
12
|
+
# def image_tag(source, options = {})
|
|
13
|
+
# options.symbolize_keys!
|
|
14
|
+
#
|
|
15
|
+
# src = options[:src] = path_to_image(source)
|
|
16
|
+
#
|
|
17
|
+
# unless src =~ /^cid:/
|
|
18
|
+
# options[:alt] = options.fetch(:alt) { File.basename(src, '.*').gsub(/-\d+$/, "").gsub("-", " ").humanize }
|
|
19
|
+
# end
|
|
20
|
+
#
|
|
21
|
+
# if size = options.delete(:size)
|
|
22
|
+
# options[:width], options[:height] = size.split("x") if size =~ %{^\d+x\d+$}
|
|
23
|
+
# end
|
|
24
|
+
#
|
|
25
|
+
# capture_haml { haml_tag :img, options }
|
|
26
|
+
# end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
require 'ostruct'
|
|
2
|
-
|
|
3
1
|
module Storefront
|
|
4
|
-
class
|
|
2
|
+
class Model
|
|
5
3
|
class << self
|
|
6
4
|
def model_names(array)
|
|
7
5
|
Array(array).flatten.map do |object|
|
|
8
6
|
case object
|
|
9
7
|
when ::Class
|
|
10
|
-
object.
|
|
8
|
+
(object.ancestors - object.included_modules).map { |i| i.name.underscore }
|
|
11
9
|
when ::String, ::Symbol
|
|
12
10
|
object
|
|
13
11
|
else
|
|
14
|
-
object.class.
|
|
12
|
+
(object.class.ancestors - object.class.included_modules).map { |i| i.name.underscore }
|
|
15
13
|
end
|
|
16
14
|
end.flatten.compact.uniq
|
|
17
15
|
end
|
|
@@ -180,7 +178,7 @@ module Storefront
|
|
|
180
178
|
validations = validations.select do |validation|
|
|
181
179
|
(validation.options.present? ? options_require_validation?(validation.options) : true)
|
|
182
180
|
end unless mode == :all
|
|
183
|
-
|
|
181
|
+
|
|
184
182
|
return validations
|
|
185
183
|
end
|
|
186
184
|
|