beyond_canvas 0.16.2.pre → 0.19.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/beyond_canvas_manifest.js +1 -0
- data/app/assets/images/icons/arrow_right.svg +1 -0
- data/app/assets/images/icons/close.svg +1 -0
- data/app/assets/images/icons/home.svg +1 -0
- data/app/assets/javascripts/beyond_canvas/base.js +120 -246
- data/app/assets/stylesheets/beyond_canvas/base.scss +10 -1
- data/app/assets/stylesheets/beyond_canvas/components/_action_bar.scss +28 -0
- data/app/assets/stylesheets/beyond_canvas/components/_breadcrumbs.scss +29 -0
- data/app/assets/stylesheets/beyond_canvas/components/_buttons.scss +1 -1
- data/app/assets/stylesheets/beyond_canvas/components/_debug.scss +10 -0
- data/app/assets/stylesheets/beyond_canvas/components/_forms.scss +11 -14
- data/app/assets/stylesheets/beyond_canvas/components/_grids.scss +12 -0
- data/app/assets/stylesheets/beyond_canvas/components/_inputs.scss +5 -0
- data/app/assets/stylesheets/beyond_canvas/components/_main.scss +12 -13
- data/app/assets/stylesheets/beyond_canvas/components/_margins.scss +12 -0
- data/app/assets/stylesheets/beyond_canvas/components/_menu.scss +50 -0
- data/app/assets/stylesheets/beyond_canvas/components/_modals.scss +35 -0
- data/app/assets/stylesheets/beyond_canvas/components/_scrollbox.scss +35 -0
- data/app/assets/stylesheets/beyond_canvas/components/_sidebar.scss +53 -0
- data/app/assets/stylesheets/beyond_canvas/components/_texts.scss +8 -0
- data/app/assets/stylesheets/beyond_canvas/components/_titles.scss +7 -0
- data/app/assets/stylesheets/beyond_canvas/settings/_variables.scss +64 -9
- data/app/controllers/beyond_canvas/application_controller.rb +3 -0
- data/app/controllers/beyond_canvas/authentications_controller.rb +37 -30
- data/app/controllers/concerns/beyond_canvas/authentication.rb +1 -12
- data/app/controllers/concerns/beyond_canvas/locale_management.rb +5 -4
- data/app/form_builders/beyond_canvas/form_builder.rb +8 -6
- data/app/helpers/beyond_canvas/authentications_helper.rb +28 -0
- data/app/helpers/beyond_canvas/cockpit_app_helper.rb +17 -0
- data/app/helpers/beyond_canvas/controller_helper.rb +9 -0
- data/app/helpers/beyond_canvas/debug_helper.rb +9 -0
- data/app/helpers/beyond_canvas/locale_switch_helper.rb +5 -1
- data/app/javascript/beyond_canvas/base.js +3 -0
- data/app/javascript/beyond_canvas/initializers/buttons.js +65 -19
- data/app/javascript/beyond_canvas/initializers/flash.js +9 -2
- data/app/javascript/beyond_canvas/initializers/inputs.js +4 -1
- data/app/javascript/beyond_canvas/initializers/modals.js +14 -0
- data/app/views/beyond_canvas/authentications/new.html.erb +19 -10
- data/app/views/beyond_canvas/shared/_action_bar.html.erb +15 -0
- data/app/views/beyond_canvas/shared/_breadcrumbs.html.erb +14 -0
- data/app/views/beyond_canvas/shared/_flash.html.erb +22 -12
- data/app/views/beyond_canvas/shared/_locales.html.erb +8 -0
- data/app/views/beyond_canvas/shared/_menu.html.erb +31 -0
- data/app/views/beyond_canvas/shared/_modal.html.erb +6 -0
- data/app/views/beyond_canvas/shared/_sidebar.html.erb +16 -0
- data/app/views/layouts/beyond_canvas/application.html.erb +31 -0
- data/app/views/layouts/beyond_canvas/public.html.erb +11 -4
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +5 -4
- data/lib/beyond_canvas.rb +12 -12
- data/lib/beyond_canvas/configuration.rb +11 -6
- data/lib/beyond_canvas/engine.rb +5 -6
- data/lib/beyond_canvas/menu_item_registration.rb +19 -0
- data/lib/beyond_canvas/parameter_sanitizer.rb +1 -1
- data/lib/beyond_canvas/rails/routes.rb +8 -7
- data/lib/beyond_canvas/version.rb +1 -1
- data/lib/generators/beyond_canvas/controller/controller_generator.rb +1 -6
- data/lib/generators/beyond_canvas/controller/templates/shops_controller.rb +20 -0
- data/lib/generators/beyond_canvas/custom_menu/custom_menu_generator.rb +13 -0
- data/lib/generators/beyond_canvas/custom_menu/templates/beyond_canvas_custom_menu.html.erb +32 -0
- data/lib/generators/beyond_canvas/custom_styles/custom_styles_generator.rb +1 -1
- data/lib/generators/beyond_canvas/custom_styles/templates/beyond_canvas_custom_styles.scss +55 -9
- data/lib/generators/beyond_canvas/install/install_generator.rb +3 -5
- data/lib/generators/beyond_canvas/install/templates/beyond_canvas.rb.erb +52 -14
- data/lib/generators/beyond_canvas/{auth_model/auth_model_generator.rb → model/model_generator.rb} +4 -5
- data/lib/generators/beyond_canvas/{auth_model → model}/templates/migration.erb +2 -4
- data/lib/generators/beyond_canvas/{auth_model → model}/templates/model.erb +0 -0
- data/lib/generators/beyond_canvas/views/views_generator.rb +4 -6
- data/lib/models/concerns/authentication.rb +57 -0
- data/lib/models/concerns/utils.rb +79 -0
- data/lib/models/shop.rb +12 -0
- metadata +73 -31
- data/app/controllers/concerns/beyond_canvas/resource_management.rb +0 -33
- data/app/javascript/beyond_canvas/initializers/functions.js +0 -41
- data/app/views/beyond_canvas/locales/_edit.html.erb +0 -8
- data/lib/beyond_canvas/models/authentication.rb +0 -66
- data/lib/beyond_canvas/models/shop.rb +0 -28
- data/lib/beyond_canvas/models/utils.rb +0 -55
- data/lib/generators/beyond_canvas/controller/templates/controller.erb +0 -37
@@ -1,17 +1,26 @@
|
|
1
|
-
|
1
|
+
<% app_name = BeyondCanvas.configuration.site_title %>
|
2
|
+
<% i18n_scope = 'beyond_canvas.authentications.new' %>
|
2
3
|
|
3
|
-
|
4
|
+
<div class="card card--padding">
|
4
5
|
|
5
|
-
|
6
|
+
<%= form_with(url: callback_path, method: :post, scope: :shop, model: @shop, local: true, builder: BeyondCanvas::FormBuilder) do |f| %>
|
6
7
|
|
7
|
-
|
8
|
-
<%= f.hidden_field :signature, value: params[:signature] || resource.signature %>
|
9
|
-
<%= f.hidden_field :return_url, value: params[:return_url] || resource.return_url %>
|
10
|
-
<%= f.hidden_field :api_url, value: params[:api_url] || resource.api_url %>
|
11
|
-
<%= f.hidden_field :access_token_url, value: params[:access_token_url] || resource.access_token_url %>
|
8
|
+
<h2 class="card__headline"><%= I18n.t('headline', app_name: app_name, scope: i18n_scope) %></h2>
|
12
9
|
|
13
|
-
<
|
14
|
-
|
10
|
+
<p class="margin--bottom"><%= I18n.t('body', app_name: app_name, scope: i18n_scope) %></p>
|
11
|
+
|
12
|
+
<%# Don't delete or modify any ot these hidden fields. They are used on shop identification and authentication %>
|
13
|
+
|
14
|
+
<%= f.hidden_field :code, value: params[:code] || @shop.code %>
|
15
|
+
<%= f.hidden_field :signature, value: params[:signature] || @shop.signature %>
|
16
|
+
<%= f.hidden_field :return_url, value: params[:return_url] || @shop.return_url %>
|
17
|
+
<%= f.hidden_field :api_url, value: params[:api_url] || @shop.api_url %>
|
18
|
+
<%= f.hidden_field :access_token_url, value: params[:access_token_url] || @shop.access_token_url %>
|
19
|
+
|
20
|
+
<%# Add HERE your custom shop fields %>
|
21
|
+
|
22
|
+
<div class="form__actions--spaced">
|
23
|
+
<%= f.button I18n.t('actions.install', scope: i18n_scope), type: :submit, class: 'button__solid--primary' %>
|
15
24
|
</div>
|
16
25
|
|
17
26
|
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if action_bar_content? %>
|
2
|
+
|
3
|
+
<div class="action_bar<% if menu_content? %> action_bar--menu<% end %>">
|
4
|
+
|
5
|
+
<div class="action_bar--left">
|
6
|
+
<%= yield :action_bar_left %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="action_bar--right">
|
10
|
+
<%= yield :action_bar_right %>
|
11
|
+
</div>
|
12
|
+
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<% if is_cockpit_app? %>
|
2
|
+
|
3
|
+
<div class='breadcrumbs'>
|
4
|
+
|
5
|
+
<%= inline_svg_tag 'icons/home.svg' %>
|
6
|
+
|
7
|
+
<% breadcrumb_trail do |crumb| %>
|
8
|
+
<%= link_to crumb.name, crumb.url, class: "breadcrumb__item#{ '--current' if crumb.current? }" %>
|
9
|
+
<% unless crumb.current? %><%= inline_svg_tag 'icons/arrow_right.svg' %><% end %>
|
10
|
+
<% end %>
|
11
|
+
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<% end %>
|
@@ -1,13 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<div id="flash">
|
2
|
+
|
3
|
+
<% flash.each do |key, value| %>
|
4
|
+
|
5
|
+
<div class="flash">
|
6
|
+
|
7
|
+
<div class="flash__icon flash__icon--<%= key %>">
|
8
|
+
<%= get_flash_icon(key) %>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div class="flash__message">
|
12
|
+
<%= value %>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<div class="flash__close">
|
16
|
+
<%= inline_svg_tag 'icons/flash_close.svg' %>
|
17
|
+
</div>
|
18
|
+
|
5
19
|
</div>
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<%= inline_svg_tag 'icons/flash_close.svg' %>
|
11
|
-
</div>
|
12
|
-
</div>
|
13
|
-
<% end %>
|
20
|
+
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
</div>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% if show_locale_switch? && !is_cockpit_app? %>
|
2
|
+
<%= form_for :system, url: beyond_canvas.update_locale_path, method: :put do |f| %>
|
3
|
+
<%= f.select :locale, I18n.available_locales.collect { |l| [translate_locale(l), l] },
|
4
|
+
{ selected: cookies[:locale] },
|
5
|
+
class: 'select--locale',
|
6
|
+
onchange: 'this.form.submit()' %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<% if menu_content? %>
|
2
|
+
|
3
|
+
<div class="menu">
|
4
|
+
|
5
|
+
<div class="menu--left">
|
6
|
+
<%= render 'beyond_canvas/shared/logo' %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="menu--center">
|
10
|
+
|
11
|
+
<% BeyondCanvas.configuration.menu_items.each do |menu_item| %>
|
12
|
+
<% name, url, options = menu_item.name.to_s, menu_item.url.to_s, menu_item.options %>
|
13
|
+
|
14
|
+
<% url, external_url = respond_to?(url) ? [send(url), false] : [url, true] %>
|
15
|
+
<% name = defined?(I18n) && I18n.exists?(name) ? I18n.t(name) : name %>
|
16
|
+
|
17
|
+
<% path = Rails.application.routes.recognize_path(url) %>
|
18
|
+
|
19
|
+
<% options = options.merge(class: 'menu__item--active') { |_key, old_val, new_val| [new_val, old_val].join(' ') } if !external_url && (path[:controller] == params[:controller]) %>
|
20
|
+
<% options = options.merge(class: 'menu__item') { |_key, old_val, new_val| [new_val, old_val].join(' ') } %>
|
21
|
+
|
22
|
+
<%= link_to name, url, options %>
|
23
|
+
<% end %>
|
24
|
+
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div class="menu--right"></div>
|
28
|
+
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% if is_cockpit_app? && Rails.env.development? %>
|
2
|
+
<div class="sidebar">
|
3
|
+
<div class="sidebar__header">
|
4
|
+
<div class="sidebar__logo"></div>
|
5
|
+
</div>
|
6
|
+
<div class="sidebar__item sidebar__item--selected"></div>
|
7
|
+
<div class="sidebar__item"></div>
|
8
|
+
<div class="sidebar__item"></div>
|
9
|
+
<div class="sidebar__item"></div>
|
10
|
+
<div class="sidebar__footer">
|
11
|
+
<div class="sidebar__icon"></div>
|
12
|
+
<div class="sidebar__icon"></div>
|
13
|
+
<div class="sidebar__icon"></div>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<%= render 'beyond_canvas/shared/head' %>
|
5
|
+
|
6
|
+
<body class="body--application"<% if is_cockpit_app? && Rails.env.development? %> style="display: flex;"<% end %>>
|
7
|
+
|
8
|
+
<%= render 'beyond_canvas/shared/sidebar' %>
|
9
|
+
|
10
|
+
<main class="main <%= params[:controller].gsub(/[\/_]/, "-") %>--<%= params[:action] %>">
|
11
|
+
|
12
|
+
<%= render 'beyond_canvas/shared/flash' %>
|
13
|
+
<%= render 'beyond_canvas/shared/locales' %>
|
14
|
+
<%= render 'beyond_canvas/shared/modal' %>
|
15
|
+
<%= render 'beyond_canvas/shared/menu' %>
|
16
|
+
<%= render 'beyond_canvas/shared/action_bar' %>
|
17
|
+
|
18
|
+
<div class="main-wrapper<% if action_bar_content? %> main-wrapper--action_bar<% end %>"<% if content_for?(:max_width)%> style="max-width: <%= yield :max_width %>"<% end %>>
|
19
|
+
|
20
|
+
<%= render 'beyond_canvas/shared/breadcrumbs' %>
|
21
|
+
|
22
|
+
<%= yield %>
|
23
|
+
|
24
|
+
<%= debug(params) if debug_mode? %>
|
25
|
+
|
26
|
+
</div>
|
27
|
+
|
28
|
+
</main>
|
29
|
+
|
30
|
+
</body>
|
31
|
+
</html>
|
@@ -4,15 +4,22 @@
|
|
4
4
|
<%= render 'beyond_canvas/shared/head' %>
|
5
5
|
|
6
6
|
<body class="body--public">
|
7
|
+
|
7
8
|
<main class="main <%= params[:controller].gsub(/[\/_]/, "-") %>--<%= params[:action] %>">
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
|
10
|
+
<%= render 'beyond_canvas/shared/flash' %>
|
11
|
+
<%= render 'beyond_canvas/shared/locales' %>
|
12
|
+
|
12
13
|
<div class="main-wrapper">
|
14
|
+
|
13
15
|
<%= render 'beyond_canvas/shared/logo' %>
|
16
|
+
|
14
17
|
<%= yield %>
|
18
|
+
|
15
19
|
</div>
|
20
|
+
|
21
|
+
<%= debug(params) if debug_mode? %>
|
22
|
+
|
16
23
|
</main>
|
17
24
|
</body>
|
18
25
|
</html>
|
data/config/locales/en.yml
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
en:
|
2
2
|
beyond_canvas:
|
3
3
|
authentications:
|
4
|
+
new:
|
5
|
+
headline: Install %{app_name} in your shop
|
6
|
+
body: You are about to install %{app_name} in your shop. For continuing with this process, press the install button below.
|
7
|
+
actions:
|
8
|
+
install: Install
|
4
9
|
failure: Shop could not be saved
|
data/config/routes.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
BeyondCanvas::Engine.routes.draw do
|
4
|
-
put '
|
4
|
+
put 'locale', to: 'system#update_locale', as: :update_locale
|
5
5
|
|
6
|
-
def create_default_routes
|
7
|
-
|
6
|
+
def create_default_routes
|
7
|
+
get 'callback', to: 'authentications#new'
|
8
|
+
post 'callback', to: 'authentications#install'
|
8
9
|
end
|
9
10
|
|
10
|
-
create_default_routes
|
11
|
+
create_default_routes unless BeyondCanvas.use_rails_app_controller
|
11
12
|
end
|
data/lib/beyond_canvas.rb
CHANGED
@@ -8,30 +8,30 @@ require 'jquery-rails'
|
|
8
8
|
require 'bourbon'
|
9
9
|
require 'sassc-rails'
|
10
10
|
require 'inline_svg'
|
11
|
+
require 'loaf'
|
11
12
|
require 'http/accept'
|
12
13
|
require 'premailer/rails'
|
13
14
|
|
14
15
|
require 'beyond_api'
|
15
16
|
require 'attr_encrypted'
|
16
|
-
require 'blind_index'
|
17
17
|
|
18
18
|
module BeyondCanvas # :nodoc:
|
19
|
-
autoload :AssetRegistration,
|
20
|
-
autoload :Configuration,
|
19
|
+
autoload :AssetRegistration, 'beyond_canvas/asset_registration'
|
20
|
+
autoload :Configuration, 'beyond_canvas/configuration'
|
21
|
+
autoload :MenuItemRegistration, 'beyond_canvas/menu_item_registration'
|
22
|
+
autoload :ParameterSanitizer, 'beyond_canvas/parameter_sanitizer'
|
21
23
|
|
22
24
|
module Models # :nodoc:
|
23
|
-
autoload :
|
24
|
-
autoload :Shop, 'beyond_canvas/models/shop'
|
25
|
-
autoload :Utils, 'beyond_canvas/models/utils'
|
26
|
-
end
|
25
|
+
autoload :Shop, 'models/shop'
|
27
26
|
|
28
|
-
|
27
|
+
module Concerns
|
28
|
+
autoload :Authentication, 'models/concerns/authentication'
|
29
|
+
autoload :Utils, 'models/concerns/utils'
|
30
|
+
end
|
31
|
+
end
|
29
32
|
|
30
33
|
mattr_accessor :use_rails_app_controller
|
31
|
-
@@use_rails_app_controller = false
|
32
|
-
|
33
|
-
mattr_accessor :auth_model
|
34
|
-
@@auth_model = 'shop' # rubocop:disable Style/ClassVars
|
34
|
+
@@use_rails_app_controller = false
|
35
35
|
|
36
36
|
class << self
|
37
37
|
def configuration
|
@@ -2,18 +2,23 @@
|
|
2
2
|
|
3
3
|
module BeyondCanvas
|
4
4
|
class Configuration # :nodoc:
|
5
|
-
attr_accessor :site_title, :site_logo, :favicon, :skip_webpacker, :encryption_key, :
|
5
|
+
attr_accessor :site_title, :site_logo, :favicon, :skip_webpacker, :encryption_key, :namespace, :cockpit_app,
|
6
|
+
:open_app_url, :preinstalled, :debug_mode
|
6
7
|
|
7
8
|
include AssetRegistration
|
9
|
+
include MenuItemRegistration
|
8
10
|
|
9
11
|
def initialize
|
10
|
-
@
|
11
|
-
@
|
12
|
-
@favicon = nil
|
13
|
-
@skip_webpacker = false
|
12
|
+
@cockpit_app = false
|
13
|
+
@debug_mode = false
|
14
14
|
@encryption_key = nil
|
15
|
-
@
|
15
|
+
@favicon = nil
|
16
16
|
@namespace = '/'
|
17
|
+
@open_app_url = nil
|
18
|
+
@preinstalled = false
|
19
|
+
@site_logo = nil
|
20
|
+
@site_title = ::Rails.application.class.name.split('::').first.humanize
|
21
|
+
@skip_webpacker = false
|
17
22
|
end
|
18
23
|
|
19
24
|
def setup!
|
data/lib/beyond_canvas/engine.rb
CHANGED
@@ -13,22 +13,21 @@ module BeyondCanvas
|
|
13
13
|
BeyondCanvas.configuration.javascripts.each do |path|
|
14
14
|
app.config.assets.precompile << path
|
15
15
|
end
|
16
|
+
|
17
|
+
app.config.assets.precompile << 'beyond_canvas_manifest.js'
|
16
18
|
end
|
17
19
|
|
18
20
|
config.before_initialize do
|
19
21
|
ActiveSupport.on_load :action_controller do
|
20
|
-
include ::BeyondCanvas::Authentication
|
21
22
|
include ::BeyondCanvas::LocaleManagement
|
22
|
-
include ::BeyondCanvas::ResourceManagement
|
23
23
|
include ::BeyondCanvas::RequestValidation
|
24
24
|
include ::BeyondCanvas::StatusCodes
|
25
|
+
include ::BeyondCanvas::AuthenticationsHelper
|
26
|
+
include ::BeyondCanvas::DebugHelper
|
27
|
+
include ::BeyondCanvas::ControllerHelper
|
25
28
|
|
26
29
|
::ActionController::Base.helper BeyondCanvas::Engine.helpers
|
27
30
|
end
|
28
|
-
|
29
|
-
ActiveSupport.on_load :action_mailer do
|
30
|
-
layout 'beyond_canvas/mailer'
|
31
|
-
end
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BeyondCanvas
|
4
|
+
module MenuItemRegistration # :nodoc:
|
5
|
+
MenuItem = Struct.new(:name, :url, :options)
|
6
|
+
|
7
|
+
def register_menu_item(name, url, options = {})
|
8
|
+
menu_items.add MenuItem.new(name, url, options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def menu_items
|
12
|
+
@menu_items ||= Set.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def clear_menu_items!
|
16
|
+
menu_items.clear
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module BeyondCanvas
|
4
4
|
class ParameterSanitizer # :nodoc:
|
5
|
-
DEFAULT_PERMITTED_ATTRIBUTES = %i[code signature return_url api_url access_token_url]
|
5
|
+
DEFAULT_PERMITTED_ATTRIBUTES = %i[code signature return_url api_url access_token_url]
|
6
6
|
|
7
7
|
def initialize(resource_name, params)
|
8
8
|
@params = params
|
@@ -3,18 +3,19 @@
|
|
3
3
|
module ActionDispatch
|
4
4
|
module Routing
|
5
5
|
class Mapper # :nodoc:
|
6
|
-
def
|
6
|
+
def beyond_canvas_routes(options = nil)
|
7
7
|
mount BeyondCanvas::Engine => BeyondCanvas.configuration.namespace
|
8
8
|
|
9
|
-
|
10
|
-
BeyondCanvas.auth_model = resource_name.to_s.singularize
|
11
|
-
BeyondCanvas.use_rails_app_controller = options.present? && options[:controller].present?
|
9
|
+
BeyondCanvas.use_rails_app_controller = options.present? && options[:custom_controller].present?
|
12
10
|
|
13
|
-
set_routes
|
11
|
+
set_routes if BeyondCanvas.use_rails_app_controller
|
14
12
|
end
|
15
13
|
|
16
|
-
def set_routes
|
17
|
-
|
14
|
+
def set_routes
|
15
|
+
scope BeyondCanvas.configuration.namespace do
|
16
|
+
get 'callback', controller: :authentications, action: :new
|
17
|
+
post 'callback', controller: :authentications, action: :install
|
18
|
+
end
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -1,19 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rails/generators/active_record'
|
4
|
-
|
5
3
|
module BeyondCanvas
|
6
4
|
module Generators
|
7
5
|
class ControllerGenerator < Rails::Generators::Base # :nodoc:
|
8
6
|
desc 'Creates an inherited Beyond Canvas controller in the app/controllers folder'
|
9
7
|
|
10
|
-
argument :scope, required: true, desc: 'The scope to create the controller, e.g. shops, users'
|
11
|
-
|
12
8
|
source_root File.expand_path('templates', __dir__)
|
13
9
|
|
14
10
|
def create_controller
|
15
|
-
template '
|
16
|
-
"app/controllers/#{scope}_controller.rb"
|
11
|
+
template 'shops_controller.rb', "app/controllers/shops_controller.rb"
|
17
12
|
end
|
18
13
|
end
|
19
14
|
end
|