shopify-sinatra-app 0.3.0 → 0.3.1

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
  SHA1:
3
- metadata.gz: 8eb803c14a147fef3795d5597e87493010740082
4
- data.tar.gz: d859264f939678dcfa015ed39c4eec2603285900
3
+ metadata.gz: ebf27b104b99f8d138a0c5c3c871cdc3edd9558c
4
+ data.tar.gz: 107fa00dc3e77b8f8f07ab5cb21b978b22863406
5
5
  SHA512:
6
- metadata.gz: 08194ed5b3a72721ec0330d067d105733c7ef4ab7e699914d0ca402cce0dff7d38446691ae61717521d914735db2ecb7c57ad7b07b39abf1affd0e3d64014dc3
7
- data.tar.gz: b76b46a294aaa30621da6edd4cb0022c1d5c58307e9b87a28696ce4c07d06adf42564fa0afb015f0883ee436639de66e0f64c30d89d403ce1edfb1dd9337f04d
6
+ metadata.gz: c1a134962895a415bfcc25b48d8ec1da62f1d861f2fd42799627edcecb3ef96dc9875639025851a5153e2e3a1cdfcbb61010feb1bda9ce112e4fe01860325a3f
7
+ data.tar.gz: b52f04425dff3d76ce9e1480b5080614e910320b8a0e3e23b464344bc3ba7c48b39f2bd610be39418827478427e6ede55b844e9048ff696e733f1bb380a8bd19
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.1.5
4
+ - 2.3.1
5
5
 
6
6
  gemfile: example/Gemfile
7
7
 
data/CHANGELOG CHANGED
@@ -1,3 +1,11 @@
1
+ 0.3.1
2
+ -----
3
+ * update authentication code for upcoming chrome changes.
4
+
5
+ 0.3.0
6
+ -----
7
+ * Remove sinatra-twitter-bootstrap dependency. Include css from cdn directly for example app.
8
+
1
9
  0.2.0
2
10
  -----
3
11
  * added a SHOPIFY_REDIRECT_URI env param for setting the redirect_uri (was breifly HOSTNAME)
