alchemy-solidus 2.5.1 → 3.0.0

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: 7702f9a029e49150f896e95ed265edcb1a3008fbe138f180eba53ed3d69f47b2
4
+ data.tar.gz: 118c3f1109a630ea2dabdd89d480fa4043db9e61ab3211f0bcce9cd27934e18a
5
5
  SHA512:
6
- metadata.gz: a8b2ce4bcf0f1ef9a8e1e1461c6843f404c7ff7397a7cef4f71dc8d3efbe8cd5a31979b83d29cb2a42279afd7f0f10261064c52e9ee31ef04e8826f4c60718f6
7
- data.tar.gz: 2b479960fe66bbe12d2168ca95eedf62c798a00e790647d80fa6dc1ac7c6aadc453a6d6b2e7ec28405aec2e534b1ad5a675884df4481f3bc0adea83b9e8faf08
6
+ metadata.gz: a3d80d75fc3bebb74a73fb62ad2d35a407a0a41d7292c3f33edbb36043504e273d67a20fa9edf5f883fa26ee66f82f8d8272ae97bbd75b8eaf2555d1d338359c
7
+ data.tar.gz: ed3bc37a2c74ebaa376fa1d41928d755e9bc672313019b8515542aa2153e8030d97a78446bb77819c1997f99ed14a7bf9470b82439dadb200b8c4f7fa427df76
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.
@@ -42,6 +42,8 @@ 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
45
47
  end
46
48
 
47
49
  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.
@@ -27,6 +27,14 @@ 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}
@@ -38,7 +46,7 @@ module Alchemy
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,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.0.0"
4
4
  end
5
5
  end
@@ -0,0 +1,3 @@
1
+ - name: Home
2
+ page_layout: index
3
+ public_on: 1970-01-01
@@ -25,38 +25,36 @@ module Alchemy
25
25
  class_option :auto_accept, default: false, type: :boolean,
26
26
  desc: 'Set true if run from a automated script (ie. on a CI)'
27
27
 
28
- source_root File.expand_path('templates', __dir__)
28
+ source_root File.expand_path('files', __dir__)
29
29
 
30
30
  def run_alchemy_installer
31
31
  unless options[:skip_alchemy_installer]
32
32
  arguments = options[:auto_accept] ? ['--skip-demo-files', '--force'] : []
33
33
  Alchemy::Generators::InstallGenerator.start(arguments)
34
+ rake('railties:install:migrations', abort_on_failure: true)
35
+ rake('db:migrate', abort_on_failure: true)
34
36
  end
35
37
  end
36
38
 
37
39
  def run_alchemy_devise_installer
38
- if Kernel.const_defined?('Alchemy::Devise') && !options[:skip_alchemy_devise_installer]
40
+ if alchemy_devise_present? && !options[:skip_alchemy_devise_installer]
39
41
  arguments = options[:auto_accept] ? ['--force'] : []
40
42
  Alchemy::Devise::Generators::InstallGenerator.start(arguments)
41
43
  end
42
44
  end
43
45
 
44
46
  def run_spree_custom_user_generator
45
- if Kernel.const_defined?('Alchemy::Devise') && !options[:skip_spree_custom_user_generator]
47
+ if alchemy_devise_present? && !options[:skip_spree_custom_user_generator]
46
48
  arguments = options[:auto_accept] ? ['Alchemy::User', '--force'] : ['Alchemy::User']
47
49
  Spree::CustomUserGenerator.start(arguments)
48
50
  gsub_file 'lib/spree/authentication_helpers.rb', /main_app\./, 'Alchemy.'
49
51
  if SolidusSupport.solidus_gem_version < Gem::Version.new('2.5.0')
50
52
  gsub_file 'config/initializers/spree.rb', /Spree\.user_class.?=.?.+$/, 'Spree.user_class = "Alchemy::User"'
51
53
  end
52
- rake 'db:migrate'
54
+ rake('db:migrate', abort_on_failure: true)
53
55
  end
54
56
  end
55
57
 
56
- def copy_alchemy_initializer
57
- template "alchemy.rb.tt", "config/initializers/alchemy.rb"
58
- end
59
-
60
58
  def inject_admin_tab
61
59
  inject_into_file 'config/initializers/spree.rb', {after: "Spree::Backend::Config.configure do |config|\n"} do
62
60
  <<~ADMIN_TAB
@@ -75,7 +73,7 @@ module Alchemy
75
73
  end
76
74
 
77
75
  def create_admin_user
78
- if Kernel.const_defined?('Alchemy::Devise') && !options[:skip_alchemy_user_generator] && Alchemy::User.count.zero?
76
+ if alchemy_devise_present? && !options[:skip_alchemy_user_generator] && Alchemy::User.count.zero?
79
77
  login = ENV.fetch('ALCHEMY_ADMIN_USER_LOGIN', 'admin')
80
78
  email = ENV.fetch('ALCHEMY_ADMIN_USER_EMAIL', 'admin@example.com')
81
79
  password = ENV.fetch('ALCHEMY_ADMIN_USER_PASSWORD', 'test1234')
@@ -114,21 +112,17 @@ module Alchemy
114
112
 
115
113
  def set_root_route
116
114
  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
115
+ if options[:auto_accept] || yes?("\nDo you want Alchemy to handle the root route '/'? (y/n)")
116
+ sentinel = "Rails.application.routes.draw do\n"
123
117
  inject_into_file routes_file_path, {after: sentinel} do
124
118
  <<~ROOT_ROUTE
125
- \n
126
119
  \ # Let AlchemyCMS handle the root route
127
- \ Spree::Core::Engine.routes.draw do
128
- \ root to: '/alchemy/pages#index'
129
- \ end
120
+ \ root to: 'alchemy/pages#index'
130
121
  ROOT_ROUTE
131
122
  end
123
+ copy_file('db/seeds/alchemy/pages.yml')
124
+ append_file(Rails.root.join('db', 'seeds.rb'), "Alchemy::Seeder.seed!\n")
125
+ rake('alchemy:db:seed', abort_on_failure: true)
132
126
  end
133
127
  end
134
128
 
@@ -136,6 +130,12 @@ module Alchemy
136
130
  append_file "vendor/assets/javascripts/alchemy/admin/all.js",
137
131
  "//= require alchemy/solidus/admin.js"
138
132
  end
133
+
134
+ private
135
+
136
+ def alchemy_devise_present?
137
+ defined?(Alchemy::Devise::Engine)
138
+ end
139
139
  end
140
140
  end
141
141
  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.0.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: 2019-12-13 00:00:00.000000000 Z
11
+ date: 2019-12-17 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
- })