disco_app 0.6.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +37 -0
  3. data/app/assets/images/disco_app/icon.svg +1 -0
  4. data/app/assets/javascripts/disco_app/components/shopify_admin_link.js.jsx +29 -0
  5. data/app/assets/javascripts/disco_app/components.js +5 -0
  6. data/app/assets/javascripts/disco_app/disco_app.js +7 -0
  7. data/app/assets/javascripts/disco_app/frame.js +152 -0
  8. data/app/assets/javascripts/disco_app/shopify-turbolinks.js +7 -0
  9. data/app/assets/stylesheets/disco_app/bootstrap/_custom.scss +54 -0
  10. data/app/assets/stylesheets/disco_app/bootstrap/_variables.scss +872 -0
  11. data/app/assets/stylesheets/disco_app/disco/_buttons.scss +31 -0
  12. data/app/assets/stylesheets/disco_app/disco/_cards.scss +51 -0
  13. data/app/assets/stylesheets/disco_app/disco/_forms.scss +23 -0
  14. data/app/assets/stylesheets/disco_app/disco/_grid.scss +58 -0
  15. data/app/assets/stylesheets/disco_app/disco/_sections.scss +61 -0
  16. data/app/assets/stylesheets/disco_app/disco/_tables.scss +57 -0
  17. data/app/assets/stylesheets/disco_app/disco/_tabs.scss +61 -0
  18. data/app/assets/stylesheets/disco_app/disco/_type.scss +39 -0
  19. data/app/assets/stylesheets/disco_app/disco/mixins/_flexbox.scss +394 -0
  20. data/app/assets/stylesheets/disco_app/disco_app.scss +16 -0
  21. data/app/assets/stylesheets/disco_app/frame/_buttons.scss +54 -0
  22. data/app/assets/stylesheets/disco_app/frame/_forms.scss +26 -0
  23. data/app/assets/stylesheets/disco_app/frame/_layout.scss +77 -0
  24. data/app/assets/stylesheets/disco_app/frame/_type.scss +32 -0
  25. data/app/assets/stylesheets/disco_app/frame.scss +9 -0
  26. data/app/controllers/disco_app/app_proxy_controller.rb +41 -0
  27. data/app/controllers/disco_app/authenticated_controller.rb +44 -0
  28. data/app/controllers/disco_app/carrier_request_controller.rb +28 -0
  29. data/app/controllers/disco_app/charges_controller.rb +30 -0
  30. data/app/controllers/disco_app/frame_controller.rb +9 -0
  31. data/app/controllers/disco_app/install_controller.rb +26 -0
  32. data/app/controllers/disco_app/webhooks_controller.rb +42 -0
  33. data/app/helpers/disco_app/application_helper.rb +28 -0
  34. data/app/jobs/disco_app/app_installed_job.rb +3 -0
  35. data/app/jobs/disco_app/app_uninstalled_job.rb +3 -0
  36. data/app/jobs/disco_app/concerns/app_installed_job.rb +22 -0
  37. data/app/jobs/disco_app/concerns/app_uninstalled_job.rb +20 -0
  38. data/app/jobs/disco_app/concerns/shop_update_job.rb +16 -0
  39. data/app/jobs/disco_app/concerns/synchronise_carrier_service_job.rb +51 -0
  40. data/app/jobs/disco_app/concerns/synchronise_webhooks_job.rb +53 -0
  41. data/app/jobs/disco_app/shop_job.rb +27 -0
  42. data/app/jobs/disco_app/shop_update_job.rb +3 -0
  43. data/app/jobs/disco_app/synchronise_carrier_service_job.rb +3 -0
  44. data/app/jobs/disco_app/synchronise_webhooks_job.rb +3 -0
  45. data/app/models/disco_app/concerns/plan.rb +14 -0
  46. data/app/models/disco_app/concerns/shop.rb +68 -0
  47. data/app/models/disco_app/concerns/subscription.rb +14 -0
  48. data/app/models/disco_app/plan.rb +3 -0
  49. data/app/models/disco_app/session_storage.rb +18 -0
  50. data/app/models/disco_app/shop.rb +3 -0
  51. data/app/models/disco_app/subscription.rb +3 -0
  52. data/app/services/disco_app/charges_service.rb +73 -0
  53. data/app/services/disco_app/subscription_service.rb +25 -0
  54. data/app/services/disco_app/webhook_service.rb +30 -0
  55. data/app/views/disco_app/charges/activate.html.erb +1 -0
  56. data/app/views/disco_app/charges/create.html.erb +1 -0
  57. data/app/views/disco_app/charges/new.html.erb +45 -0
  58. data/app/views/disco_app/frame/frame.html.erb +36 -0
  59. data/app/views/disco_app/install/installing.html.erb +7 -0
  60. data/app/views/disco_app/install/uninstalling.html.erb +1 -0
  61. data/app/views/disco_app/proxy_errors/404.html.erb +1 -0
  62. data/app/views/disco_app/shared/_card.html.erb +14 -0
  63. data/app/views/disco_app/shared/_section.html.erb +17 -0
  64. data/app/views/layouts/application.html.erb +18 -0
  65. data/app/views/layouts/embedded_app.html.erb +41 -0
  66. data/app/views/layouts/embedded_app_modal.html.erb +17 -0
  67. data/app/views/sessions/new.html.erb +26 -0
  68. data/config/routes.rb +26 -0
  69. data/db/migrate/20150525000000_create_shops_if_not_existent.rb +15 -0
  70. data/db/migrate/20150525162112_add_status_to_shops.rb +5 -0
  71. data/db/migrate/20150525171422_add_meta_to_shops.rb +11 -0
  72. data/db/migrate/20150629210346_add_charge_status_to_shop.rb +5 -0
  73. data/db/migrate/20150814214025_add_more_meta_to_shops.rb +15 -0
  74. data/db/migrate/20151017231302_create_disco_app_plans.rb +13 -0
  75. data/db/migrate/20151017232027_create_disco_app_subscriptions.rb +15 -0
  76. data/db/migrate/20151017234409_move_shop_to_disco_app_engine.rb +5 -0
  77. data/lib/disco_app/engine.rb +23 -0
  78. data/lib/disco_app/support/file_fixtures.rb +23 -0
  79. data/lib/disco_app/test_help.rb +11 -0
  80. data/lib/disco_app/version.rb +3 -0
  81. data/lib/disco_app.rb +4 -0
  82. data/lib/generators/disco_app/USAGE +5 -0
  83. data/lib/generators/disco_app/disco_app_generator.rb +154 -0
  84. data/lib/generators/disco_app/mailify/mailify_generator.rb +54 -0
  85. data/lib/generators/disco_app/reactify/reactify_generator.rb +45 -0
  86. data/lib/generators/disco_app/templates/assets/javascripts/application.js +17 -0
  87. data/lib/generators/disco_app/templates/assets/stylesheets/application.scss +5 -0
  88. data/lib/generators/disco_app/templates/config/puma.rb +15 -0
  89. data/lib/generators/disco_app/templates/controllers/home_controller.rb +7 -0
  90. data/lib/generators/disco_app/templates/initializers/disco_app.rb +1 -0
  91. data/lib/generators/disco_app/templates/initializers/shopify_app.rb +7 -0
  92. data/lib/generators/disco_app/templates/initializers/shopify_session_repository.rb +7 -0
  93. data/lib/generators/disco_app/templates/root/Procfile +2 -0
  94. data/lib/generators/disco_app/templates/views/home/index.html.erb +2 -0
  95. data/lib/tasks/carrier_service.rake +10 -0
  96. data/lib/tasks/start.rake +3 -0
  97. data/lib/tasks/webhooks.rake +10 -0
  98. data/test/controllers/disco_app/install_controller_test.rb +50 -0
  99. data/test/controllers/disco_app/webhooks_controller_test.rb +58 -0
  100. data/test/controllers/home_controller_test.rb +61 -0
  101. data/test/disco_app_test.rb +7 -0
  102. data/test/dummy/Rakefile +6 -0
  103. data/test/dummy/app/assets/javascripts/application.js +17 -0
  104. data/test/dummy/app/assets/stylesheets/application.scss +5 -0
  105. data/test/dummy/app/controllers/application_controller.rb +6 -0
  106. data/test/dummy/app/controllers/home_controller.rb +7 -0
  107. data/test/dummy/app/helpers/application_helper.rb +2 -0
  108. data/test/dummy/app/jobs/disco_app/app_uninstalled_job.rb +11 -0
  109. data/test/dummy/app/models/disco_app/shop.rb +15 -0
  110. data/test/dummy/app/views/home/index.html.erb +2 -0
  111. data/test/dummy/bin/bundle +3 -0
  112. data/test/dummy/bin/rails +4 -0
  113. data/test/dummy/bin/rake +4 -0
  114. data/test/dummy/bin/setup +29 -0
  115. data/test/dummy/config/application.rb +37 -0
  116. data/test/dummy/config/boot.rb +5 -0
  117. data/test/dummy/config/database.yml +25 -0
  118. data/test/dummy/config/environment.rb +5 -0
  119. data/test/dummy/config/environments/development.rb +41 -0
  120. data/test/dummy/config/environments/production.rb +85 -0
  121. data/test/dummy/config/environments/test.rb +42 -0
  122. data/test/dummy/config/initializers/assets.rb +11 -0
  123. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  124. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  125. data/test/dummy/config/initializers/disco_app.rb +1 -0
  126. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  127. data/test/dummy/config/initializers/inflections.rb +16 -0
  128. data/test/dummy/config/initializers/mime_types.rb +4 -0
  129. data/test/dummy/config/initializers/omniauth.rb +9 -0
  130. data/test/dummy/config/initializers/session_store.rb +3 -0
  131. data/test/dummy/config/initializers/shopify_app.rb +7 -0
  132. data/test/dummy/config/initializers/shopify_session_repository.rb +7 -0
  133. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  134. data/test/dummy/config/locales/en.yml +23 -0
  135. data/test/dummy/config/routes.rb +8 -0
  136. data/test/dummy/config/secrets.yml +22 -0
  137. data/test/dummy/config.ru +4 -0
  138. data/test/dummy/db/schema.rb +70 -0
  139. data/test/dummy/public/404.html +67 -0
  140. data/test/dummy/public/422.html +67 -0
  141. data/test/dummy/public/500.html +66 -0
  142. data/test/dummy/public/favicon.ico +0 -0
  143. data/test/fixtures/api/widget_store/shop.json +46 -0
  144. data/test/fixtures/api/widget_store/webhooks.json +1 -0
  145. data/test/fixtures/disco_app/plans.yml +32 -0
  146. data/test/fixtures/disco_app/shops.yml +10 -0
  147. data/test/fixtures/disco_app/subscriptions.yml +26 -0
  148. data/test/fixtures/webhooks/app_uninstalled.json +46 -0
  149. data/test/integration/navigation_test.rb +10 -0
  150. data/test/jobs/disco_app/app_installed_job_test.rb +30 -0
  151. data/test/jobs/disco_app/app_uninstalled_job_test.rb +32 -0
  152. data/test/models/disco_app/plan_test.rb +5 -0
  153. data/test/models/disco_app/shop_test.rb +26 -0
  154. data/test/models/disco_app/subscription_test.rb +6 -0
  155. data/test/services/disco_app/subscription_service_test.rb +28 -0
  156. data/test/support/test_file_fixtures.rb +29 -0
  157. data/test/test_helper.rb +51 -0
  158. metadata +484 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a50699ff4ae93838aa2c37aaf47a16551f0c729d1f41cb54f10b8e82ac5d6088