data/README.md CHANGED
@@ -3,7 +3,8 @@ shopify-sinatra-app [![Build Status](https://travis-ci.org/kevinhughes27/shopify
3
3
 
4
4
  "A classy shopify app"
5
5
 
6
- shopify-sinatra-app is lightweight extension for building Shopify apps using Sinatra. It comes with the Shopify API gem for interacting with the Shopify API and uses the Shopify omniauth gem to handle authentication. The framework itself provides a handful of helper methods to make creating your app as easy as possible. The framework was designed with deployment to Heroku in mind and following the instructions below I've been able to create a new application from scratch, deploy it to Heroku and install on my live test shop in less than 5 minutes.
6
+ shopify-sinatra-app is lightweight extension for building Shopify apps using Sinatra. It comes with the Shopify API gem for interacting with the Shopify API and uses the Shopify omniauth gem to handle authentication via Oauth (other auth methods are not supported). The framework itself provides a handful of helper methods to make creating your app as easy as possible. The framework was designed with deployment to Heroku in mind and following the instructions below I've been able to create a new application from scratch, deploy it to Heroku and install on my live test shop in less than 5 minutes.
7
+
7
8
 
8
9
  Getting Started
9
10
  ---------------
@@ -66,12 +67,12 @@ After creating your new application you need to edit the `.env` file and add the
66
67
  ```
67
68
  SHOPIFY_API_KEY=<your api key>
68
69
  SHOPIFY_SHARED_SECRET=<your shared secret>
69
- SHOPIFY_REDIRECT_URI="<your redirect_uri>"
70
70
  SECRET=<generate a random string to encrypt credentials with>
71
71
  ```
72
72
 
73
73
  If your app has any other secret credentials you should add them to this file.
74
74
 
75
+
75
76
  Shopify::Methods
76
77
  ----------------
77
78
 
@@ -137,11 +138,10 @@ end
137
138
 
138
139
  note - a flash must be followed by a redirect or it won't work!
139
140
 
141
+
140
142
  Developing
141
143
  ----------
142
- You can set the application url in the [Shopify Partner area](https://app.shopify.com/services/partners/api_clients) to be `http://localhost:4567/` which will allow you to install your app on a live shop while running it locally.
143
-
144
- When developing locally you'll need to enable unsafe javascripts in your browser for the Embedded App SDK to function. Read more [here](http://docs.shopify.com/embedded-app-sdk/getting-started).
144
+ The embedded app sdk won't load non https content so you'll need to use a forwarding service like [ngrok](https://ngrok.com/) or [forwardhq](https://forwardhq.com/). Set your application url in the [Shopify Partner area](https://app.shopify.com/services/partners/api_clients) to your forwarded url. However The redirect_uri should still be `http://localhost:4567/auth/shopify/callback` which will allow you to install your app on a live shop while running it locally.
145
145
 
146
146
  To run the app locally we use `foreman` which comes with the [Heroku Toolbelt](https://devcenter.heroku.com/articles/quickstart). Foreman handles running our application and setting our credentials as environment variables. To run the application type:
147
147
 
@@ -153,13 +153,8 @@ Note - we use `foreman run ...` not `foreman start ...` because we only want to
153
153
 
154
154
  To debug your app simply add `require 'byebug'` at the top and then type `byebug` where you would like to drop into an interactive session. You may also want to try out [Pry](http://pryrepl.org/).
155
155
 
156
- While running the app locally you'll be able to test the install and other routes because your browser is aware of your local application but if you want to test a route that listens to a webhook this will not work because Shopify cannot talk to your local web application. You could expose your local application to the web but an easier solution is to use a tool called [Ngrok](https://ngrok.com/). Download Ngrok and run it on port 4567 (or whichever port you are using):
157
-
158
- ```
159
- ./ngrok 4567
160
- ```
156
+ If you are testing webhooks locally make sure they also go through the forwarded url and not `localhost`.
161
157
 
162
- Ngrok will report what address your app is available at, leave Ngrok running and then create your webhook to point to the ngrok url plus your route e.g. `<ngrok url>/webhook_test.json`. Now trigger the webhook you are testing and it will get forwarded through ngrok to your local web application allowing you to use debuggers and REPLs to complete your code.
163
158
 
164
159
  Testing
165
160
  -------
@@ -175,6 +170,7 @@ bundle exec rake test
175
170
 
176
171
  Checkout the contents of the `app_test.rb` file and the `test_helper.rb` and modify them as you add functionality to your app. You can also check the tests of other apps using this framework to see more about how to write tests for your own app.
177
172
 
173
+
178
174
  Deploying
179
175
  ---------
180
176
 
@@ -231,6 +227,7 @@ Note - if you are not using any background queue for processing webhooks then yo
231
227
 
232
228
  Make sure you set your shopify apps url to your Heroku app url (and make sure to use the `https` version or else the Embedded App SDK won't work) in the Shopify Partner area https://app.shopify.com/services/partners/api_clients.
233
229
 
230
+
234
231
  Apps using this framework
235
232
  -------------------------
236
233
 
@@ -238,6 +235,7 @@ Apps using this framework
238
235
  * [shopify-tax-receipts](https://github.com/pickle27/shopify-tax-receipts)
239
236
  * Add yours!
240
237
 
238
+
241
239
  Contributing
242
240
  ------------
243
241
 
@@ -1,7 +1,7 @@
1
1
  source 'https://rubygems.org'
2
- ruby "2.2.2"
2
+ ruby '2.3.1'
3
3
 
4
- gem 'shopify-sinatra-app', '~> 0.2.0'
4
+ gem 'shopify-sinatra-app', path: '../'
5
5
  gem 'sinatra-activerecord'
6
6
  gem 'rack-flash3', require: 'rack-flash'
7
7
 
@@ -1,3 +1,17 @@
1
+ PATH
2
+ remote: ../
3
+ specs:
4
+ shopify-sinatra-app (0.3.0)
5
+ activesupport (~> 4.1.1)
6
+ attr_encrypted (~> 1.3.2)
7
+ omniauth-shopify-oauth2 (~> 1.1.11)
8
+ rack-flash3 (~> 1.0.5)
9
+ resque (~> 1.25.2)
10
+ shopify_api (~> 4.0.2)
11
+ sinatra (~> 1.4.6)
12
+ sinatra-activerecord (~> 2.0.9)
13
+ sinatra-redis (~> 0.3.0)
14
+
1
15
  GEM
2
16
  remote: https://rubygems.org/
3
17
  specs:
@@ -8,10 +22,10 @@ GEM
8
22
  activemodel (= 4.1.14)
9
23
  activesupport (= 4.1.14)
10
24
  arel (~> 5.0.0)
11
- activeresource (4.0.0)
25
+ activeresource (4.1.0)
12
26
  activemodel (~> 4.0)
13
27
  activesupport (~> 4.0)
14
- rails-observers (~> 0.1.1)
28
+ rails-observers (~> 0.1.2)
15
29
  activesupport (4.1.14)
16
30
  i18n (~> 0.6, >= 0.6.9)
17
31
  json (~> 1.7, >= 1.7.7)
@@ -19,8 +33,8 @@ GEM
19
33
  thread_safe (~> 0.1)
20
34
  tzinfo (~> 1.1)
21
35
  arel (5.0.1.20140414130214)
22
- attr_encrypted (1.3.4)
23
- encryptor (>= 1.3.0)
36
+ attr_encrypted (1.3.5)
37
+ encryptor (~> 1.3.0)
24
38
  builder (3.2.2)
25
39
  byebug (8.2.1)
26
40
  dotenv (2.0.2)
@@ -30,31 +44,32 @@ GEM
30
44
  multipart-post (>= 1.2, < 3)
31
45
  foreman (0.78.0)
32
46
  thor (~> 0.19.1)
33
- hashie (3.4.3)
47
+ hashie (3.4.6)
34
48
  i18n (0.7.0)
35
49
  json (1.8.3)
36
- jwt (1.5.2)
50
+ jwt (1.5.1)
37
51
  metaclass (0.0.4)
38
52
  minitest (5.8.3)
39
53
  mocha (1.1.0)
40
54
  metaclass (~> 0.0.1)
41
55
  mono_logger (1.1.0)
42
- multi_json (1.11.2)
43
- multi_xml (0.5.5)
56
+ multi_json (1.12.1)
57
+ multi_xml (0.6.0)
44
58
  multipart-post (2.0.0)
45
- oauth2 (1.0.0)
59
+ oauth2 (1.1.0)
46
60
  faraday (>= 0.8, < 0.10)
47
- jwt (~> 1.0)
61
+ jwt (~> 1.0, < 1.5.2)
48
62
  multi_json (~> 1.3)
49
63
  multi_xml (~> 0.5)
50
- rack (~> 1.2)
51
- omniauth (1.2.2)
64
+ rack (>= 1.2, < 3)
65
+ omniauth (1.3.2)
52
66
  hashie (>= 1.2, < 4)
53
- rack (~> 1.0)
67
+ rack (>= 1.0, < 3)
54
68
  omniauth-oauth2 (1.4.0)
55
69
  oauth2 (~> 1.0)
56
70
  omniauth (~> 1.2)
57
- omniauth-shopify-oauth2 (1.1.11)
71
+ omniauth-shopify-oauth2 (1.1.16)
72
+ oauth2 (~> 1.1.0)
58
73
  omniauth-oauth2 (~> 1.2)
59
74
  pg (0.18.4)
60
75
  rack (1.6.4)
@@ -67,7 +82,7 @@ GEM
67
82
  rails-observers (0.1.2)
68
83
  activemodel (~> 4.0)
69
84
  rake (10.4.2)
70
- redis (3.2.2)
85
+ redis (3.3.2)
71
86
  redis-namespace (1.5.2)
72
87
  redis (~> 3.0, >= 3.0.4)
73
88
  resque (1.25.2)
@@ -76,17 +91,6 @@ GEM
76
91
  redis-namespace (~> 1.3)
77
92
  sinatra (>= 0.9.2)
78
93
  vegas (~> 0.1.2)
79
- shopify-sinatra-app (0.2.0)
80
- activesupport (~> 4.1.1)
81
- attr_encrypted (~> 1.3.2)
82
- omniauth-shopify-oauth2 (~> 1.1.11)
83
- rack-flash3 (~> 1.0.5)
84
- resque (~> 1.25.2)
85
- shopify_api (~> 4.0.2)
86
- sinatra (~> 1.4.6)
87
- sinatra-activerecord (~> 2.0.9)
88
- sinatra-redis (~> 0.3.0)
89
- sinatra-twitter-bootstrap (~> 2.3.3)
90
94
  shopify_api (4.0.7)
91
95
  activeresource
92
96
  rack
@@ -100,7 +104,6 @@ GEM
100
104
  sinatra-redis (0.3.0)
101
105
  redis
102
106
  sinatra (>= 0.9.4)
103
- sinatra-twitter-bootstrap (2.3.4)
104
107
  sqlite3 (1.3.11)
105
108
  thor (0.19.1)
106
109
  thread_safe (0.3.5)
@@ -124,9 +127,12 @@ DEPENDENCIES
124
127
  rack-flash3
125
128
  rack-test
126
129
  rake
127
- shopify-sinatra-app (~> 0.2.0)
130
+ shopify-sinatra-app!
128
131
  sinatra-activerecord
129
132
  sqlite3
130
133
 
134
+ RUBY VERSION
135
+ ruby 2.3.1p112
136
+
131
137
  BUNDLED WITH
132
- 1.11.2
138
+ 1.13.6
@@ -29,9 +29,11 @@
29
29
 
30
30
  <div class="container">
31
31
  <form role="form" class="form-large" action="/login" method="post">
32
- <div class="input-append">
33
- <input class="form-control form-wide" type="url" name="shop" placeholder="Shop URL">
34
- <input class="btn" type="submit" value="Install App" />
32
+ <div class="input-group form-wide">
33
+ <input class="form-control" type="url" name="shop" placeholder="Shop URL">
34
+ <span class="input-group-btn">
35
+ <input class="btn" type="submit" value="Install App" />
36
+ </span>
35
37
  </div>
36
38
  </form>
37
39
  </div>
@@ -87,9 +87,9 @@ module Sinatra
87
87
  end
88
88
 
89
89
  def authenticate(return_to = '/')
90
- if shop_name = sanitize_shop_param(params)
90
+ if shop_name = sanitized_shop_name
91
91
  redirect_url = "/auth/shopify?shop=#{shop_name}&return_to=#{base_url}#{return_to}"
92
- fullpage_redirect_to redirect_url
92
+ redirect_javascript redirect_url
93
93
  else
94
94
  redirect '/install'
95
95
  end
@@ -106,12 +106,38 @@ module Sinatra
106
106
  shop.save
107
107
  end
108
108
 
109
- def fullpage_redirect_to(redirect_url)
110
- @fullpage_redirect_to = redirect_url
109
+ def redirect_javascript(url)
110
+ erb %(
111
+ <!DOCTYPE html>
112
+ <html lang="en">
113
+ <head>
114
+ <meta charset="utf-8" />
115
+ <base target="_top">
116
+ <title>Redirecting…</title>
117
+
118
+ <script type='text/javascript'>
119
+ // If the current window is the 'parent', change the URL by setting location.href
120
+ if (window.top == window.self) {
121
+ window.top.location.href = #{url.to_json};
122
+
123
+ // If the current window is the 'child', change the parent's URL with postMessage
124
+ } else {
125
+ message = JSON.stringify({
126
+ message: 'Shopify.API.remoteRedirect',
127
+ data: { location: window.location.origin + #{url.to_json} }
128
+ });
129
+ window.parent.postMessage(message, 'https://#{sanitized_shop_name}');
130
+ }
131
+ </script>
132
+ </head>
133
+ <body>
134
+ </body>
135
+ </html>
136
+ %), layout: false
137
+ end
111
138
 
112
- erb "<script type='text/javascript'>
113
- window.top.location.href = '<%= @fullpage_redirect_to %>';
114
- </script>", layout: false
139
+ def sanitized_shop_name
140
+ @sanitized_shop_name ||= sanitize_shop_param(params)
115
141
  end
116
142
 
117
143
  def sanitize_shop_param(params)
@@ -179,7 +205,6 @@ module Sinatra
179
205
  provider :shopify,
180
206
  app.settings.api_key,
181
207
  app.settings.shared_secret,
182
- redirect_uri: app.settings.redirect_uri,
183
208
 
184
209
  scope: app.settings.scope,
185
210
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'shopify-sinatra-app'
3
- s.version = '0.3.0'
3
+ s.version = '0.3.1'
4
4
 
5
5
  s.summary = 'A classy shopify app'
6
6
  s.description = 'A Sinatra extension for building Shopify Apps. Akin to the shopify_app gem but for Sinatra'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify-sinatra-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Hughes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-07 00:00:00.000000000 Z
11
+ date: 2017-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -282,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
282
  version: '0'
283
283
  requirements: []
284
284
  rubyforge_project:
285
- rubygems_version: 2.4.5
285
+ rubygems_version: 2.5.1
286
286
  signing_key:
287
287
  specification_version: 4
288
288
  summary: A classy shopify app