kajabi_theme 0.2.1 → 0.5.0

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
- SHA1:
3
- metadata.gz: 9352ef12ae197f6f659505bbcb9b68ae8b366671
4
- data.tar.gz: 4df235168d41370dc14194330aef983d362e2c9f
2
+ SHA256:
3
+ metadata.gz: a96c3071d92de9a6bcabff7851e4e10d3786b6e54c6212390a3e5c606c76c2a7
4
+ data.tar.gz: 4fc0ce5480f59157cabe1f75f1f9323b8a467e6dff3cfeddde7a97db13c89203
5
5
  SHA512:
6
- metadata.gz: 4838ae748909f4a091145f7bee8309f09ca0bf6e548e37e735f46ed9f0d778530caa703c7386a3095d7235bcf2384300708866168ab14998db6e9eeb9f5c9f71
7
- data.tar.gz: 360926518f8bf1a0cad028fb083cd46a0ad3505fa21322b6c822b10c16e27e9f387bed8a5badfce5d8dbf96f4082a5fae52541a353fe1eda3a7a1c17d53c3d53
6
+ metadata.gz: 0105b79a4be6393c42b703fa53516a734f8f5ed6ac4e14d838c4923b00e1cb87f207be0ed38236f45dbfdb038128ae68c568cddc8ca65881868b0abc4836ea7b
7
+ data.tar.gz: 7421d37fde804610d2442f393ce48c9ac3c32b5614d501a1067e798579a671765ed1a4119399210b641f2b37cc8003d6a511f808ad396d7e1949751baedf7836
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
- --format documentation
1
+ --format progress
2
2
  --color
@@ -20,9 +20,11 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "thor"
22
22
  spec.add_dependency "typhoeus"
23
- spec.add_dependency "filewatcher"
23
+ spec.add_dependency "filewatcher", "~> 0.5.4"
24
+ spec.add_dependency "mime-types", "~> 3.1"
24
25
 
25
26
  spec.add_development_dependency "bundler", "~> 1.10"
26
27
  spec.add_development_dependency "rake", "~> 10.0"
27
28
  spec.add_development_dependency "rspec"
29
+ spec.add_development_dependency "webmock"
28
30
  end
@@ -12,7 +12,7 @@ module KajabiTheme
12
12
  include Thor::Actions
13
13
 
14
14
  FOLDERS=%w[config templates layouts sections snippets assets].freeze
15
- ACCOUNT_SETTINGS_URL="https://app.newkajabi.com/admin/settings/account"
15
+ ACCOUNT_SETTINGS_URL="https://app.kajabi.com/admin/settings/account"
16
16
 
17
17
  attr_reader :name
18
18
  attr_reader :updated_at
@@ -20,20 +20,24 @@ module KajabiTheme
20
20
  attr_reader :presigned_post
21
21
 
22
22
  desc "sync", "Sync all files to Kajabi"
23
+ option :concurrency, type: :numeric, default: 20, desc: "Maximum simultaneous uploads", aliases: :c
23
24
  def sync(force=true)
25
+ self.concurrency = options[:concurrency]
24
26
  refresh!
25
27
  (force ? files : changed_files).each {|f| send_file(f)}
26
28
  hydra.run
27
29
  end
28
30
 
29
31
  desc "watch", "Sync and watch for changes"
32
+ option :concurrency, type: :numeric, default: 20, desc: "Maximum simultaneous uploads", aliases: :c
30
33
  def watch
34
+ self.concurrency = options[:concurrency]
31
35
  refresh!
32
36
  sync(false)
33
37
 
34
38
  say "Watching for file changes..."
35
39
 
36
- Filewatcher.new(FOLDERS).watch do |filename|
40
+ FileWatcher.new(FOLDERS).watch do |filename|
37
41
  say "Change detected: #{filename}"
38
42
  send_file(filename)
39
43
  hydra.run
@@ -43,11 +47,23 @@ module KajabiTheme
43
47
  desc "configure", "Configure the current directory for syncing"
44
48
  def configure
45
49
  theme_id = ask("Kajabi Theme ID:")
46
- api_key = ask("API Key (#{ACCOUNT_SETTINGS_URL}):")
47
- api_secret = ask("API Secret (#{ACCOUNT_SETTINGS_URL}):")
50
+ api_key = ask("API Key (#{ACCOUNT_SETTINGS_URL}):")
51
+ api_secret = ask("API Secret (#{ACCOUNT_SETTINGS_URL}):")
52
+ cainfo = ask("CA Cert File (leave blank if you're unsure):")
53
+
54
+ if !cainfo.empty? && !File.exist?(File.expand_path(cainfo))
55
+ say "Unable to find '#{cainfo}' (skipping)", :yellow
56
+ cainfo = ""
57
+ end
48
58
 
49
59
  create_file "config.yml" do
50
- { theme_id: theme_id, api_key: api_key, api_secret: api_secret }.to_yaml
60
+ {
61
+ theme_id: theme_id,
62
+ api_key: api_key,
63
+ api_secret: api_secret,
64
+ cainfo: cainfo,
65
+ ssl_verifypeer: true
66
+ }.to_yaml
51
67
  end
52
68
  end
53
69
 
@@ -65,7 +81,16 @@ module KajabiTheme
65
81
  end