4
+ data.tar.gz: 00f838a1b2f9f2c8726fafede84074c55c421e93e07c1d444c2cb6aa58eb0512
5
+ SHA512:
6
+ metadata.gz: ce2ab79fc07af31d63ebfcbfe68a173e18eeca434a2fd12a333e9fceb60381fc64ba4c73d0bf8963659208ba8512907f8391ad9ae8e19e06c23bd7ef7fd84c8b
7
+ data.tar.gz: ca19c5f680719e52e92b3eefd9713d18ddad1e22446582c15b37401428a93de06bb55fb0c3a23e327e0f54d2dde61889ce7d33495ffd0261b93eb64efd8032d9
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'DiscoApp'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><style>.st0{fill:#231F20;} .st1{fill:#FBAF41;} .st2{fill:#8676D5;} .st3{fill:#9CCC6B;} .st4{fill:#FBCC6B;} .st5{fill:#9CCCD5;} .st6{fill:#FFFFFF;}</style><path id="XMLID_7_" class="st0" d="M12 24l-5.2-3-5.2-3V6l5.2-3L12 0l5.2 3 5.2 3v12l-5.2 3-5.2 3z"/><path id="XMLID_6_" class="st1" d="M2.9 6.8v10.4h18.2z"/><path id="XMLID_5_" class="st2" d="M2.9 17.2h18.2V6.8z"/><path id="XMLID_4_" class="st3" d="M21.1 17.2L12 1.5 2.9 17.2z"/><path id="XMLID_3_" class="st4" d="M7.5 9.4l-4.6 7.8h18.2z"/><path id="XMLID_2_" class="st5" d="M2.9 17.2h18.2l-4.6-7.8z"/><path id="XMLID_1_" class="st6" d="M12 12l-9.1 5.2 9.1 5.3 9.1-5.3z"/></svg>
@@ -0,0 +1,29 @@
1
+ /**
2
+ * ShopifyAdminLink
3
+ *
4
+ * Renders a link pointing to an object (such as an order or customer) inside
5
+ * the given shop's Shopify admin. This helper makes it easy to create links
6
+ * to objects within the admin that support both right-clicking and opening in
7
+ * a new tab as well as capturing a left click and redirecting to the relevant
8
+ * object using `ShopifyApp.redirect()`.
9
+ *
10
+ * This component is the React equivalent to the link_to_shopify_admin helper
11
+ * found in app/helpers/disco_app/application_helper.rb.
12
+ */
13
+ var ShopifyAdminLink = React.createClass({
14
+
15
+ handleClick: function(e) {
16
+ e.preventDefault();
17
+ ShopifyApp.redirect(this.props.href);
18
+ },
19
+
20
+ render: function() {
21
+ var href = '/admin' + this.props.href;
22
+ return (
23
+ <a className={this.props.className} href={href} onClick={this.handleClick}>
24
+ {this.props.label}
25
+ </a>
26
+ )
27
+ }
28
+
29
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * disco_app/components.js
3
+ * React components common to Disco applications.
4
+ */
5
+ //= require_tree ./components
@@ -0,0 +1,7 @@
1
+ /**
2
+ * disco_app/disco_app.js
3
+ * Base Javascript for Disco applications.
4
+ * Assumes that jQuery will be loaded in the parent application.js.
5
+ */
6
+ //= require bootstrap-sprockets
7
+ //= require disco_app/shopify-turbolinks
@@ -0,0 +1,152 @@
1
+ /**
2
+ * frame.js
3
+ *
4
+ * The FrameApp object is a lightweight Javascript object intended to mock the `postMessage` endpoint for Embedded Apps
5
+ * in the Shopify Admin panel. Eventually, we hope to mock all of the functionality provided by the Shopify Embedded App
6
+ * SDK.
7
+ */
8
+ (function() {
9
+
10
+ window.FrameApp = (function() {
11
+
12
+ FrameApp.name = 'Shopify Dev Frame';
13
+
14
+ function FrameApp() {}
15
+
16
+
17
+ /* Initialisation, configuration and helpers.
18
+ ================================================== */
19
+
20
+ /**
21
+ * Initialise the FrameApp - load configuration, set up event handlers.
22
+ *
23
+ * @param config
24
+ * @returns {*}
25
+ */
26
+ FrameApp.init = function(config) {
27
+ var _this = this;
28
+ if (config == null) {
29
+ config = {};
30
+ }
31
+ this.loadConfig(config);
32
+
33
+ // Use addEventListener if available, otherwise fall back to attachEvent.
34
+ if (window.addEventListener) {
35
+ this.iframe.addEventListener("load", FrameApp.__iframeLoadCallback, false);
36
+ return window.addEventListener("message", FrameApp.__addEventMessageCallback, false);
37
+ }
38
+
39
+ this.iframe.attachEvent("load", FrameApp.__iframeLoadCallback);
40
+ return window.attachEvent("onMessage", FrameApp.__addEventMessageCallback);
41
+ };
42
+
43
+ /**
44
+ * Load configuration for the FrameApp. Set defaults if not provided.
45
+ * @param config
46
+ */
47
+ FrameApp.loadConfig = function(config) {
48
+ this.shopOrigin = config.shopOrigin;
49
+ this.debug = !!config.debug;
50
+ this.iframe = config.iframe;
51
+ if (!this.iframe) {
52
+ this.log("FrameApp error: no <iframe> specified.");
53
+ }
54
+ FrameApp.log('FrameApp configuration loaded.');
55
+ };
56
+
57
+ /**
58
+ * Log a message to the console, if the app was configured in debug mode.
59
+ *
60
+ * @param message
61
+ * @param force
62
+ * @returns {*}
63
+ */
64
+ FrameApp.log = function(message, force) {
65
+ if ((typeof console !== "undefined" && console !== null ? console.log : void 0) && (this.debug || force)) {
66
+ return console.log(message);
67
+ }
68
+ };
69
+
70
+
71
+ /* Message sending and event handling.
72
+ ================================================== */
73
+
74
+ FrameApp.__messageHandlers = {};
75
+
76
+ /**
77
+ * Post a message to the <iframe>.
78
+ *
79
+ * @param message
80
+ * @param data
81
+ * @returns {*}
82
+ */
83
+ FrameApp.postMessage = function(message, data) {
84
+ var json;
85
+ json = JSON.stringify({
86
+ message: message,
87
+ data: data
88
+ });
89
+ FrameApp.log("FrameApp client sent " + json + " to ShopifyApp.");
90
+ return this.iframe.contentWindow.postMessage(json, '*');
91
+ };
92
+
93
+ /**
94
+ * Add a handler for a received message.
95
+ *
96
+ * @param message
97
+ * @param fn
98
+ * @returns {Number|*}
99
+ * @private
100
+ */
101
+ FrameApp.__addMessageHandler = function(message, fn) {
102
+ if (typeof message === "function") {
103
+ fn = message;
104
+ message = void 0;
105
+ }
106
+ if (!FrameApp.__messageHandlers[message]) {
107
+ FrameApp.__messageHandlers[message] = [];
108
+ }
109
+ return FrameApp.__messageHandlers[message].push(fn);
110
+ };
111
+
112
+ /**
113
+ * Callback triggered when a postMessage message is received.
114
+ *
115
+ * @param e
116
+ * @returns {*}
117
+ * @private
118
+ */
119
+ FrameApp.__addEventMessageCallback = function(e) {
120
+ var handler, handlers, message, submitForm, _i, _len;
121
+ FrameApp.log("FrameApp client received " + e.data + " from " + e.origin);
122
+ message = JSON.parse(e.data);
123
+ handlers = [];
124
+ if (FrameApp.__messageHandlers[message.message]) {
125
+ handlers = handlers.concat(FrameApp.__messageHandlers[message.message]);
126
+ }
127
+ if (FrameApp.__messageHandlers[void 0]) {
128
+ handlers = handlers.concat(FrameApp.__messageHandlers[void 0]);
129
+ }
130
+ for (_i = 0, _len = handlers.length; _i < _len; _i++) {
131
+ handler = handlers[_i];
132
+ handler(message.message, message.data);
133
+ }
134
+ };
135
+
136
+ /**
137
+ * Callback triggered when our iFrame is loaded.
138
+ *
139
+ * @param e
140
+ * @private
141
+ */
142
+ FrameApp.__iframeLoadCallback = function(e) {
143
+ FrameApp.postMessage('Shopify.API.initialize', {
144
+ 'hi': 'there!'
145
+ });
146
+ };
147
+
148
+ return FrameApp;
149
+
150
+ }).call(this);
151
+
152
+ }).call(this);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * disco_app/shopify-turbolinks.js
3
+ * Some tweaks to help Turbolinks play nicely with the Embedded App SDK.
4
+ */
5
+ jQuery(document).on('page:load', function(e) {
6
+ ShopifyApp.pushState(window.location.pathname);
7
+ });
@@ -0,0 +1,54 @@
1
+ //
2
+ // Select the Bootstrap components to pull in.
3
+ // --------------------------------------------------
4
+
5
+ // Core variables and mixins
6
+ @import "bootstrap/variables";
7
+ @import "bootstrap/mixins";
8
+
9
+ // Reset and dependencies
10
+ @import "bootstrap/normalize";
11
+ //@import "bootstrap/print";
12
+ //@import "bootstrap/glyphicons";
13
+
14
+ // Core CSS
15
+ @import "bootstrap/scaffolding";
16
+ @import "bootstrap/type";
17
+ //@import "bootstrap/code";
18
+ @import "bootstrap/grid";
19
+ //@import "bootstrap/tables";
20
+ @import "bootstrap/forms";
21
+ @import "bootstrap/buttons";
22
+
23
+ // Components
24
+ @import "bootstrap/component-animations";
25
+ @import "bootstrap/dropdowns";
26
+ @import "bootstrap/button-groups";
27
+ @import "bootstrap/input-groups";
28
+ @import "bootstrap/navs";
29
+ @import "bootstrap/navbar";
30
+ //@import "bootstrap/breadcrumbs";
31
+ //@import "bootstrap/pagination";
32
+ //@import "bootstrap/pager";
33
+ @import "bootstrap/labels";
34
+ @import "bootstrap/badges";
35
+ //@import "bootstrap/jumbotron";
36
+ @import "bootstrap/thumbnails";
37
+ @import "bootstrap/alerts";
38
+ @import "bootstrap/progress-bars";
39
+ @import "bootstrap/media";
40
+ @import "bootstrap/list-group";
41
+ @import "bootstrap/panels";
42
+ //@import "bootstrap/responsive-embed";
43
+ //@import "bootstrap/wells";
44
+ @import "bootstrap/close";
45
+
46
+ // Components w/ JavaScript
47
+ //@import "bootstrap/modals";
48
+ //@import "bootstrap/tooltip";
49
+ //@import "bootstrap/popovers";
50
+ //@import "bootstrap/carousel";
51
+
52
+ // Utility classes
53
+ @import "bootstrap/utilities";
54
+ @import "bootstrap/responsive-utilities";