alchemy-solidus 2.5.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -6
- data/Rakefile +1 -1
- data/config/initializers/alchemy.rb +8 -0
- data/lib/alchemy/solidus/alchemy_in_solidus.rb +15 -12
- data/lib/alchemy/solidus/engine.rb +12 -4
- data/lib/alchemy/solidus/spree_admin_unauthorized_redirect.rb +1 -1
- data/lib/alchemy/solidus/use_solidus_layout.rb +18 -15
- data/lib/alchemy/solidus/version.rb +1 -1
- data/lib/generators/alchemy/solidus/install/files/db/seeds/alchemy/pages.yml +3 -0
- data/lib/generators/alchemy/solidus/install/install_generator.rb +33 -23
- metadata +3 -3
- data/lib/generators/alchemy/solidus/install/templates/alchemy.rb.tt +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a20516abea7d38b47f1a022998b93c48dddadff27a75e82bf511b0d4bde77792
|
4
|
+
data.tar.gz: c991f9f52ce9c98a87adc6b8ca880564c8f8bfc2802aff44b17b808e252543b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb405c8a49ba7ce079fe81a94577447673c1c0f6b22b8161153097dec0f6f9e65af98bfb91be37ba26ca3bf0f71ef1e336e34968b70154a71ae5ac440dea3510
|
7
|
+
data.tar.gz: 959ff15ccbba0ab90a0a170bd9cc5fcffe099b89f388fb2066b220c0e45d9636782fe4c4e4a76cfb92e2a177801b520b499954493de84f31890663cb292acd37
|
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
|
-
|
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
|
-
|
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 --
|
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?
|
@@ -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,14 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
# Allows to render Alchemy content within Solidus' controller views
|
2
|
+
Spree::StoreController.include(
|
3
|
+
Alchemy::ControllerActions,
|
4
|
+
Alchemy::ConfigurationMethods
|
5
|
+
)
|
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
|
9
13
|
end
|
10
14
|
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
Spree::BaseController.send :include, Alchemy::ConfigurationMethods
|
15
|
+
# Do not prefix element view partials with `spree` namespace.
|
16
|
+
# See https://github.com/AlchemyCMS/alchemy_cms/issues/1626
|
17
|
+
ActionView::Base.prefix_partial_path_with_controller_namespace = false
|
@@ -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.
|
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.
|
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.
|
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
|
@@ -1,16 +1,19 @@
|
|
1
|
-
#
|
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
|
+
)
|
2
9
|
|
3
|
-
Alchemy::
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Pricing
|
14
|
-
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Search
|
15
|
-
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Store
|
16
|
-
Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::StrongParameters
|
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,12 @@
|
|
1
1
|
require 'rails/generators'
|
2
|
-
require '
|
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('
|
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
|
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
|
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
|
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
|
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
|
-
|
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] ||
|
118
|
-
|
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
|
-
\
|
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:
|
4
|
+
version: 3.1.0
|
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:
|
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
|
-
})
|