dugway 1.0.12 → 1.0.14

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca53a46e63f06064d7d5ff72d37a4056f99cd0210bd2ee12a3680bfe693bd84c
4
- data.tar.gz: 4b05f6b48ba91601c4a78c45d2f64a614f6792411fd60f980a732d5e22ea3bf3
3
+ metadata.gz: 7eae3c870ceda8207acc698d61c2aeb008b1f315e4e8bf4347578b90e10e365e
4
+ data.tar.gz: 0a2f33a7f2d6be0402e95c23385703ce8bef02f6b6825b0c2b17bc8e7d24198f
5
5
  SHA512:
6
- metadata.gz: 589bd59aa78d9ffb203fd0d323f051d764b7e74a9182cbe9b70cbc6361a3d055ca4bf4258c83d4804a127a9c16c7d6f191bef9dfe532658f0e056f7188efb588
7
- data.tar.gz: 1fdf871fdb967fc908937524d48e5b7a431704b6b977b84037424006d9b3848d2c1db98026f8f89b13f720b4ba109e50af6b118bc540d7a178b809d197607a67
6
+ metadata.gz: 14f7065a90a40eeff514d2816326af0cbc3341e0608a39e22c4059db4924557120b06de94ee11f1601a883707ef905b3ae26ae651490b6931a4c1f604d498d43
7
+ data.tar.gz: 1877a14d06d370d659a1c747f1d9f52642c6e6696942aa3d0a01d1fad9fa719d7bc373cf10538eb9b86a1a9aa37c27cad4cb26d462f2544084f99c43ddc07079
@@ -34,7 +34,7 @@ body#cart
34
34
 
35
35
  a.remove
36
36
  display: inline-block
37
- background: #ddd + 20
37
+ background: lighten(#ddd, 20%)
38
38
  border-radius: 20px
39
39
  height: 20px
40
40
  line-height: 18px
@@ -74,7 +74,7 @@ module Dugway
74
74
  'artists' => Drops::ArtistsDrop.new(store.artists.map { |a| Drops::ArtistDrop.new(a) }),
75
75
  'products' => Drops::ProductsDrop.new(store.products.map { |p| Drops::ProductDrop.new(p) }),
76
76
  'contact' => Drops::ContactDrop.new,
77
- 'head_content' => head_content,
77
+ 'head_content' => [window_bigcartel_script, head_content].join,
78
78
  'bigcartel_credit' => bigcartel_credit,
79
79
  'powered_by_big_cartel' => powered_by_big_cartel,
80
80
  }
@@ -100,6 +100,15 @@ module Dugway
100
100
  content
101
101
  end
102
102
 
103
+ def window_bigcartel_script
104
+ product = @request.params[:product] ? store.product(@request.params[:product]) : nil
105
+
106
+ script = "window.bigcartel = window.bigcartel || {};"
107
+ script << "\nwindow.bigcartel.product = #{product.to_json};" if product
108
+
109
+ "<script>#{script}</script>"
110
+ end
111
+
103
112
  def bigcartel_credit
104
113
  '<a href="http://bigcartel.com/" title="Start your own store at Big Cartel now">Online Store by Big Cartel</a>'
105
114
  end
data/lib/dugway/theme.rb CHANGED
@@ -143,7 +143,7 @@ module Dugway
143
143
  def validate_required_layout_attributes
144
144
  layout_content = read_source_file('layout.html')
145
145
 
146
- unless layout_content =~ /<body[^>]*data-bc-page-type[^>]*>/
146
+ unless layout_content =~ /<body.*?\bdata-bc-page-type\b/
147
147
  @errors << "layout.html missing `data-bc-page-type` attribute on body tag"
148
148
  end
149
149
 
@@ -168,30 +168,32 @@ module Dugway
168
168
  end
169
169
 
170
170
  def validate_preset_styles(preset)
171
- @errors << 'Preset is missing group_name' unless preset['group_name'].is_a?(String)
171
+ @errors << 'Preset is missing group_name' if preset['group_name'].to_s.strip.empty?
172
172
  @errors << 'Preset is missing styles' unless preset['styles'].is_a?(Array)
173
173
 
174
174
  preset['styles'].each do |style|
175
- @errors << 'Style is missing style_name' unless style['style_name'].is_a?(String)
175
+ @errors << "Style in group '#{preset['group_name']}' - Missing style_name" if style['style_name'].to_s.strip.empty?
176
176
 
177
177
  if style['fonts'].is_a?(Hash) && !style['fonts'].empty?
178
178
  style['fonts'].each_value do |font|
179
- @errors << 'Font value should be a string' unless font.is_a?(String)
179
+ @errors << "Style '#{style['style_name']} - Contains an invalid font name" if font.to_s.strip.empty?
180
180
  end
181
181
  else
182
- @errors << 'Style is missing fonts'
182
+ @errors << "Style '#{style['style_name']}' - Missing fonts"
183
183
  end
184
184
 
185
185
  if style['colors'].is_a?(Hash) && !style['colors'].empty?
