-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class HomeController < ShopifyApp::AuthenticatedController | ||
def index | ||
@products = ShopifyAPI::Product.find(:all, params: { limit: 10 }) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class Shop < ActiveRecord::Base | ||
include ShopifyApp::Shop | ||
include ShopifyApp::SessionStorage | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<% content_for :javascript do %> | ||
<script type="text/javascript"> | ||
ShopifyApp.ready(function(){ | ||
ShopifyApp.Bar.initialize({ | ||
title: "Home", | ||
icon: "<%= asset_path('favicon.ico') %>" | ||
}); | ||
}); | ||
</script> | ||
<% end %> | ||
|
||
<h2>Products</h2> | ||
|
||
<ul> | ||
<% @products.each do |product| %> | ||
<li><%= link_to product.title, "https://#{@shop_session.url}/admin/products/#{product.id}", target: "_top" %></li> | ||
<% end %> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<% content_for :javascript do %> | ||
<script type="text/javascript"> | ||
var eventName = typeof(Turbolinks) !== 'undefined' ? 'page:change' : 'DOMContentLoaded'; | ||
|
||
document.addEventListener(eventName, function() { | ||
<% if flash[:notice] %> | ||
ShopifyApp.flashNotice("<%= j flash[:notice].html_safe %>"); | ||
<% end %> | ||
|
||
<% if flash[:error] %> | ||
ShopifyApp.flashError("<%= j flash[:error].html_safe %>"); | ||
<% end %> | ||
}); | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<% application_name = ShopifyApp.configuration.application_name %> | ||
<title><%= application_name %></title> | ||
<%= stylesheet_link_tag 'application' %> | ||
<%= javascript_include_tag 'application', "data-turbolinks-track" => true %> | ||
<%= csrf_meta_tags %> | ||
</head> | ||
|
||
<body> | ||
<div class="app-wrapper"> | ||
<div class="app-content"> | ||
<main role="main"> | ||
<%= yield %> | ||
</main> | ||
</div> | ||
</div> | ||
|
||
<%= render 'layouts/flash_messages' %> | ||
|
||
<script src="https://cdn.shopify.com/s/assets/external/app.js?<%= Time.now.strftime('%Y%m%d%H') %>"></script> | ||
|
||
<script type="text/javascript"> | ||
ShopifyApp.init({ | ||
apiKey: "<%= ShopifyApp.configuration.api_key %>", | ||
shopOrigin: "<%= "https://#{ @shop_session.url }" if @shop_session %>", | ||
debug: <%= Rails.env.development? ? 'true' : 'false' %>, | ||
forceRedirect: true | ||
}); | ||
</script> | ||
|
||
<% if content_for?(:javascript) %> | ||
<div id="ContentForJavascript" data-turbolinks-temporary> | ||
<%= yield :javascript %> | ||
</div> | ||
<% end %> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Rails.application.config.middleware.use OmniAuth::Builder do | ||
provider :shopify, | ||
ShopifyApp.configuration.api_key, | ||
ShopifyApp.configuration.secret, | ||
scope: ShopifyApp.configuration.scope | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
ShopifyApp.configure do |config| | ||
config.application_name = "My Shopify App" | ||
config.api_key = "5857c42a164d7b0fb38ef5464bd9ec0e" | ||
config.secret = "c23568d568a5e83d7fbcfc6addba3367" | ||
config.scope = "read_orders, read_products" | ||
config.embedded_app = true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
if Rails.configuration.cache_classes | ||
ShopifyApp::SessionRepository.storage = Shop | ||
else | ||
reloader = defined?(ActiveSupport::Reloader) ? ActiveSupport::Reloader : ActionDispatch::Reloader | ||
|
||
reloader.to_prepare do | ||
ShopifyApp::SessionRepository.storage = Shop | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Rails.application.routes.draw do | ||
root :to => 'home#index' | ||
mount ShopifyApp::Engine, at: '/' | ||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class CreateShops < ActiveRecord::Migration[5.1] | ||
def self.up | ||
create_table :shops do |t| | ||
t.string :shopify_domain, null: false | ||
t.string :shopify_token, null: false | ||
t.timestamps | ||
end | ||
|
||
add_index :shops, :shopify_domain, unique: true | ||
end | ||
|
||
def self.down | ||
drop_table :shops | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
regular_shop: | ||
shopify_domain: 'regular-shop.myshopify.com' | ||
shopify_token: 'token' |