alchemy-solidus 2.5.1 → 3.1.1

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
  SHA256:
3
- metadata.gz: 902f1162c27c48166435b147674f8b9da9fd5c0fa9d3d95b60acb4cc62cf900c
4
- data.tar.gz: acd5cabe30ca1080ef6790ad7f3e47b553b02b7eb3ff8fe68c82ca7bb6c8c178
3
+ metadata.gz: 0a6e12d7505ec9bc89770302454888523f6c5fe4853bc46f49596b2f2c0380aa
4
+ data.tar.gz: 6a57eba2ac492aae30aa9df6ae32a9a48c3237210f0bcf6028b2e270ac25bebe
5
5
  SHA512:
6
- metadata.gz: a8b2ce4bcf0f1ef9a8e1e1461c6843f404c7ff7397a7cef4f71dc8d3efbe8cd5a31979b83d29cb2a42279afd7f0f10261064c52e9ee31ef04e8826f4c60718f6
7
- data.tar.gz: 2b479960fe66bbe12d2168ca95eedf62c798a00e790647d80fa6dc1ac7c6aadc453a6d6b2e7ec28405aec2e534b1ad5a675884df4481f3bc0adea83b9e8faf08
6
+ metadata.gz: 2f25bad30b4d80f28b066d1631ea7cbd0dd750490c8e3bdf8b731c83bcbf87080a273e6067b499295c5017cdf87d317190aed4fa207477cd166f45a6169aa018
7
+ data.tar.gz: 63b56091e7f023645b5de9c7212587852741fe2e6dbae826e12f1dc79e8c268f1b4248e5498c97d2aebb4bc9a7c5d782dfe61d5d6300f66c57b8b0ec9316de1a
data/README.md CHANGED
@@ -41,6 +41,8 @@ $ bundle install
41
41
 
42
42
  ## Automated setup
43
43
 
44
+ **Recommended**
45
+
44
46
  We ship a Rails generator that helps you to install this gem into your existing application.
45
47
 
46
48
  ```bash
@@ -61,9 +63,11 @@ To upgrade update the Gemfile and run the install generator again
61
63
  $ bin/rails g alchemy:solidus:install
62
64
  ```
63
65
 
64
- ## Manual setup
66
+ **NOTE** Please make sure to remove the `Alchemy::Modules.register_module` part from your `config/initializer/alchemy.rb` file if upgrading from 2.5.
67
+
68
+ ## Manual setup (for advanced users)
65
69
 