66
82
 
67
83
  def host
68
- @host ||= config[:host] || "https://app.newkajabi.com/"
84
+ @host ||= config[:host] || "https://app.kajabi.com/"
85
+ end
86
+
87
+ def concurrency
88
+ @concurrency || 20
89
+ end
90
+
91
+ def concurrency=(val)
92
+ val = val.to_i
93
+ @concurrency = val if val.positive?
69
94
  end
70
95
 
71
96
  def id
@@ -80,8 +105,26 @@ module KajabiTheme
80
105
  config[:api_secret]
81
106
  end
82
107
 
108
+ def ssl_verifypeer
109
+ config.fetch(:ssl_verifypeer, true)
110
+ end
111
+
112
+ def cainfo
113
+ config.fetch(:cainfo, "")
114
+ end
115
+
116
+ def ssl_options
117
+ { ssl_verifypeer: ssl_verifypeer }.tap do |options|
118
+ options[:cainfo] = File.expand_path(cainfo) unless cainfo.empty?
119
+ end
120
+ end
121
+
122
+ def proxy
123
+ config[:proxy]
124
+ end
125
+
83
126
  def hydra
84
- @hydra ||= Typhoeus::Hydra.hydra
127
+ @hydra ||= Typhoeus::Hydra.new(max_concurrency: concurrency)
85
128
  end
86
129
 
87
130
  def http_credentials
@@ -117,7 +160,8 @@ module KajabiTheme
117
160
  say "Request timed out", :red
118
161
  elsif response.code == 0
119
162
  # Could not get an http response, something's wrong.
120
- say "Request timed out", :red
163
+ say "Something went wrong: #{response.return_message}", :red
164
+ say "URL: #{response.request.url}", :red
121
165
  else
122
166
  # Received a non-successful http response.
123
167
  say "HTTP request failed: #{response.code.to_s} #{response.body.to_s}", :red
@@ -142,28 +186,40 @@ module KajabiTheme
142
186
  end
143
187
 
144
188
  def send_editable_file(file)
145
- request = Typhoeus::Request.new(
146
- assets_url,
189
+ options = {
190
+ proxy: proxy,
147
191
  userpwd: http_credentials,
148
192
  method: :put,
149
193
  headers: { "content-type" => "application/x-www-form-urlencoded" },
150
194
  body: { asset: { key: file, content: File.read(file) }}
195
+ }.merge(ssl_options)
196
+
197
+ request = Typhoeus::Request.new(
198
+ assets_url,
199
+ options
151
200
  )
201
+
152
202
  handle_request request do |response|
153
203
  say "Uploaded: #{file}", :green
154
204
  end
205
+
155
206
  hydra.queue(request)
156
207
  request
157
208
  end
158
209
 
159
210
  def send_asset_file(file)
160
211
  body = presigned_post["fields"]
161
- request = Typhoeus::Request.new(
162
- presigned_post["url"],
212
+ options = {
213
+ proxy: proxy,
163
214
  method: :post,
164
215
  body: body.merge("file" => File.open(file, "r"))
216
+ }.merge(ssl_options)
217
+
218
+ request = Typhoeus::Request.new(
219
+ presigned_post["url"],
220
+ options
165
221
  )
166
-
222
+
167
223
  handle_request request do |response|
168
224
  say "Uploaded: #{file}", :green
169
225
  end
@@ -1,3 +1,5 @@
1
+ require "mime/types"
2
+
1
3
  module KajabiTheme
2
4
  class Util
3
5
  def self.editable?(name)
@@ -9,7 +11,7 @@ module KajabiTheme
9
11
  def self.content_type(name)
10
12
  if name.end_with?(".woff2")
11
13
  "application/font-woff2"
12
- elsif name.end_with?(".scss") || name.end_with?(".scss.liquid")
14
+ elsif name.end_with?(".css") || name.end_with?(".scss") || name.end_with?(".scss.liquid")
13
15
  "text/css"
14
16
  else
15
17
  MIME::Types.type_for(name.sub('.liquid', '')).first.content_type rescue "text/plain"
@@ -1,3 +1,3 @@
1
1
  module KajabiTheme
2
- VERSION = "0.2.1"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kajabi_theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Saenz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-16 00:00:00.000000000 Z
11
+ date: 2020-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -42,16 +42,30 @@ dependencies:
42
42
  name: filewatcher
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 0.5.4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 0.5.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: mime-types
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - ">="
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description: Command line tool to help with developing Kajabi themes. Provides some
98
126
  commands detect changes of local theme files and sync them with a theme on Kajabi
99
127
  email:
@@ -120,7 +148,7 @@ files:
120
148
  homepage: http://www.kajabi.co
121
149
  licenses: []
122
150
  metadata: {}
123
- post_install_message:
151
+ post_install_message:
124
152
  rdoc_options: []
125
153
  require_paths:
126
154
  - lib
@@ -135,9 +163,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
163
  - !ruby/object:Gem::Version
136
164
  version: '0'
137
165
  requirements: []
138
- rubyforge_project:
139
- rubygems_version: 2.4.5
140
- signing_key:
166
+ rubygems_version: 3.0.3
167
+ signing_key:
141
168
  specification_version: 4
142
169
  summary: Command line tool for developing themes
143
170
  test_files: []