dugway 1.0.7 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8390ef193bc160dedfcd4745df7b5b96e2bb702b10bd3cd9794cd7f951edc03d
4
- data.tar.gz: bbba535b7d2c34823c50bdac3f83418ad74091063fc3cd6957fe1f70a36a0145
3
+ metadata.gz: 8f97af86358fec7f36d3c23b9f128e5bc9d4bb4c14a59ed299fc24cf663697fd
4
+ data.tar.gz: 2f384d23090cd675a83a689c9df2be70fd340f91ccbd0eb2094fece3c418fc15
5
5
  SHA512:
6
- metadata.gz: ecc5b434330a537eba7f403815975fbff7fbec5d1ab3256fc324392fdde90bd8228cd741897517ba92464a0a2023cf870d579ddd2fd192a27667b5d3d4098c9a
7
- data.tar.gz: 2557195c107df99b5ae72cfd027d6a4c43463b4d2c39b8a2d5022ddf4bdeab5d2c3fe34efdba8fff6bb5b5777fcdc39cf0ba5f14ff7c9f0c31dda507d081ab01
6
+ metadata.gz: 49c1e1d3d002ba1054f3a33692c28deb1a5d27445bf16f29982dad577981f646eecb7cd38bded3992f07d2d19580e0262492b05210ae37d17af1fcaadc4cd752
7
+ data.tar.gz: 784f2bf5789523cdebe025401eee40c89cffd4e864d0cea765261c92a912123678262d7d451484113d840124300852ee187baa3805d0fe56b0dac2ee6fcb5a73
data/dugway.gemspec CHANGED
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  s.add_dependency('will_paginate', '~> 3.0.4')
36
36
  s.add_dependency('i18n', '1.6')
37
37
  s.add_dependency('htmlentities', '~> 4.3.1')
38
+ s.add_dependency('listen', '~> 3.0')
38
39
  s.add_dependency('thor', '~> 0.20.3')
39
40
  s.add_dependency('rubyzip', '~> 0.9.9')
40
41
  s.add_dependency('terser', '~> 1.1')
@@ -1,4 +1,5 @@
1
1
  require 'rack'
2
+ require 'listen'
2
3
 
3
4
  module Dugway
4
5
  module Cli
@@ -22,6 +23,13 @@ module Dugway
22
23
  :desc => "The server to run"
23
24
 
24
25
  def start
26
+ listener = Listen.to('.', only: /\.dugway\.json$/) do |modified|
27
+ puts "Config changed, restarting server..."
28
+ exec "dugway server"
29
+ end
30
+
31
+ Thread.new { listener.start }
32
+
25
33
  Rack::Server.start({
26
34
  :config => File.join(Dir.pwd, 'config.ru'),
27
35
  :environment => 'none',
@@ -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
@@ -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
@@ -127,6 +127,10 @@ module Dugway
127
127
  currency['locale']
128
128
  end
129
129
 
130
+ def instant_checkout?
131
+ Dugway.options.dig(:store, :instant_checkout) || false
132
+ end
133
+
130
134
  private
131
135
 
132
136
  def get(path)
@@ -1,3 +1,3 @@
1
1
  module Dugway
2
- VERSION = "1.0.7"
2
+ VERSION = "1.0.9"
3
3
  end
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.7
4
+ version: 1.0.9
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-02-08 00:00:00.000000000 Z
11
+ date: 2024-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
236
  version: 4.3.1
237
+ - !ruby/object:Gem::Dependency
238
+ name: listen
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '3.0'
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '3.0'
237
251
  - !ruby/object:Gem::Dependency
238
252
  name: thor
239
253
  requirement: !ruby/object:Gem::Requirement
@@ -482,6 +496,7 @@ files:
482
496
  - lib/dugway/liquid/filters/core_filters.rb
483
497
  - lib/dugway/liquid/filters/default_pagination.rb
484
498
  - lib/dugway/liquid/filters/font_filters.rb
499
+ - lib/dugway/liquid/filters/instant_checkout_filter.rb
485
500
  - lib/dugway/liquid/filters/url_filters.rb
486
501
  - lib/dugway/liquid/filters/util_filters.rb
487
502
  - lib/dugway/liquid/tags/get.rb
@@ -577,7 +592,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
577
592
  - !ruby/object:Gem::Version
578
593
  version: '0'
579
594
  requirements: []
580
- rubygems_version: 3.2.3
595
+ rubygems_version: 3.0.3.1
581
596
  signing_key:
582
597
  specification_version: 4
583
598
  summary: Easily build and test Big Cartel themes.