66
- If you want to have full control over the integration you can also set this up manually.
70
+ For regular setups we recommend the [automated installer](#automated-setup) mentioned above. But if you know what you are doing and want to have full control over the integration you can also set this up manually.
67
71
 
68
72
  ### Authentication system installation
69
73
 
@@ -178,26 +182,30 @@ and follow the on screen instructions.
178
182
 
179
183
  ### Render Alchemy Content in Solidus Layout
180
184
 
181
- If you plan to render the Alchemy site in the Solidus layout add the following
182
- to your initializer:
185
+ ~~If you plan to render the Alchemy site in the Solidus layout add the following
186
+ to your initializer:~~
183
187
 
184
188
  ```ruby
185
189
  # config/initializers/alchemy.rb
186
190
  require 'alchemy/solidus/use_solidus_layout'
187
191
  ```
188
192
 
193
+ **NOTE:** Since v2.5.2 this is done automatically for you. If you upgraded from an older version you can safely remove this from your initializers.
194
+
189
195
  ### Render Alchemy Content in Solidus views
190
196
 
191
- If you plan to render Alchemy content in your Solidus views (ie. a global header
197
+ ~~If you plan to render Alchemy content in your Solidus views (ie. a global header
192
198
  or footer section), you need to include the Alchemy view helpers and language
193
199
  store in your Solidus controllers with the following addition to your
194
- initializer:
200
+ initializer:~~
195
201
 
196
202
  ```ruby
197
203
  # config/initializers/alchemy.rb
198
204
  require 'alchemy/solidus/alchemy_in_solidus'
199
205
  ```
200
206
 
207
+ **NOTE:** Since v2.5.2 this is done automatically for you. If you upgraded from an older version you can safely remove this from your initializers.
208
+
201
209
  ### Routing
202
210
 
203
211
  For routing you have a few options.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ task :test_setup do
20
20
  system <<-SETUP.strip_heredoc
21
21
  export RAILS_ENV=test && \
22
22
  bin/rake db:environment:set db:drop && \
23
- bin/rails g spree:install --force --quiet --auto-accept --no-seed --no-sample && \
23
+ bin/rails g spree:install --force --auto-accept --no-seed --no-sample && \
24
24
  bin/rails g alchemy:solidus:install --auto-accept --force
25
25
  SETUP
26
26
  exit($?.exitstatus) unless $?.success?
@@ -1,3 +1,5 @@
1
+ <% content ||= local_assigns[:content] || local_assigns[:essence_spree_product_editor] %>
2
+
1
3
  <div class="content_editor essence_spree_product" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
2
4
  <%= content_label(content) %>
3
5
  <%= text_field_tag(
@@ -1,3 +1,5 @@
1
+ <% content ||= local_assigns[:content] || local_assigns[:essence_spree_taxon_editor] %>
2
+
1
3
  <div class="content_editor essence_spree_taxon" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
2
4
  <%= content_label(content) %>
3
5
  <%= text_field_tag(
@@ -1,3 +1,5 @@
1
+ <% content ||= local_assigns[:content] || local_assigns[:essence_spree_variant_editor] %>
2
+
1
3
  <div class="content_editor essence_spree_variant" id="<%= content.dom_id %>" data-content-id="<%= content.id %>">
2
4
  <%= content_label(content) %>
3
5
  <%= text_field_tag(
@@ -42,6 +42,14 @@ if defined?(Spree::Auth::Engine)
42
42
  name: 'Users'
43
43
  }
44
44
  )
45
+ Alchemy.user_class_name = 'Spree::User'
46
+ Alchemy.current_user_method = :spree_current_user
47
+
48
+ if Alchemy.respond_to?(:logout_method)
49
+ Rails.application.config.after_initialize do
50
+ Alchemy.logout_method = Devise.sign_out_via
51
+ end
52
+ end
45
53
  end
46
54
 
47
55
  Alchemy::Modules.register_module(alchemy_module)
@@ -1,16 +1,15 @@
1
- # Make sure we have everything loaded before patching classes
2
- Rails.application.config.to_prepare do
3
- # Allows to render Alchemy content within Solidus' controller views
4
- Spree::BaseController.include Alchemy::ControllerActions
5
- Spree::BaseController.include Alchemy::ConfigurationMethods
1
+ # Allows to render Alchemy content within Solidus' controller views
2
+ Spree::StoreController.include(
3
+ Alchemy::ControllerActions,
4
+ Alchemy::ConfigurationMethods
5
+ )
6
6
 
7
- # Hook into SolidusAuthDevise controllers if present
8
- if defined? Spree::Auth::Engine
9
- Spree::UserPasswordsController.include Alchemy::ControllerActions
10
- Spree::UserConfirmationsController.include Alchemy::ControllerActions
11
- Spree::UserRegistrationsController.include Alchemy::ControllerActions
12
- Spree::UserSessionsController.include Alchemy::ControllerActions
13
- end
7
+ # Hook into SolidusAuthDevise controllers if present
8
+ if defined? Spree::Auth::Engine
9
+ Spree::UserPasswordsController.include Alchemy::ControllerActions
10
+ Spree::UserConfirmationsController.include Alchemy::ControllerActions
11
+ Spree::UserRegistrationsController.include Alchemy::ControllerActions
12
+ Spree::UserSessionsController.include Alchemy::ControllerActions
14
13
  end
15
14
 
16
15
  # Do not prefix element view partials with `spree` namespace.
@@ -12,12 +12,12 @@ module Alchemy
12
12
  Alchemy.register_ability ::Spree::Ability
13
13
  ::Spree::Ability.register_ability ::Alchemy::Permissions
14
14
 
15
- if Alchemy.user_class_name == 'Spree::User'
15
+ if Alchemy.user_class.name == 'Spree::User'
16
16
  require 'alchemy/solidus/spree_user_extension'
17
17
  Spree::User.include Alchemy::Solidus::SpreeUserExtension
18
18
  end
19
19
 
20
- if Alchemy.user_class_name == 'Alchemy::User'
20
+ if Alchemy.user_class.name == 'Alchemy::User'
21
21
  require 'alchemy/solidus/alchemy_user_extension'
22
22
  Alchemy::User.include Alchemy::Solidus::AlchemyUserExtension
23
23
  require 'alchemy/solidus/spree_admin_unauthorized_redirect'
@@ -27,18 +27,26 @@ module Alchemy
27
27
  require 'alchemy/solidus/spree_custom_user_generator_fix'
28
28
  require 'alchemy/solidus/spree_install_generator_fix'
29
29
  end
30
+
31
+ if SolidusSupport.frontend_available?
32
+ # Allows to render Alchemy content within Solidus' controller views
33
+ require_dependency 'alchemy/solidus/alchemy_in_solidus'
34
+ end
35
+
36
+ # Allows to use Solidus helpers within Alchemys controller views
37
+ require_dependency 'alchemy/solidus/use_solidus_layout'
30
38
  end
31
39
 
32
40
  # Fix for +belongs_to :bill_address+ in {Spree::UserAddressBook}
33
41
  # Solidus has this set to +false+ in {Spree::Base}, but {Alchemy::User} does not inherit from it.
34
42
  initializer 'alchemy_solidus.belongs_bill_address_fix' do
35
- if Alchemy.user_class_name == 'Alchemy::User'
43
+ if Alchemy.user_class.name == 'Alchemy::User'
36
44
  ActiveSupport.on_load(:active_record) do
37
45
  Alchemy::User.belongs_to_required_by_default = false
38
46
  end
39
47
  end
40
48
  end
41
-
49
+
42
50
  # In versions of Solidus prior to 2.8, we override the tabs partial
43
51
  # to pass a match_path value to each tab. (Version 2.8 is already
44
52
  # passing this option.) This option is used to configure the paths
@@ -4,6 +4,6 @@ Spree::Admin::BaseController.unauthorized_redirect = -> do
4
4
  redirect_to spree.root_path
5
5
  else
6
6
  store_location
7
- redirect_to alchemy.login_path
7
+ redirect_to Alchemy.login_path
8
8
  end
9
9
  end
@@ -1,18 +1,19 @@
1
- # Make sure we have everything loaded before patching classes
2
- Rails.application.config.to_prepare do
3
- # Allows to use Solidus helpers within Alchemys controller views
4
- Alchemy::BaseHelper.include Spree::BaseHelper
5
- Alchemy::BaseHelper.include Spree::CheckoutHelper
6
- Alchemy::BaseHelper.include Spree::ProductsHelper
7
- Alchemy::BaseHelper.include Spree::StoreHelper
8
- Alchemy::BaseHelper.include Spree::TaxonsHelper
1
+ # Allows to use Solidus helpers within Alchemys controller views
2
+ Alchemy::BaseHelper.include(
3
+ Spree::BaseHelper,
4
+ Spree::CheckoutHelper,
5
+ Spree::ProductsHelper,
6
+ Spree::StoreHelper,
7
+ Spree::TaxonsHelper
8
+ )
9
9
 
10
- Alchemy::BaseController.include Spree::Core::ControllerHelpers::Auth
11
- Alchemy::BaseController.include Spree::Core::ControllerHelpers::Common
12
- Alchemy::BaseController.include Spree::Core::ControllerHelpers::Order
13
- Alchemy::BaseController.include Spree::Core::ControllerHelpers::PaymentParameters
14
- Alchemy::BaseController.include Spree::Core::ControllerHelpers::Pricing
15
- Alchemy::BaseController.include Spree::Core::ControllerHelpers::Search
16
- Alchemy::BaseController.include Spree::Core::ControllerHelpers::Store
17
- Alchemy::BaseController.include Spree::Core::ControllerHelpers::StrongParameters
18
- end
10
+ Alchemy::BaseController.include(
11
+ Spree::Core::ControllerHelpers::Auth,
12
+ Spree::Core::ControllerHelpers::Common,
13
+ Spree::Core::ControllerHelpers::Order,
14
+ Spree::Core::ControllerHelpers::PaymentParameters,
15
+ Spree::Core::ControllerHelpers::Pricing,
16
+ Spree::Core::ControllerHelpers::Search,
17
+ Spree::Core::ControllerHelpers::Store,
18
+ Spree::Core::ControllerHelpers::StrongParameters
19
+ )
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module Solidus
3
- VERSION = "2.5.1"
3
+ VERSION = "3.1.1"
4
4
  end
5
5
  end
@@ -0,0 +1,3 @@
1
+ - name: Home
2
+ page_layout: index
3
+ public_on: 1970-01-01
@@ -1,5 +1,12 @@
1
1
  require 'rails/generators'
2
- require 'rails/generators/alchemy/install/install_generator'
2
+ require 'alchemy/version'
3
+
4
+ if Alchemy.gem_version >= Gem::Version.new("5.0.0.a")
5
+ require 'generators/alchemy/install/install_generator'
6
+ else
7
+ require 'rails/generators/alchemy/install/install_generator'
8
+ end
9
+
3
10
  require 'generators/spree/custom_user/custom_user_generator'
4
11
  require 'solidus_support'
5
12
 
@@ -25,38 +32,36 @@ module Alchemy
25
32
  class_option :auto_accept, default: false, type: :boolean,
26
33
  desc: 'Set true if run from a automated script (ie. on a CI)'
27
34
 
28
- source_root File.expand_path('templates', __dir__)
35
+ source_root File.expand_path('files', __dir__)
29
36
 
30
37
  def run_alchemy_installer
31
38
  unless options[:skip_alchemy_installer]
32
39
  arguments = options[:auto_accept] ? ['--skip-demo-files', '--force'] : []
33
40
  Alchemy::Generators::InstallGenerator.start(arguments)
41
+ rake('railties:install:migrations', abort_on_failure: true)
42
+ rake('db:migrate', abort_on_failure: true)
34
43
  end
35
44
  end
36
45
 
37
46
  def run_alchemy_devise_installer
38
- if Kernel.const_defined?('Alchemy::Devise') && !options[:skip_alchemy_devise_installer]
47
+ if alchemy_devise_present? && !options[:skip_alchemy_devise_installer]
39
48
  arguments = options[:auto_accept] ? ['--force'] : []
40
49
  Alchemy::Devise::Generators::InstallGenerator.start(arguments)
41
50
  end
42
51
  end
43
52
 
44
53
  def run_spree_custom_user_generator
45
- if Kernel.const_defined?('Alchemy::Devise') && !options[:skip_spree_custom_user_generator]
54
+ if alchemy_devise_present? && !options[:skip_spree_custom_user_generator]
46
55
  arguments = options[:auto_accept] ? ['Alchemy::User', '--force'] : ['Alchemy::User']
47
56
  Spree::CustomUserGenerator.start(arguments)
48
57
  gsub_file 'lib/spree/authentication_helpers.rb', /main_app\./, 'Alchemy.'
49
58
  if SolidusSupport.solidus_gem_version < Gem::Version.new('2.5.0')
50
59
  gsub_file 'config/initializers/spree.rb', /Spree\.user_class.?=.?.+$/, 'Spree.user_class = "Alchemy::User"'
51
60
  end
52
- rake 'db:migrate'
61
+ rake('db:migrate', abort_on_failure: true)
53
62
  end
54
63
  end
55
64
 
56
- def copy_alchemy_initializer
57
- template "alchemy.rb.tt", "config/initializers/alchemy.rb"
58
- end
59
-
60
65
  def inject_admin_tab
61
66
  inject_into_file 'config/initializers/spree.rb', {after: "Spree::Backend::Config.configure do |config|\n"} do
62
67
  <<~ADMIN_TAB
@@ -75,7 +80,7 @@ module Alchemy
75
80
  end
76
81
 
77
82
  def create_admin_user
78
- if Kernel.const_defined?('Alchemy::Devise') && !options[:skip_alchemy_user_generator] && Alchemy::User.count.zero?
83
+ if alchemy_devise_present? && !options[:skip_alchemy_user_generator] && Alchemy::User.count.zero?
79
84
  login = ENV.fetch('ALCHEMY_ADMIN_USER_LOGIN', 'admin')
80
85
  email = ENV.fetch('ALCHEMY_ADMIN_USER_EMAIL', 'admin@example.com')
81
86
  password = ENV.fetch('ALCHEMY_ADMIN_USER_PASSWORD', 'test1234')
@@ -85,14 +90,17 @@ module Alchemy
85
90
  password = ask("Enter the password for the admin user", default: password)
86
91
  end
87
92
 
93
+ # This is a bit strange, but without the double save this fails with a failed validation.
88
94
  Alchemy::User.create!(
89
95
  login: login,
90
96
  email: email,
91
97
  password: password,
92
98
  password_confirmation: password,
93
- alchemy_roles: 'admin',
94
- spree_roles: [Spree::Role.find_or_create_by!(name: 'admin')]
95
- )
99
+ alchemy_roles: 'admin'
100
+ ).tap do |user|
101
+ user.spree_roles = [Spree::Role.find_or_create_by!(name: 'admin')]
102
+ user.save!
103
+ end
96
104
  end
97
105
  end
98
106
 
@@ -114,21 +122,17 @@ module Alchemy
114
122
 
115
123
  def set_root_route
116
124
  routes_file_path = Rails.root.join('config', 'routes.rb')
117
- if options[:auto_accept] || ask("\nDo you want Alchemy to handle the root route ('/')?", default: true)
118
- if File.read(routes_file_path).match SPREE_MOUNT_REGEXP
119
- sentinel = SPREE_MOUNT_REGEXP
120
- else
121
- sentinel = "Rails.application.routes.draw do\n"
122
- end
125
+ if options[:auto_accept] || yes?("\nDo you want Alchemy to handle the root route '/'? (y/n)")
126
+ sentinel = "Rails.application.routes.draw do\n"
123
127
  inject_into_file routes_file_path, {after: sentinel} do
124
128
  <<~ROOT_ROUTE
125
- \n
126
129
  \ # Let AlchemyCMS handle the root route
127
- \ Spree::Core::Engine.routes.draw do
128
- \ root to: '/alchemy/pages#index'
129
- \ end
130
+ \ root to: 'alchemy/pages#index'
130
131
  ROOT_ROUTE
131
132
  end
133
+ copy_file('db/seeds/alchemy/pages.yml')
134
+ append_file(Rails.root.join('db', 'seeds.rb'), "Alchemy::Seeder.seed!\n")
135
+ rake('alchemy:db:seed', abort_on_failure: true)
132
136
  end
133
137
  end
134
138
 
@@ -136,6 +140,12 @@ module Alchemy
136
140
  append_file "vendor/assets/javascripts/alchemy/admin/all.js",
137
141
  "//= require alchemy/solidus/admin.js"
138
142
  end
143
+
144
+ private
145
+
146
+ def alchemy_devise_present?
147
+ defined?(Alchemy::Devise::Engine)
148
+ end
139
149
  end
140
150
  end
141
151
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-solidus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.1
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-13 00:00:00.000000000 Z
11
+ date: 2020-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms
@@ -239,8 +239,8 @@ files:
239
239
  - lib/alchemy/solidus/spree_user_extension.rb
240
240
  - lib/alchemy/solidus/use_solidus_layout.rb
241
241
  - lib/alchemy/solidus/version.rb
242
+ - lib/generators/alchemy/solidus/install/files/db/seeds/alchemy/pages.yml
242
243
  - lib/generators/alchemy/solidus/install/install_generator.rb
243
- - lib/generators/alchemy/solidus/install/templates/alchemy.rb.tt
244
244
  - lib/views/spree/admin/shared/_tabs.html.erb
245
245
  homepage: https://github.com/AlchemyCMS/alchemy-solidus
246
246
  licenses:
@@ -1,44 +0,0 @@
1
- Alchemy::Modules.register_module({
2
- engine_name: 'spree',
3
- name: 'solidus',
4
- navigation: {
5
- controller: 'spree/admin/orders',
6
- action: 'index',
7
- name: 'Store',
8
- inline_image: '<svg version="1.1" width="24px" height="24px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" style="vertical-align: middle">
9
- <path d="M 6.687 21.839 L 17.314 21.839 L 17.314 2.162 L 6.687 2.162 Z M 19.476 24 L 4.525 24 L 4.525 0 L 19.476 0 Z M 13.89 17 C 13.307 16.662 13.078 16.287 13.05 15.313 L 13.05 8.574 C 13.05 6.554 12.05 5.814 9.911 4.794 L 8.99 6.434 L 10.111 7.074 C 10.693 7.412 10.923 7.786 10.951 8.761 L 10.951 15.5 C 10.951 17.52 11.951 18.26 14.09 19.279 L 15.01 17.64 Z" fill="currentColor"/>
10
- </svg>',
11
- data: { turbolinks: false },
12
- sub_navigation: [
13
- {
14
- controller: 'spree/admin/orders',
15
- action: 'index',
16
- name: 'Orders'
17
- },
18
- {
19
- controller: 'spree/admin/products',
20
- action: 'index',
21
- name: 'Products'
22
- },
23
- {
24
- controller: 'spree/admin/promotions',
25
- action: 'index',
26
- name: 'Promotions'
27
- },
28
- {
29
- controller: 'spree/admin/stock_items',
30
- action: 'index',
31
- name: 'Stock'
32
- <%- if defined?(Spree::Auth::Engine) -%>
33
- },
34
- {
35
- controller: 'spree/admin/users',
36
- action: 'index',
37
- name: 'Users'
38
- }
39
- <%- else -%>
40
- }
41
- <%- end -%>
42
- ]
43
- }
44
- })