shopify-sinatra-app 1.1.1 → 1.2.0
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/.circleci/config.yml +3 -3
- data/.gitignore +0 -2
- data/CHANGELOG +4 -0
- data/Gemfile.lock +116 -0
- data/README.md +3 -21
- data/example/Gemfile +1 -1
- data/example/Gemfile.lock +126 -0
- data/example/db/schema.rb +1 -2
- data/example/views/layouts/application.erb +0 -14
- data/lib/sinatra/shopify-sinatra-app.rb +1 -40
- data/shopify-sinatra-app.gemspec +6 -6
- metadata +23 -29
- data/example/views/_flash_messages.erb +0 -25
- data/example/views/_top_bar.erb +0 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8c0d855c21535c2d1915f2308110d3cb63346006da58d7d651d9669454acaab8
|
|
4
|
+
data.tar.gz: c51f8d793929ed69180a2bc61a97c1caf1f327d98a7507ba52e0f9f76aac3f16
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6118de76a19ddd7d3e1bd3592e6568d7957d03314ae81778cf95296ed6764f089415d91f10d168036839a0c2de4efb49de223d04d93e2fd8c4f18d28dee58bc
|
|
7
|
+
data.tar.gz: db1ebc67c55d9448258810975893053323d9bd2346a3ee4c39ebd2309fa43b07cb1222d43481a4388223c95497515cf59f6b3c9f7a6e5adb5f671d5a47b1f3e8
|
data/.circleci/config.yml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
version: 2.1
|
|
2
2
|
orbs:
|
|
3
|
-
ruby: circleci/ruby@0.
|
|
3
|
+
ruby: circleci/ruby@2.0.0
|
|
4
4
|
|
|
5
5
|
jobs:
|
|
6
6
|
build:
|
|
7
7
|
docker:
|
|
8
|
-
- image:
|
|
8
|
+
- image: cimg/ruby:2.7.7
|
|
9
9
|
executor: ruby/default
|
|
10
10
|
steps:
|
|
11
11
|
- checkout
|
|
12
|
-
- ruby/
|
|
12
|
+
- ruby/install-deps
|
|
13
13
|
- run:
|
|
14
14
|
name: Tests
|
|
15
15
|
command: ./bin/ci.sh
|
data/.gitignore
CHANGED
data/CHANGELOG
CHANGED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
shopify-sinatra-app (1.2.0)
|
|
5
|
+
activesupport
|
|
6
|
+
attr_encrypted
|
|
7
|
+
omniauth (>= 2.0.4)
|
|
8
|
+
omniauth-shopify-oauth2 (>= 2.3.2)
|
|
9
|
+
shopify_api (= 9.5.1)
|
|
10
|
+
sinatra
|
|
11
|
+
sinatra-activerecord
|
|
12
|
+
|
|
13
|
+
GEM
|
|
14
|
+
remote: https://rubygems.org/
|
|
15
|
+
specs:
|
|
16
|
+
activemodel (7.0.4.3)
|
|
17
|
+
activesupport (= 7.0.4.3)
|
|
18
|
+
activemodel-serializers-xml (1.0.2)
|
|
19
|
+
activemodel (> 5.x)
|
|
20
|
+
activesupport (> 5.x)
|
|
21
|
+
builder (~> 3.1)
|
|
22
|
+
activerecord (7.0.4.3)
|
|
23
|
+
activemodel (= 7.0.4.3)
|
|
24
|
+
activesupport (= 7.0.4.3)
|
|
25
|
+
activeresource (6.0.0)
|
|
26
|
+
activemodel (>= 6.0)
|
|
27
|
+
activemodel-serializers-xml (~> 1.0)
|
|
28
|
+
activesupport (>= 6.0)
|
|
29
|
+
activesupport (7.0.4.3)
|
|
30
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
31
|
+
i18n (>= 1.6, < 2)
|
|
32
|
+
minitest (>= 5.1)
|
|
33
|
+
tzinfo (~> 2.0)
|
|
34
|
+
attr_encrypted (4.0.0)
|
|
35
|
+
encryptor (~> 3.0.0)
|
|
36
|
+
builder (3.2.4)
|
|
37
|
+
concurrent-ruby (1.2.2)
|
|
38
|
+
encryptor (3.0.0)
|
|
39
|
+
fakeweb (1.3.0)
|
|
40
|
+
faraday (2.5.2)
|
|
41
|
+
faraday-net_http (>= 2.0, < 3.1)
|
|
42
|
+
ruby2_keywords (>= 0.0.4)
|
|
43
|
+
faraday-net_http (3.0.0)
|
|
44
|
+
graphql (2.0.21)
|
|
45
|
+
graphql-client (0.18.0)
|
|
46
|
+
activesupport (>= 3.0)
|
|
47
|
+
graphql
|
|
48
|
+
hashie (5.0.0)
|
|
49
|
+
i18n (1.12.0)
|
|
50
|
+
concurrent-ruby (~> 1.0)
|
|
51
|
+
jwt (2.5.0)
|
|
52
|
+
minitest (5.16.3)
|
|
53
|
+
mocha (2.0.2)
|
|
54
|
+
ruby2_keywords (>= 0.0.5)
|
|
55
|
+
multi_xml (0.6.0)
|
|
56
|
+
mustermann (3.0.0)
|
|
57
|
+
ruby2_keywords (~> 0.0.1)
|
|
58
|
+
oauth2 (2.0.9)
|
|
59
|
+
faraday (>= 0.17.3, < 3.0)
|
|
60
|
+
jwt (>= 1.0, < 3.0)
|
|
61
|
+
multi_xml (~> 0.5)
|
|
62
|
+
rack (>= 1.2, < 4)
|
|
63
|
+
snaky_hash (~> 2.0)
|
|
64
|
+
version_gem (~> 1.1)
|
|
65
|
+
omniauth (2.1.1)
|
|
66
|
+
hashie (>= 3.4.6)
|
|
67
|
+
rack (>= 2.2.3)
|
|
68
|
+
rack-protection
|
|
69
|
+
omniauth-oauth2 (1.8.0)
|
|
70
|
+
oauth2 (>= 1.4, < 3)
|
|
71
|
+
omniauth (~> 2.0)
|
|
72
|
+
omniauth-shopify-oauth2 (2.3.2)
|
|
73
|
+
activesupport
|
|
74
|
+
omniauth-oauth2 (~> 1.5)
|
|
75
|
+
rack (2.2.6.4)
|
|
76
|
+
rack-protection (3.0.6)
|
|
77
|
+
rack
|
|
78
|
+
rack-test (2.0.2)
|
|
79
|
+
rack (>= 1.3)
|
|
80
|
+
rake (13.0.6)
|
|
81
|
+
ruby2_keywords (0.0.5)
|
|
82
|
+
shopify_api (9.5.1)
|
|
83
|
+
activeresource (>= 4.1.0)
|
|
84
|
+
graphql-client
|
|
85
|
+
rack
|
|
86
|
+
sinatra (3.0.6)
|
|
87
|
+
mustermann (~> 3.0)
|
|
88
|
+
rack (~> 2.2, >= 2.2.4)
|
|
89
|
+
rack-protection (= 3.0.6)
|
|
90
|
+
tilt (~> 2.0)
|
|
91
|
+
sinatra-activerecord (2.0.26)
|
|
92
|
+
activerecord (>= 4.1)
|
|
93
|
+
sinatra (>= 1.0)
|
|
94
|
+
snaky_hash (2.0.1)
|
|
95
|
+
hashie
|
|
96
|
+
version_gem (~> 1.1, >= 1.1.1)
|
|
97
|
+
sqlite3 (1.6.2-x86_64-linux)
|
|
98
|
+
tilt (2.1.0)
|
|
99
|
+
tzinfo (2.0.6)
|
|
100
|
+
concurrent-ruby (~> 1.0)
|
|
101
|
+
version_gem (1.1.1)
|
|
102
|
+
|
|
103
|
+
PLATFORMS
|
|
104
|
+
x86_64-linux
|
|
105
|
+
|
|
106
|
+
DEPENDENCIES
|
|
107
|
+
fakeweb
|
|
108
|
+
minitest
|
|
109
|
+
mocha
|
|
110
|
+
rack-test
|
|
111
|
+
rake
|
|
112
|
+
shopify-sinatra-app!
|
|
113
|
+
sqlite3
|
|
114
|
+
|
|
115
|
+
BUNDLED WITH
|
|
116
|
+
2.4.12
|
data/README.md
CHANGED
|
@@ -44,13 +44,9 @@ This will create a new skeleton shopify-sinatra-app. The generator will create s
|
|
|
44
44
|
|
|
45
45
|
`Procfile` --> Specific for deploying to Heroku, this file tells heroku how to run the app
|
|
46
46
|
|
|
47
|
-
`public/icon.png` --> This icon file is used by the Shopify Embedded App SKD and is shown in the menu bar of your embedded app
|
|
48
|
-
|
|
49
47
|
`Rakefile` --> includes some helper methods etc for running and managing the app. Standard for ruby based projects
|
|
50
48
|
|
|
51
|
-
`views/layouts/appliction.erb` --> This is the layout file that all templates will use unless otherwise specified.
|
|
52
|
-
|
|
53
|
-
`views/_top_bar.erb` --> This is a partial view that describes the top bar inside a Shopify Embedded App. It also has some code to *forward* flash messages to the Embedded App SKD
|
|
49
|
+
`views/layouts/appliction.erb` --> This is the layout file that all templates will use unless otherwise specified.
|
|
54
50
|
|
|
55
51
|
`views/*` --> The other views used by the app. You'll probably make a lot of changes to home.erb and install.erb to customize the experience for your app
|
|
56
52
|
|
|
@@ -63,8 +59,6 @@ You'll need to create a Shopify Partner Account and a new application. You can m
|
|
|
63
59
|
* the default redirect_uri from omniauth `<your domain>/auth/shopify/callback`
|
|
64
60
|
* and `<your domain>/login`
|
|
65
61
|
|
|
66
|
-
Note - The shopify-sinatra-app creates an embedded app! You need change the embedded setting to `enabled` in the [Shopify Partner area](https://app.shopify.com/services/partners/api_clients) for your app. If you don't want your app to be embedded then remove the related code in `layout/application.erb` and delete the `layout/_top_bar.erb` file and the references to it in the other views.
|
|
67
|
-
|
|
68
62
|
After creating your new application you need to edit the `.env` file and add the following lines:
|
|
69
63
|
|
|
70
64
|
```
|
|
@@ -112,21 +106,11 @@ It's impossible to control the flow of webhooks to your app from Shopify especia
|
|
|
112
106
|
|
|
113
107
|
shopify-sinatra-app includes sinatra/activerecord for creating models that can be persisted in the database. You might want to read more about sinatra/activerecord and the methods it makes available to you: [https://github.com/janko-m/sinatra-activerecord](https://github.com/janko-m/sinatra-activerecord)
|
|
114
108
|
|
|
115
|
-
shopify-sinatra-app also includes `sinatra-flash` and the flash messages are forwarded to the Shopify Embedded App SDK (see the code in `views/layouts/application.erb`). Flash messages are useful for signalling to your users that a request was successful without changing the page. The following is an example of how to use a flash message in a route:
|
|
116
|
-
|
|
117
|
-
```ruby
|
|
118
|
-
post '/flash_message' do
|
|
119
|
-
flash[:notice] = "Flash Message!"
|
|
120
|
-
redirect '/'
|
|
121
|
-
end
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
note - a flash must be followed by a redirect or it won't work!
|
|
125
|
-
|
|
126
109
|
|
|
127
110
|
Developing
|
|
128
111
|
----------
|
|
129
|
-
|
|
112
|
+
|
|
113
|
+
The app needs to be accessible on the internet in order to receive webhooks so you'll need to use a real domain or a forwarding service like [ngrok](https://ngrok.com/). Set your application url in the [Shopify Partner area](https://app.shopify.com/services/partners/api_clients) to your forwarded url and set the redirect_uri to your forwarded url + `/auth/shopify/callback` which will allow you to install your app on a live shop while running it locally.
|
|
130
114
|
|
|
131
115
|
To run the app locally we use [overmind](https://github.com/DarthSim/overmind) a tool for running multiple process and setting our credentials as environment variables. To run the application run:
|
|
132
116
|
|
|
@@ -138,8 +122,6 @@ To connect to a single process to use a debugger/break point use `overmind conne
|
|
|
138
122
|
|
|
139
123
|
To debug your app add `require 'byebug'` at the top and then add `byebug` to your code where you would like to drop into an interactive session. You may also want to try out [Pry](http://pryrepl.org/).
|
|
140
124
|
|
|
141
|
-
If you are testing webhooks locally make sure they also go through the forwarded url and not `localhost`.
|
|
142
|
-
|
|
143
125
|
|
|
144
126
|
Testing
|
|
145
127
|
-------
|
data/example/Gemfile
CHANGED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ..
|
|
3
|
+
specs:
|
|
4
|
+
shopify-sinatra-app (1.1.1)
|
|
5
|
+
activesupport
|
|
6
|
+
attr_encrypted (>= 3.1, < 4.1)
|
|
7
|
+
omniauth (>= 2.0.4)
|
|
8
|
+
omniauth-shopify-oauth2 (>= 2.3.2)
|
|
9
|
+
shopify_api (>= 7.0.1, < 12.6)
|
|
10
|
+
sinatra (>= 2.2, < 3.1)
|
|
11
|
+
sinatra-activerecord (~> 2.0.9)
|
|
12
|
+
|
|
13
|
+
GEM
|
|
14
|
+
remote: https://rubygems.org/
|
|
15
|
+
specs:
|
|
16
|
+
activemodel (7.0.4.3)
|
|
17
|
+
activesupport (= 7.0.4.3)
|
|
18
|
+
activemodel-serializers-xml (1.0.2)
|
|
19
|
+
activemodel (> 5.x)
|
|
20
|
+
activesupport (> 5.x)
|
|
21
|
+
builder (~> 3.1)
|
|
22
|
+
activerecord (7.0.4.3)
|
|
23
|
+
activemodel (= 7.0.4.3)
|
|
24
|
+
activesupport (= 7.0.4.3)
|
|
25
|
+
activeresource (6.0.0)
|
|
26
|
+
activemodel (>= 6.0)
|
|
27
|
+
activemodel-serializers-xml (~> 1.0)
|
|
28
|
+
activesupport (>= 6.0)
|
|
29
|
+
activesupport (7.0.4.3)
|
|
30
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
31
|
+
i18n (>= 1.6, < 2)
|
|
32
|
+
minitest (>= 5.1)
|
|
33
|
+
tzinfo (~> 2.0)
|
|
34
|
+
attr_encrypted (4.0.0)
|
|
35
|
+
encryptor (~> 3.0.0)
|
|
36
|
+
builder (3.2.4)
|
|
37
|
+
byebug (11.1.3)
|
|
38
|
+
concurrent-ruby (1.2.2)
|
|
39
|
+
encryptor (3.0.0)
|
|
40
|
+
fakeweb (1.3.0)
|
|
41
|
+
faraday (2.7.2)
|
|
42
|
+
faraday-net_http (>= 2.0, < 3.1)
|
|
43
|
+
ruby2_keywords (>= 0.0.4)
|
|
44
|
+
faraday-net_http (3.0.2)
|
|
45
|
+
graphql (2.0.15)
|
|
46
|
+
graphql-client (0.18.0)
|
|
47
|
+
activesupport (>= 3.0)
|
|
48
|
+
graphql
|
|
49
|
+
hashie (5.0.0)
|
|
50
|
+
i18n (1.12.0)
|
|
51
|
+
concurrent-ruby (~> 1.0)
|
|
52
|
+
jwt (2.5.0)
|
|
53
|
+
minitest (5.18.0)
|
|
54
|
+
mocha (1.15.0)
|
|
55
|
+
multi_xml (0.6.0)
|
|
56
|
+
mustermann (2.0.2)
|
|
57
|
+
ruby2_keywords (~> 0.0.1)
|
|
58
|
+
oauth2 (2.0.9)
|
|
59
|
+
faraday (>= 0.17.3, < 3.0)
|
|
60
|
+
jwt (>= 1.0, < 3.0)
|
|
61
|
+
multi_xml (~> 0.5)
|
|
62
|
+
rack (>= 1.2, < 4)
|
|
63
|
+
snaky_hash (~> 2.0)
|
|
64
|
+
version_gem (~> 1.1)
|
|
65
|
+
omniauth (2.1.0)
|
|
66
|
+
hashie (>= 3.4.6)
|
|
67
|
+
rack (>= 2.2.3)
|
|
68
|
+
rack-protection
|
|
69
|
+
omniauth-oauth2 (1.8.0)
|
|
70
|
+
oauth2 (>= 1.4, < 3)
|
|
71
|
+
omniauth (~> 2.0)
|
|
72
|
+
omniauth-shopify-oauth2 (2.3.2)
|
|
73
|
+
activesupport
|
|
74
|
+
omniauth-oauth2 (~> 1.5)
|
|
75
|
+
pg (1.4.3)
|
|
76
|
+
rack (2.2.6.4)
|
|
77
|
+
rack-protection (2.2.4)
|
|
78
|
+
rack
|
|
79
|
+
rack-test (2.0.2)
|
|
80
|
+
rack (>= 1.3)
|
|
81
|
+
rake (13.0.6)
|
|
82
|
+
ruby2_keywords (0.0.5)
|
|
83
|
+
shopify_api (9.5.1)
|
|
84
|
+
activeresource (>= 4.1.0)
|
|
85
|
+
graphql-client
|
|
86
|
+
rack
|
|
87
|
+
sinatra (2.2.4)
|
|
88
|
+
mustermann (~> 2.0)
|
|
89
|
+
rack (~> 2.2)
|
|
90
|
+
rack-protection (= 2.2.4)
|
|
91
|
+
tilt (~> 2.0)
|
|
92
|
+
sinatra-activerecord (2.0.26)
|
|
93
|
+
activerecord (>= 4.1)
|
|
94
|
+
sinatra (>= 1.0)
|
|
95
|
+
sinatra-flash (0.3.0)
|
|
96
|
+
sinatra (>= 1.0.0)
|
|
97
|
+
snaky_hash (2.0.1)
|
|
98
|
+
hashie
|
|
99
|
+
version_gem (~> 1.1, >= 1.1.1)
|
|
100
|
+
sqlite3 (1.5.1-x86_64-linux)
|
|
101
|
+
tilt (2.0.11)
|
|
102
|
+
tzinfo (2.0.6)
|
|
103
|
+
concurrent-ruby (~> 1.0)
|
|
104
|
+
version_gem (1.1.1)
|
|
105
|
+
|
|
106
|
+
PLATFORMS
|
|
107
|
+
x86_64-linux
|
|
108
|
+
|
|
109
|
+
DEPENDENCIES
|
|
110
|
+
byebug
|
|
111
|
+
fakeweb
|
|
112
|
+
minitest
|
|
113
|
+
mocha
|
|
114
|
+
pg
|
|
115
|
+
rack-test
|
|
116
|
+
rake (>= 12.3.3)
|
|
117
|
+
shopify-sinatra-app!
|
|
118
|
+
sinatra-activerecord
|
|
119
|
+
sinatra-flash
|
|
120
|
+
sqlite3
|
|
121
|
+
|
|
122
|
+
RUBY VERSION
|
|
123
|
+
ruby 2.7.7p221
|
|
124
|
+
|
|
125
|
+
BUNDLED WITH
|
|
126
|
+
2.4.12
|
data/example/db/schema.rb
CHANGED
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
#
|
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
|
12
12
|
|
|
13
|
-
ActiveRecord::Schema.define(version: 2014_04_14_042317) do
|
|
14
|
-
|
|
13
|
+
ActiveRecord::Schema[7.0].define(version: 2014_04_14_042317) do
|
|
15
14
|
create_table "shops", force: :cascade do |t|
|
|
16
15
|
t.string "name"
|
|
17
16
|
t.string "token_encrypted"
|
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
|
-
<script src="https://unpkg.com/@shopify/app-bridge@3"></script>
|
|
5
|
-
<script type="text/javascript">
|
|
6
|
-
var AppBridge = window['app-bridge'];
|
|
7
|
-
|
|
8
|
-
var host = '<%= shop_host %>';
|
|
9
|
-
var apiKey = '<%= SinatraApp.settings.api_key %>';
|
|
10
|
-
|
|
11
|
-
var app = AppBridge.createApp({
|
|
12
|
-
apiKey: apiKey,
|
|
13
|
-
host: host
|
|
14
|
-
});
|
|
15
|
-
</script>
|
|
16
4
|
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-7s5uDGW3AHqw6xtJmNNtr+OBRJUlgkNJEo78P4b0yRw= sha512-nNo+yCHEyn0smMxSswnf/OnX6/KwJuZTlNZBjauKhTK0c+zT+q5JOCx0UFhXQ6rJR9jg6Es8gPuD2uZcYDLqSw==" crossorigin="anonymous">
|
|
17
5
|
</head>
|
|
18
6
|
|
|
19
7
|
<body>
|
|
20
8
|
<div class="container">
|
|
21
|
-
<%= erb :'_top_bar', layout: false, locals: locals %>
|
|
22
|
-
<%= erb :'_flash_messages', layout: false, locals: locals %>
|
|
23
9
|
<%= yield %>
|
|
24
10
|
</div>
|
|
25
11
|
</body>
|
|
@@ -15,11 +15,6 @@ module Sinatra
|
|
|
15
15
|
def after_shopify_auth
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
# for the app bridge initializer
|
|
19
|
-
def shop_host
|
|
20
|
-
"#{session[:shopify][:host]}"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
18
|
def shopify_session(&blk)
|
|
24
19
|
return_to = request.path
|
|
25
20
|
return_params = request.params
|
|
@@ -117,37 +112,6 @@ module Sinatra
|
|
|
117
112
|
end
|
|
118
113
|
end
|
|
119
114
|
|
|
120
|
-
# needs to be dynamic to incude the current shop
|
|
121
|
-
class ContentSecurityPolicy < Rack::Protection::Base
|
|
122
|
-
def csp_policy(env)
|
|
123
|
-
"frame-ancestors: #{current_shop(env)} https://admin.shopify.com;"
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def call(env)
|
|
127
|
-
status, headers, body = @app.call(env)
|
|
128
|
-
header = 'Content-Security-Policy'
|
|
129
|
-
headers[header] ||= csp_policy(env) if html? headers
|
|
130
|
-
[status, headers, body]
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
private
|
|
134
|
-
|
|
135
|
-
def current_shop(env)
|
|
136
|
-
s = session(env)
|
|
137
|
-
if s.has_key?("return_params")
|
|
138
|
-
"https://#{s["return_params"]["shop"]}"
|
|
139
|
-
elsif s.has_key?(:shopify)
|
|
140
|
-
"https://#{s[:shopify][:shop]}"
|
|
141
|
-
end
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def html?(headers)
|
|
145
|
-
return false unless (header = headers.detect { |k, _v| k.downcase == 'content-type' })
|
|
146
|
-
|
|
147
|
-
options[:html_types].include? header.last[%r{^\w+/\w+}]
|
|
148
|
-
end
|
|
149
|
-
end
|
|
150
|
-
|
|
151
115
|
def shopify_webhook(route, &blk)
|
|
152
116
|
settings.webhook_routes << route
|
|
153
117
|
post(route) do
|
|
@@ -166,8 +130,6 @@ module Sinatra
|
|
|
166
130
|
app.set :public_folder, File.expand_path('public')
|
|
167
131
|
app.enable :inline_templates
|
|
168
132
|
|
|
169
|
-
app.set :protection, except: :frame_options
|
|
170
|
-
|
|
171
133
|
app.set :api_version, '2019-07'
|
|
172
134
|
app.set :scope, 'read_products, read_orders'
|
|
173
135
|
|
|
@@ -188,8 +150,7 @@ module Sinatra
|
|
|
188
150
|
secret: app.settings.secret,
|
|
189
151
|
expire_after: 60 * 30 # half an hour in seconds
|
|
190
152
|
|
|
191
|
-
app.use
|
|
192
|
-
|
|
153
|
+
app.use Rack::Protection
|
|
193
154
|
app.use Rack::Protection::AuthenticityToken, allow_if: lambda { |env|
|
|
194
155
|
app.settings.webhook_routes.include?(env["PATH_INFO"])
|
|
195
156
|
}
|
data/shopify-sinatra-app.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'shopify-sinatra-app'
|
|
3
|
-
s.version = '1.
|
|
3
|
+
s.version = '1.2.0'
|
|
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'
|
|
@@ -13,16 +13,16 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.files = `git ls-files`.split("\n")
|
|
14
14
|
s.executables << 'shopify-sinatra-app-generator'
|
|
15
15
|
|
|
16
|
-
s.add_runtime_dependency 'sinatra'
|
|
17
|
-
s.add_runtime_dependency 'sinatra-activerecord'
|
|
16
|
+
s.add_runtime_dependency 'sinatra'
|
|
17
|
+
s.add_runtime_dependency 'sinatra-activerecord'
|
|
18
18
|
s.add_runtime_dependency 'activesupport'
|
|
19
|
-
s.add_runtime_dependency 'attr_encrypted'
|
|
19
|
+
s.add_runtime_dependency 'attr_encrypted'
|
|
20
20
|
|
|
21
|
-
s.add_runtime_dependency 'shopify_api', '
|
|
21
|
+
s.add_runtime_dependency 'shopify_api', '9.5.1'
|
|
22
22
|
s.add_runtime_dependency 'omniauth-shopify-oauth2', '>= 2.3.2'
|
|
23
23
|
s.add_runtime_dependency 'omniauth', '>= 2.0.4'
|
|
24
24
|
|
|
25
|
-
s.add_development_dependency 'rake'
|
|
25
|
+
s.add_development_dependency 'rake'
|
|
26
26
|
s.add_development_dependency 'sqlite3'
|
|
27
27
|
s.add_development_dependency 'minitest'
|
|
28
28
|
s.add_development_dependency 'rack-test'
|
metadata
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shopify-sinatra-app
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kevin Hughes
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-04-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sinatra
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: '0'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: sinatra-activerecord
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: '0'
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: activesupport
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -56,36 +56,30 @@ dependencies:
|
|
|
56
56
|
name: attr_encrypted
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- - "
|
|
59
|
+
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: '0'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- - "
|
|
66
|
+
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: shopify_api
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- -
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: 7.0.1
|
|
76
|
-
- - "<"
|
|
73
|
+
- - '='
|
|
77
74
|
- !ruby/object:Gem::Version
|
|
78
|
-
version:
|
|
75
|
+
version: 9.5.1
|
|
79
76
|
type: :runtime
|
|
80
77
|
prerelease: false
|
|
81
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
82
79
|
requirements:
|
|
83
|
-
- -
|
|
84
|
-
- !ruby/object:Gem::Version
|
|
85
|
-
version: 7.0.1
|
|
86
|
-
- - "<"
|
|
80
|
+
- - '='
|
|
87
81
|
- !ruby/object:Gem::Version
|
|
88
|
-
version:
|
|
82
|
+
version: 9.5.1
|
|
89
83
|
- !ruby/object:Gem::Dependency
|
|
90
84
|
name: omniauth-shopify-oauth2
|
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -120,14 +114,14 @@ dependencies:
|
|
|
120
114
|
requirements:
|
|
121
115
|
- - ">="
|
|
122
116
|
- !ruby/object:Gem::Version
|
|
123
|
-
version:
|
|
117
|
+
version: '0'
|
|
124
118
|
type: :development
|
|
125
119
|
prerelease: false
|
|
126
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
127
121
|
requirements:
|
|
128
122
|
- - ">="
|
|
129
123
|
- !ruby/object:Gem::Version
|
|
130
|
-
version:
|
|
124
|
+
version: '0'
|
|
131
125
|
- !ruby/object:Gem::Dependency
|
|
132
126
|
name: sqlite3
|
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -211,12 +205,14 @@ files:
|
|
|
211
205
|
- ".gitignore"
|
|
212
206
|
- CHANGELOG
|
|
213
207
|
- Gemfile
|
|
208
|
+
- Gemfile.lock
|
|
214
209
|
- LICENSE
|
|
215
210
|
- README.md
|
|
216
211
|
- bin/ci.sh
|
|
217
212
|
- bin/shopify-sinatra-app-generator
|
|
218
213
|
- example/.gitignore
|
|
219
214
|
- example/Gemfile
|
|
215
|
+
- example/Gemfile.lock
|
|
220
216
|
- example/Procfile
|
|
221
217
|
- example/README.md
|
|
222
218
|
- example/Rakefile
|
|
@@ -231,8 +227,6 @@ files:
|
|
|
231
227
|
- example/src/app.rb
|
|
232
228
|
- example/test/app_test.rb
|
|
233
229
|
- example/test/test_helper.rb
|
|
234
|
-
- example/views/_flash_messages.erb
|
|
235
|
-
- example/views/_top_bar.erb
|
|
236
230
|
- example/views/home.erb
|
|
237
231
|
- example/views/layouts/application.erb
|
|
238
232
|
- example/views/login.erb
|
|
@@ -257,7 +251,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
257
251
|
- !ruby/object:Gem::Version
|
|
258
252
|
version: '0'
|
|
259
253
|
requirements: []
|
|
260
|
-
rubygems_version: 3.
|
|
254
|
+
rubygems_version: 3.4.6
|
|
261
255
|
signing_key:
|
|
262
256
|
specification_version: 4
|
|
263
257
|
summary: A classy shopify app
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<script type="text/javascript">
|
|
2
|
-
var AppBridge = window['app-bridge'];
|
|
3
|
-
|
|
4
|
-
var actions = AppBridge.actions;
|
|
5
|
-
var Toast = actions.Toast;
|
|
6
|
-
|
|
7
|
-
<% if flash[:notice] %>
|
|
8
|
-
var notice = Toast.create(app, {
|
|
9
|
-
message: "<%= flash[:notice] %>",
|
|
10
|
-
duration: 5000
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
notice.dispatch(Toast.Action.SHOW);
|
|
14
|
-
<% end %>
|
|
15
|
-
|
|
16
|
-
<% if flash[:error] %>
|
|
17
|
-
var notice = Toast.create(app, {
|
|
18
|
-
message: "<%= flash[:error] %>",
|
|
19
|
-
duration: 5000,
|
|
20
|
-
isError: true,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
notice.dispatch(Toast.Action.SHOW);
|
|
24
|
-
<% end %>
|
|
25
|
-
</script>
|
data/example/views/_top_bar.erb
DELETED