shopify-sinatra-app 0.0.1 → 0.0.2

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: ecb9d81878d71aa112a589d76932f041c53e1d9a
4
- data.tar.gz: 81d6eb212418d81c89fbad68595d3b6fdcde01b9
3
+ metadata.gz: 553b8af66b43f827feabdaafecbb73e36fd24ebb
4
+ data.tar.gz: 47b7c7fcf76e78fccfb081f74980ad5a989d591a
5
5
  SHA512:
6
- metadata.gz: a9738522aa12eec39f3b87267a0a72af1b01788dcdc0acba8280b83b53fabb28ae71dad9ef9a19329fd62f273ebf4abd014f9f07fbb7db3ee9dc61ba5997bad7
7
- data.tar.gz: 176f8fc34e159c4f01ea4eb9f5f779a6bc4ff29a85fab83562c8d78c01bb2448a9848cea1484b3960cb3bad5002208705bc622a518b8b152df82418e8fe5e644
6
+ metadata.gz: 6e1871bf85da48aa12e719f526603557796cd1881f6afbb9c421ed27159319fd3b389b281ed27777a0c98dfca4ddb403f5c4730021320a0b425014e8741e1530
7
+ data.tar.gz: 2dd73b4cc83692cc4edd42f0405bfc46caa0ac052066a1ac02a3e9c360d92bf0aeeb2e0f47ecf9618437ebcade35debff86911e8b055c45de057ceeb0235f7be
data/README.md CHANGED
@@ -58,6 +58,10 @@ This will create a new skeleton shopify-sinatra-app. The generator will create s
58
58
 
59
59
  You'll need to create a Shopify Partner Account and a new application. You can make an account [here](http://www.shopify.ca/partners) and see this [tutorial](http://docs.shopify.com/api/the-basics/getting-started) for creating a new application.
60
60
 
61
+ 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.
62
+
63
+ Also note that when developing locally you'll need to enable unsafe javascripts in your browser for the embedded sdk to function. Read more [here](http://docs.shopify.com/embedded-app-sdk/getting-started)
64
+
61
65
  After creating your new application you need to create a `.env` file and add the following lines:
62
66
 
63
67
  ```
@@ -121,7 +125,17 @@ end
121
125
  Deploying
122
126
  ---------
123
127
 
124
- This template was created with deploying to Heroku in mind. Heroku is a great cloud based app hosting provider that makes it incredibly easy to get an application into a product environment. To create a new heroku application download the [Heroku Toolbelt](https://devcenter.heroku.com/articles/quickstart) and create a new application:
128
+ This template was created with deploying to Heroku in mind. Heroku is a great cloud based app hosting provider that makes it incredibly easy to get an application into a product environment.
129
+
130
+ Before you can get started with Heroku you need to create a git repo for you application:
131
+
132
+ ```
133
+ git init
134
+ git add .
135
+ git commit -m "initial commit"
136
+ ```
137
+
138
+ Now you can create a new heroku application. Download the [Heroku Toolbelt](https://devcenter.heroku.com/articles/quickstart) and run the following command to create a new application:
125
139
 
126
140
  ```
127
141
  heroku apps:create <your new app name>
@@ -134,6 +148,26 @@ heroku addons:add heroku-postgresql
134
148
  heroku addons:add rediscloud
135
149
  ```
136
150
 
151
+ Now we can deploy the new application to Heroku. Deploying to Heroku is as simple as pushing the code using git:
152
+
153
+ ```
154
+ git push heroku master
155
+ ```
156
+
157
+ A `rake deploy2heroku` command is included in the generated Rakefile which does just this.
158
+
159
+ Now that our application is deployed we need to run `rake db:migrate` to initialize our database on Heroku. To do this run:
160
+
161
+ ```
162
+ heroku run rake db:migrate
163
+ ```
164
+
165
+ We also need to set our environment variables on Heroku. The environment variables are stored in `.env` and are not tracked by git. This is to protect your credentials in the case of a source control breach. Heroku provides a command to set environment variables: `heroku config:set VAR=foo`. In the generated Rakefile there is a helper method that will properly set all the variables in your `.env` file:
166
+
167
+ ```
168
+ rake creds2heroku
169
+ ```
170
+
137
171
  and make sure you have at least 1 dyno for web and resque:
138
172
 
139
173
  ```
@@ -142,6 +176,8 @@ heroku scale web=1 resque=1
142
176
 
143
177
  Note - if you are not using any background queue for processing webhooks then you do not need the redis add-on or the resque dyno so you can set it to 0.
