dugway 0.12.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/dugway/cli/templates/source/contact.html +1 -6
- data/lib/dugway/contact_form_validator.rb +1 -7
- data/lib/dugway/liquid/drops/contact_drop.rb +9 -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/features/contact_form_spec.rb +0 -7
- data/spec/features/page_rendering_spec.rb +1 -1
- data/spec/fixtures/theme/contact.html +1 -6
- data/spec/units/dugway/contact_form_validator_spec.rb +0 -11
- data/spec/units/dugway/liquid/drops/contact_drop_spec.rb +7 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 164c11d13a392a70b8827996b897125e0669211fe85cb5463445d86d41d53a4d
|
4
|
+
data.tar.gz: e4d2171b77593472fc50be05842b091d83c4c0c6fa28d2ebe9e7c54de9bc115a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 935b7f6c7af148e55df7a3f20e52a37d0aa317f3033f991a4c1f21a9d03b0c5fc6665658e4990c7d293b64203fde70e68e23dce3be750477da0802ab1848ef31
|
7
|
+
data.tar.gz: 5f85b9baa1c340cead3ad92b503d90cb619f3b66e9a08bec983300df80a7ec057c3651b681c29e1cb4beacf569961322638a0ec52bce21add32aeed550567043
|
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
|
@@ -22,14 +22,9 @@
|
|
22
22
|
<label for="message">Message</label>
|
23
23
|
{{ contact | contact_input: 'message' }}
|
24
24
|
</li>
|
25
|
-
<li>
|
26
|
-
<label for="captcha">Spam check</label>
|
27
|
-
<p>Please enter the characters from the image.</p>
|
28
|
-
<div>{{ contact.captcha }}</div>
|
29
|
-
{{ contact | contact_input: 'captcha' }}
|
30
|
-
</li>
|
31
25
|
<li>
|
32
26
|
<button type="submit" name="submit" title="Send us an email">Send</button>
|
27
|
+
<div>{{ contact.recaptcha }}</div>
|
33
28
|
</li>
|
34
29
|
</ul>
|
35
30
|
</form>
|
@@ -12,25 +12,19 @@ module Dugway
|
|
12
12
|
'All fields are required'
|
13
13
|
elsif param_does_not_match(:email, email_format)
|
14
14
|
'Invalid email address'
|
15
|
-
elsif param_does_not_match(:captcha, captcha_format)
|
16
|
-
'Spam check was incorrect'
|
17
15
|
end
|
18
16
|
end
|
19
17
|
|
20
18
|
private
|
21
19
|
|
22
20
|
def required_fields
|
23
|
-
[ :name, :email, :subject, :message
|
21
|
+
[ :name, :email, :subject, :message ]
|
24
22
|
end
|
25
23
|
|
26
24
|
def email_format
|
27
25
|
/^([^@\s]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})$/
|
28
26
|
end
|
29
27
|
|
30
|
-
def captcha_format
|
31
|
-
/^rQ9pC$/i
|
32
|
-
end
|
33
|
-
|
34
28
|
def param_does_not_match(param_name, regex)
|
35
29
|
!(params[param_name.to_sym] =~ regex)
|
36
30
|
end
|
@@ -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
|
@@ -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
@@ -16,18 +16,12 @@ feature 'Contact form' do
|
|
16
16
|
expect(page).to have_content('Invalid email address')
|
17
17
|
end
|
18
18
|
|
19
|
-
scenario 'with an invalid captcha' do
|
20
|
-
submit_contact_form(:captcha => 'blah')
|
21
|
-
expect(page).to have_content('Spam check was incorrect')
|
22
|
-
end
|
23
|
-
|
24
19
|
def submit_contact_form(fields={})
|
25
20
|
fields.reverse_merge!(
|
26
21
|
:name => 'Joe',
|
27
22
|
:email => 'joe@example.com',
|
28
23
|
:subject => 'Testing',
|
29
24
|
:message => 'Hi there',
|
30
|
-
:captcha => 'rQ9pC'
|
31
25
|
)
|
32
26
|
|
33
27
|
visit '/contact'
|
@@ -36,7 +30,6 @@ feature 'Contact form' do
|
|
36
30
|
fill_in 'Email', :with => fields[:email]
|
37
31
|
fill_in 'Subject', :with => fields[:subject]
|
38
32
|
fill_in 'Message', :with => fields[:message]
|
39
|
-
fill_in 'Spam check', :with => fields[:captcha]
|
40
33
|
|
41
34
|
click_button 'Send'
|
42
35
|
end
|
@@ -50,7 +50,7 @@ feature 'Page rendering' do
|
|
50
50
|
visit '/contact'
|
51
51
|
expect(page).to have_content('Dugway') # layout.html
|
52
52
|
expect(page).to have_content('Contact')
|
53
|
-
expect(page).to have_content('
|
53
|
+
expect(page).to have_content('protected by reCAPTCHA')
|
54
54
|
end
|
55
55
|
|
56
56
|
scenario 'maintenance.html' do
|
@@ -22,14 +22,9 @@
|
|
22
22
|
<label for="message">Message</label>
|
23
23
|
{{ contact | contact_input: 'message' }}
|
24
24
|
</li>
|
25
|
-
<li>
|
26
|
-
<label for="captcha">Spam check</label>
|
27
|
-
<p>Please enter the characters from the image.</p>
|
28
|
-
<div>{{ contact.captcha }}</div>
|
29
|
-
{{ contact | contact_input: 'captcha' }}
|
30
|
-
</li>
|
31
25
|
<li>
|
32
26
|
<button type="submit" name="submit" title="Send us an email">Send</button>
|
27
|
+
<div>{{ contact.recaptcha }}</div>
|
33
28
|
</li>
|
34
29
|
</ul>
|
35
30
|
</form>
|
@@ -11,7 +11,6 @@ describe Dugway::ContactFormValidator do
|
|
11
11
|
:email => "name@example.com",
|
12
12
|
:subject => "subject",
|
13
13
|
:message => "message",
|
14
|
-
:captcha => "rQ9pc",
|
15
14
|
}
|
16
15
|
end
|
17
16
|
|
@@ -36,21 +35,11 @@ describe Dugway::ContactFormValidator do
|
|
36
35
|
assert_required_fields_error
|
37
36
|
end
|
38
37
|
|
39
|
-
it "returns an error for a missing captcha" do
|
40
|
-
validator.params[:captcha] = " "
|
41
|
-
assert_required_fields_error
|
42
|
-
end
|
43
|
-
|
44
38
|
it "returns an error for invalid email format" do
|
45
39
|
validator.params[:email] = "foo-at-foo-dot-net"
|
46
40
|
expect(validator.error_message).to eq "Invalid email address"
|
47
41
|
end
|
48
42
|
|
49
|
-
it "returns an error for incorrect captcha" do
|
50
|
-
validator.params[:captcha] = "oops"
|
51
|
-
expect(validator.error_message).to eq "Spam check was incorrect"
|
52
|
-
end
|
53
|
-
|
54
43
|
def assert_required_fields_error
|
55
44
|
expect(validator.error_message).to eql "All fields are required"
|
56
45
|
end
|
@@ -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.1
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -545,7 +545,7 @@ homepage: https://github.com/bigcartel/dugway
|
|
545
545
|
licenses:
|
546
546
|
- MIT
|
547
547
|
metadata: {}
|
548
|
-
post_install_message:
|
548
|
+
post_install_message:
|
549
549
|
rdoc_options: []
|
550
550
|
require_paths:
|
551
551
|
- lib
|
@@ -560,9 +560,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
560
560
|
- !ruby/object:Gem::Version
|
561
561
|
version: '0'
|
562
562
|
requirements: []
|
563
|
-
|
564
|
-
|
565
|
-
signing_key:
|
563
|
+
rubygems_version: 3.0.6
|
564
|
+
signing_key:
|
566
565
|
specification_version: 4
|
567
566
|
summary: Easily build and test Big Cartel themes.
|
568
567
|
test_files:
|