dugway 1.0.7 → 1.0.8
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/lib/dugway/liquid/filters/instant_checkout_filter.rb +67 -0
- data/lib/dugway/liquifier.rb +2 -0
- data/lib/dugway/store.rb +4 -0
- data/lib/dugway/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4c29856362aa6781513881924c2ffdab292d4a1a3a401c91d11e4ef1f7389a43
|
|
4
|
+
data.tar.gz: 8676516fc4b26c415f78e31558f1df5814dddb55c80221e0507f5793343f8d2e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7ffa6f534fcb3d51f14de4168906a2b7dbfab08689ac8d61136df08ffa848458d94fdbdacf17db43611d40c3ebf208759d3ca49a10781d58e02b53c740f295c
|
|
7
|
+
data.tar.gz: 32186c12dd6696cf6b41904c253a414cb25a7af2f19f0ff45e29c5dbc7212bb09703bac52b0ba9e9216bce4b645af30a62d77de9d96e3c0b5f075758425d5b45
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module Dugway
|
|
2
|
+
module Filters
|
|
3
|
+
module InstantCheckoutFilter
|
|
4
|
+
DIV_STYLES = [
|
|
5
|
+
"border-radius: 4px",
|
|
6
|
+
"font-size: 20px",
|
|
7
|
+
"font-weight: bold"
|
|
8
|
+
].freeze
|
|
9
|
+
|
|
10
|
+
LINK_STYLES = [
|
|
11
|
+
"border-radius: 4px",
|
|
12
|
+
"height: 100%",
|
|
13
|
+
"display: flex",
|
|
14
|
+
"padding: 10px",
|
|
15
|
+
"align-items: center",
|
|
16
|
+
"justify-content: center"
|
|
17
|
+
].freeze
|
|
18
|
+
|
|
19
|
+
def instant_checkout_button(account, a=nil, b=nil)
|
|
20
|
+
account = @context.registers[:account]
|
|
21
|
+
theme, height = sanitize_options(a, b)
|
|
22
|
+
|
|
23
|
+
return nil unless account.instant_checkout?
|
|
24
|
+
|
|
25
|
+
div_styles = generate_div_styles(theme, height)
|
|
26
|
+
link_styles = generate_link_styles(theme)
|
|
27
|
+
|
|
28
|
+
%(<div id="instant-checkout-button" style="#{ div_styles }"><a href="https://www.bigcartel.com/resources/help/article/apple-pay" style="#{ link_styles }">Instant Checkout</a></div>)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def sanitize_options(a, b)
|
|
34
|
+
theme = height = nil
|
|
35
|
+
|
|
36
|
+
[a, b].each do |value|
|
|
37
|
+
theme = value if /\A(dark|light(?:-outline)?)\z/.match(value)
|
|
38
|
+
height = value if /\A\d+(px|em|\%)\z/.match(value)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
return theme, height
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def generate_div_styles(theme, height)
|
|
45
|
+
styles = DIV_STYLES.dup
|
|
46
|
+
styles << "border: 1px solid black" if theme == "light-outline"
|
|
47
|
+
styles << "height: #{ height }" if height
|
|
48
|
+
styles << colors(theme)
|
|
49
|
+
styles.join("; ")
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def generate_link_styles(theme)
|
|
53
|
+
styles = LINK_STYLES.dup
|
|
54
|
+
styles << colors(theme)
|
|
55
|
+
styles.join("; ")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def colors(theme)
|
|
59
|
+
if theme =~ /\Alight/
|
|
60
|
+
"background-color: white; color: black"
|
|
61
|
+
else
|
|
62
|
+
"background-color: black; color: white"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
data/lib/dugway/liquifier.rb
CHANGED
|
@@ -7,6 +7,7 @@ Liquid::Template.register_filter(Dugway::Filters::CoreFilters)
|
|
|
7
7
|
Liquid::Template.register_filter(Dugway::Filters::DefaultPagination)
|
|
8
8
|
Liquid::Template.register_filter(Dugway::Filters::UrlFilters)
|
|
9
9
|
Liquid::Template.register_filter(Dugway::Filters::FontFilters)
|
|
10
|
+
Liquid::Template.register_filter(Dugway::Filters::InstantCheckoutFilter)
|
|
10
11
|
|
|
11
12
|
Liquid::Template.register_tag(:get, Dugway::Tags::Get)
|
|
12
13
|
Liquid::Template.register_tag(:paginate, Dugway::Tags::Paginate)
|
|
@@ -28,6 +29,7 @@ module Dugway
|
|
|
28
29
|
registers = shared_registers
|
|
29
30
|
registers[:category] = variables[:category]
|
|
30
31
|
registers[:artist] = variables[:artist]
|
|
32
|
+
registers[:account] = Dugway.store
|
|
31
33
|
|
|
32
34
|
if errors = variables.delete(:errors)
|
|
33
35
|
shared_context['errors'] << errors
|
data/lib/dugway/store.rb
CHANGED
data/lib/dugway/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dugway
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Big Cartel
|
|
@@ -482,6 +482,7 @@ files:
|
|
|
482
482
|
- lib/dugway/liquid/filters/core_filters.rb
|
|
483
483
|
- lib/dugway/liquid/filters/default_pagination.rb
|
|
484
484
|
- lib/dugway/liquid/filters/font_filters.rb
|
|
485
|
+
- lib/dugway/liquid/filters/instant_checkout_filter.rb
|
|
485
486
|
- lib/dugway/liquid/filters/url_filters.rb
|
|
486
487
|
- lib/dugway/liquid/filters/util_filters.rb
|
|
487
488
|
- lib/dugway/liquid/tags/get.rb
|