144
178
 
179
+ Make sure you set your shopify apps url to your Heroku app url in the Shopify Partner area https://app.shopify.com/services/partners/api_clients.
180
+
145
181
  Contributing
146
182
  ------------
147
183
 
@@ -24,11 +24,12 @@ else
24
24
  FileUtils.cp_r(generator_dir + "/public", app_dir + "/public")
25
25
  FileUtils.cp_r(generator_dir + "/views", app_dir + "/views")
26
26
 
27
+ FileUtils.cp(generator_dir + "/.env", app_dir + "/.env")
27
28
  FileUtils.cp(generator_dir + "/config.ru", app_dir + "/config.ru")
28
29
  FileUtils.cp(generator_dir + "/Procfile", app_dir + "/Procfile")
29
30
  FileUtils.cp(generator_dir + "/Rakefile", app_dir + "/Rakefile")
30
- FileUtils.cp(generator_dir + "/Gemfile", app_dir + "/Gemfile")
31
- FileUtils.cp(generator_dir + "/README.md", app_dir + "/README.md")
31
+ FileUtils.cp(generator_dir + "/Gemfile", app_dir + "/Gemfile")
32
+ FileUtils.cp(generator_dir + "/README.md", app_dir + "/README.md")
32
33
 
33
34
  Dir.chdir(app_dir)
34
35
 
@@ -0,0 +1 @@
1
+ .env
@@ -3,46 +3,20 @@ require 'resque/tasks'
3
3
  require 'rake/testtask'
4
4
  require './lib/app'
5
5
 
6
- task :server do
7
- pipe = IO.popen("bundle exec rackup config.ru -p 4567")
8
- while (line = pipe.gets)
9
- print line
10
- end
6
+ task :creds2heroku do
7
+ Bundler.with_clean_env {
8
+ File.readlines('.env').each do |var|
9
+ pipe = IO.popen("heroku config:set #{var}")
10
+ while (line = pipe.gets)
11
+ print line
12
+ end
13
+ end
14
+ }
11
15
  end
12
16
 
13
- task :deploy do
17
+ task :deploy2heroku do
14
18
  pipe = IO.popen("git push heroku master --force")
15
19
  while (line = pipe.gets)
16
20
  print line
17
21
  end
18
22
  end
19
-
20
- task :clear do
21
- Rake::Task["clear_products"].invoke
22
- Rake::Task["clear_charities"].invoke
23
- Rake::Task["clear_shops"].invoke
24
- end
25
-
26
- task :clear_shops do
27
- Shop.delete_all
28
- end
29
-
30
- task :clear_charities do
31
- Charity.delete_all
32
- end
33
-
34
- task :clear_products do
35
- Product.delete_all
36
- end
37
-
38
- task :creds2heroku do
39
- Bundler.with_clean_env {
40
- api_key = `sed -n '1p' .env`
41
- shared_secret = `sed -n '2p' .env`
42
- secret = `sed -n '3p' .env`
43
-
44
- `heroku config:set #{api_key}`
45
- `heroku config:set #{shared_secret}`
46
- `heroku config:set #{secret}`
47
- }
48
- end
@@ -6,7 +6,7 @@ class SinatraApp < Sinatra::Base
6
6
  get '/' do
7
7
  # your app's Home page
8
8
  shopify_session do |shop_name|
9
- @shop = Shop.find_by(:name => shop_name)
9
+ @shop_name = shop_name
10
10
  @products = ShopifyAPI::Product.all(limit: 5)
11
11
  erb :home
12
12
  end
@@ -9,7 +9,7 @@
9
9
  <% @products.each do |product| %>
10
10
  <tr>
11
11
  <td>
12
- <a href=<%="https://#{@shop.name}/admin/products/#{product.product_id}"%> target="_blank"> <%= product.product_id %> </a>
12
+ <a href=<%="https://#{@shop_name}/admin/products/#{product.id}"%> target="_blank"> <%= product.id %> </a>
13
13
  </td>
14
14
  </tr>
15
15
  <% end %>
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'shopify-sinatra-app'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
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.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Hughes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-23 00:00:00.000000000 Z
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -234,6 +234,7 @@ files:
234
234
  - LICENSE
235
235
  - README.md
236
236
  - bin/shopify-sinatra-app-generator
237
+ - lib/generator/.gitignore
237
238
  - lib/generator/Gemfile
238
239
  - lib/generator/Procfile
239
240
  - lib/generator/README.md