dugway 0.11.4 → 1.0.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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/dugway/liquid/drops/contact_drop.rb +9 -0
- data/lib/dugway/liquid/drops/option_group_drop.rb +24 -0
- data/lib/dugway/liquid/drops/option_group_value_drop.rb +23 -0
- data/lib/dugway/liquid/drops/product_drop.rb +9 -0
- data/lib/dugway/liquid/drops/product_option_drop.rb +5 -0
- data/lib/dugway/liquid/filters/default_pagination.rb +22 -4
- data/lib/dugway/liquid/filters/url_filters.rb +1 -1
- data/lib/dugway/liquid/filters/util_filters.rb +2 -2
- data/lib/dugway/version.rb +1 -1
- data/spec/units/dugway/liquid/drops/contact_drop_spec.rb +7 -1
- metadata +8 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2625aace16555a5b683e997a7a0e445ba02a07418eb40b711ea03604c8a82c2b
|
|
4
|
+
data.tar.gz: 28e23d4592a86308e3297a6595077913585e8108cfd8ad41dda633ccea57cca6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 93c9c354790dca5dbcc2f14a4bb8c5b75ae82c43283f27c8a1c2509478b9c75c6583f315b247cc7e82aa793ee476d67ae19c6c489cf9bb5e5f3c3a79d09f8097
|
|
7
|
+
data.tar.gz: 75fd66e26e0b8d5490c7dd066d734d794f5df9f2cb5babc873bf18f539abea836a5b7a70347efbb1051b46f95469381e499e29db4e33c9a7a5dbf2d0a7fcff33
|
data/README.md
CHANGED
|
@@ -120,7 +120,7 @@ utilities.
|
|
|
120
120
|
|
|
121
121
|
Prefer [LESS](http://lesscss.org)? No problem, you'll just need to create a
|
|
122
122
|
[Gemfile like this one](https://gist.github.com/mattwigham/5569898) in the
|
|
123
|
-
root directory of your theme, run
|
|
123
|
+
root directory of your theme, run `bundle install`, and append the
|
|
124
124
|
**.less** extension to your CSS files.
|
|
125
125
|
|
|
126
126
|
And finally, for you JavaScript folks, we've baked
|
|
@@ -21,6 +21,15 @@ module Dugway
|
|
|
21
21
|
%{<img id="captcha_image" src="https://s3.amazonaws.com/bigcartel/captcha/28e3d1288cbc70c0cd1a2d10845f8e11e1a90d14.png">}
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def recaptcha
|
|
25
|
+
@recaptcha ||= begin
|
|
26
|
+
html = "This site is protected by reCAPTCHA and the Google "
|
|
27
|
+
html += '<a href="https://policies.google.com/privacy">Privacy Policy</a> and '
|
|
28
|
+
html += '<a href="https://policies.google.com/terms">Terms of Service</a> apply.'
|
|
29
|
+
html
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
24
33
|
def sent
|
|
25
34
|
request.path == '/contact' && request.post? && errors.blank?
|
|
26
35
|
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Dugway
|
|
2
|
+
module Drops
|
|
3
|
+
class OptionGroupDrop < BaseDrop
|
|
4
|
+
|
|
5
|
+
def id
|
|
6
|
+
source['id']
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def name
|
|
10
|
+
source['name']
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def position
|
|
14
|
+
source['position']
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def values
|
|
18
|
+
@values ||= source['values'].present? ?
|
|
19
|
+
source['values'].map { |value| OptionGroupValueDrop.new(value) } : []
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Dugway
|
|
2
|
+
module Drops
|
|
3
|
+
class OptionGroupValueDrop < BaseDrop
|
|
4
|
+
|
|
5
|
+
def id
|
|
6
|
+
source['id']
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def name
|
|
10
|
+
source['name']
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def position
|
|
14
|
+
source['position']
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def option_group_id
|
|
18
|
+
source['option_group_id']
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -37,6 +37,15 @@ module Dugway
|
|
|
37
37
|
@options_in_stock ||= options.reject { |o| o.sold_out }
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
def has_option_groups
|
|
41
|
+
source['has_option_groups']
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def option_groups
|
|
45
|
+
@option_groups ||= source['option_groups'].present? ?
|
|
46
|
+
source['option_groups'].map { |group| OptionGroupDrop.new(group) } : []
|
|
47
|
+
end
|
|
48
|
+
|
|
40
49
|
def shipping
|
|
41
50
|
@shipping ||= source['shipping'].present? ? source['shipping'].map { |o| ShippingOptionDrop.new(o.update('product' => self)) } : []
|
|
42
51
|
end
|
|
@@ -22,6 +22,11 @@ module Dugway
|
|
|
22
22
|
def inventory
|
|
23
23
|
((quantity.to_f / (quantity + sold).to_f) * 100).round
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
def option_group_values
|
|
27
|
+
@option_group_values ||= source['option_group_values'].present? ?
|
|
28
|
+
source['option_group_values'].map { |value| OptionGroupValueDrop.new(value) } : []
|
|
29
|
+
end
|
|
25
30
|
end
|
|
26
31
|
end
|
|
27
32
|
end
|
|
@@ -7,22 +7,22 @@ module Dugway
|
|
|
7
7
|
|
|
8
8
|
prev_label = prev_label.blank? ? paginate['previous']['title'] : prev_label
|
|
9
9
|
if paginate['previous']['is_link']
|
|
10
|
-
html << %(<a class="previous" href="#{ paginate['previous']['url'] }">#{ prev_label }</a>)
|
|
10
|
+
html << %(<a class="previous" href="#{ paginate['previous']['url'] }" aria-label="Go to previous page">#{ prev_label }</a>)
|
|
11
11
|
else
|
|
12
12
|
html << %(<span class="previous disabled">#{ prev_label }</span>)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
paginate['parts'].each do |part|
|
|
16
16
|
if part['is_link']
|
|
17
|
-
html << %(<a href="#{ part['url'] }">#{ part['title'] }</a>)
|
|
17
|
+
html << %(<a href="#{ part['url'] }" aria-label="Go to page #{part['title']}">#{ part['title'] }</a>)
|
|
18
18
|
else
|
|
19
|
-
html <<
|
|
19
|
+
html << build_non_link_span(part, paginate)
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
next_label = next_label.blank? ? paginate['next']['title'] : next_label
|
|
24
24
|
if paginate['next']['is_link']
|
|
25
|
-
html << %(<a class="next" href="#{ paginate['next']['url'] }">#{ next_label }</a>)
|
|
25
|
+
html << %(<a class="next" href="#{ paginate['next']['url'] }" aria-label="Go to next page">#{ next_label }</a>)
|
|
26
26
|
else
|
|
27
27
|
html << %(<span class="next disabled">#{ next_label }</span>)
|
|
28
28
|
end
|
|
@@ -30,6 +30,24 @@ module Dugway
|
|
|
30
30
|
html << %(</div>)
|
|
31
31
|
}.join(' ')
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def build_non_link_span(part, paginate)
|
|
37
|
+
is_current = is_current_page?(part, paginate)
|
|
38
|
+
span_class = is_current ? 'current' : 'gap'
|
|
39
|
+
|
|
40
|
+
span = %(<span )
|
|
41
|
+
span << %(class="#{span_class}" )
|
|
42
|
+
span << %(aria-label="Current page, page #{part['title']}") if is_current
|
|
43
|
+
span << %(>)
|
|
44
|
+
span << %(#{ part['title'] }</span>)
|
|
45
|
+
span
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def is_current_page?(part, paginate)
|
|
49
|
+
part['title'] == paginate['current_page'].to_s
|
|
50
|
+
end
|
|
33
51
|
end
|
|
34
52
|
end
|
|
35
53
|
end
|
|
@@ -86,13 +86,13 @@ module Dugway
|
|
|
86
86
|
digits, rounded_number = 1, 0
|
|
87
87
|
else
|
|
88
88
|
digits = (Math.log10(number.abs) + 1).floor
|
|
89
|
-
rounded_number = (BigDecimal
|
|
89
|
+
rounded_number = (BigDecimal(number.to_s) / BigDecimal((10 ** (digits - precision)).to_f.to_s)).round.to_f * 10 ** (digits - precision)
|
|
90
90
|
digits = (Math.log10(rounded_number.abs) + 1).floor # After rounding, the number of digits may have changed
|
|
91
91
|
end
|
|
92
92
|
precision -= digits
|
|
93
93
|
precision = precision > 0 ? precision : 0 #don't let it be negative
|
|
94
94
|
else
|
|
95
|
-
rounded_number = BigDecimal
|
|
95
|
+
rounded_number = BigDecimal(number.to_s).round(precision).to_f
|
|
96
96
|
end
|
|
97
97
|
formatted_number = number_with_delimiter("%01.#{precision}f" % rounded_number, options)
|
|
98
98
|
if strip_insignificant_zeros
|
data/lib/dugway/version.rb
CHANGED
|
@@ -13,7 +13,7 @@ describe Dugway::Drops::ContactDrop do
|
|
|
13
13
|
Rack::MockRequest::DEFAULT_ENV.update({
|
|
14
14
|
'PATH_INFO' => '/contact'
|
|
15
15
|
})}
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
let(:request) { Dugway::Request.new(env) }
|
|
18
18
|
|
|
19
19
|
let(:errors) {
|
|
@@ -96,6 +96,12 @@ describe Dugway::Drops::ContactDrop do
|
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
+
describe "#recaptcha" do
|
|
100
|
+
it "returns the recaptcha branding text" do
|
|
101
|
+
contact.recaptcha.should == %{This site is protected by reCAPTCHA and the Google <a href="https://policies.google.com/privacy">Privacy Policy</a> and <a href="https://policies.google.com/terms">Terms of Service</a> apply.}
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
99
105
|
describe "#sent" do
|
|
100
106
|
it "should return false before the form has been sent" do
|
|
101
107
|
contact.sent.should be(false)
|
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: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Big Cartel
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-10-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -452,6 +452,8 @@ files:
|
|
|
452
452
|
- lib/dugway/liquid/drops/country_drop.rb
|
|
453
453
|
- lib/dugway/liquid/drops/currency_drop.rb
|
|
454
454
|
- lib/dugway/liquid/drops/image_drop.rb
|
|
455
|
+
- lib/dugway/liquid/drops/option_group_drop.rb
|
|
456
|
+
- lib/dugway/liquid/drops/option_group_value_drop.rb
|
|
455
457
|
- lib/dugway/liquid/drops/page_drop.rb
|
|
456
458
|
- lib/dugway/liquid/drops/pages_drop.rb
|
|
457
459
|
- lib/dugway/liquid/drops/product_drop.rb
|
|
@@ -543,7 +545,7 @@ homepage: https://github.com/bigcartel/dugway
|
|
|
543
545
|
licenses:
|
|
544
546
|
- MIT
|
|
545
547
|
metadata: {}
|
|
546
|
-
post_install_message:
|
|
548
|
+
post_install_message:
|
|
547
549
|
rdoc_options: []
|
|
548
550
|
require_paths:
|
|
549
551
|
- lib
|
|
@@ -558,9 +560,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
558
560
|
- !ruby/object:Gem::Version
|
|
559
561
|
version: '0'
|
|
560
562
|
requirements: []
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
signing_key:
|
|
563
|
+
rubygems_version: 3.0.6
|
|
564
|
+
signing_key:
|
|
564
565
|
specification_version: 4
|
|
565
566
|
summary: Easily build and test Big Cartel themes.
|
|
566
567
|
test_files:
|