186
186
  style['colors'].each do |key, color|
187
- @errors << 'Invalid color format' unless color =~ /^#[0-9A-Fa-f]{6}$/
187
+ unless color =~ /^#[0-9A-Fa-f]{6}$/
188
+ @errors << "Style '#{style['style_name']}' - Invalid color value '#{color}' for color '#{key}'"
189
+ end
188
190
  end
189
191
  else
190
- @errors << 'Style is missing colors'
192
+ @errors << "Style '#{style['style_name']}' - Missing required color settings"
191
193
  end
192
194
  end
193
195
 
194
- @errors << 'Style names should be unique' unless preset['styles'].map { |style| style['style_name'] }.uniq.length == preset['styles'].length
196
+ validate_style_name_uniqueness(preset['styles'])
195
197
  end
196
198
 
197
199
  def validate_style_references(preset)
@@ -209,11 +211,20 @@ module Dugway
209
211
  extra_keys = style_keys - variables
210
212
  missing_keys = variables - style_keys
211
213
 
212
- @errors << "Extra #{key_type} keys: #{extra_keys.join(', ')}" unless extra_keys.empty?
213
- @errors << "Missing #{key_type} keys: #{missing_keys.join(', ')}" unless missing_keys.empty?
214
+ @errors << "Style '#{style['style_name']}' - Extra #{key_type} keys: #{extra_keys.join(', ')}" unless extra_keys.empty?
215
+ @errors << "Style '#{style['style_name']}' - Missing #{key_type} keys: #{missing_keys.join(', ')}" unless missing_keys.empty?
214
216
  end
215
217
  end
216
218
 
219
+ def validate_style_name_uniqueness(styles)
220
+ duplicates = styles
221
+ .group_by { |s| s['style_name'] }
222
+ .select { |_, group| group.size > 1 }
223
+ .keys
224
+
225
+ @errors << "Duplicate style names found: #{duplicates.join(', ')}" if duplicates.any?
226
+ end
227
+
217
228
  def source_dir
218
229
  Dugway.source_dir
219
230
  end
@@ -1,3 +1,3 @@
1
1
  module Dugway
2
- VERSION = "1.0.12"
2
+ VERSION = "1.0.14"
3
3
  end
@@ -231,6 +231,68 @@ describe Dugway::Theme do
231
231
  theme.errors.size.should == 2
232
232
  end
233
233
  end
234
+
235
+ describe "when preset styles are invalid" do
236
+ let(:valid_settings) do
237
+ {
238
+ 'fonts' => [{'variable' => 'font'}],
239
+ 'colors' => [
240
+ {'variable' => 'background_color'},
241
+ {'variable' => 'primary_text_color'},
242
+ {'variable' => 'link_text_color'},
243
+ {'variable' => 'link_hover_color'},
244
+ {'variable' => 'button_background_color'},
245
+ {'variable' => 'button_text_color'},
246
+ {'variable' => 'button_hover_background_color'}
247
+ ],
248
+ 'preset_styles' => {
249
+ 'preview' => {
250
+ 'title_font' => 'font',
251
+ 'body_font' => 'font',
252
+ 'text_color' => '#000000',
253
+ 'background_color' => '#FFFFFF'
254
+ },
255
+ 'presets' => [{
256
+ 'group_name' => 'Classic',
257
+ 'styles' => [{
258
+ 'style_name' => 'Style 1',
259
+ 'fonts' => {'font' => 'Arial'},
260
+ 'colors' => {
261
+ 'background_color' => '#FFFFFF',
262
+ 'primary_text_color' => '#000000',
263
+ 'link_text_color' => '#000000',
264
+ 'link_hover_color' => '#000000',
265
+ 'button_background_color' => '#000000',
266
+ 'button_text_color' => '#FFFFFF',
267
+ 'button_hover_background_color' => '#000000'
268
+ }
269
+ }]
270
+ }]
271
+ }
272
+ }
273
+ end
274
+
275
+ before(:each) do
276
+ allow(theme).to receive(:name) { "Test Theme" }
277
+ allow(theme).to receive(:version) { "1.2.3" }
278
+ end
279
+
280
+ it "requires non-empty group_name" do
281
+ settings = valid_settings
282
+ settings['preset_styles']['presets'].first['group_name'] = ' '
283
+ theme.stub(:settings) { settings }
284
+ theme.valid?.should be(false)
285
+ theme.errors.should include('Preset is missing group_name')
286
+ end
287
+
288
+ it "requires non-empty style_name" do
289
+ settings = valid_settings
290
+ settings['preset_styles']['presets'].first['styles'].first['style_name'] = ' '
291
+ theme.stub(:settings) { settings }
292
+ theme.valid?.should be(false)
293
+ theme.errors.should include('Style in group \'Classic\' - Missing style_name')
294
+ end
295
+ end
234
296
  end
235
297
 
236
298
  def read_file(file_name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dugway
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Big Cartel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-10 00:00:00.000000000 Z
11
+ date: 2025-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler