alchemy-solidus 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5df79cbf96a886200a6dc90ed749a92e3b10db90
4
+ data.tar.gz: ed76a4ccf6ca300da5d06a2a5ffc68d6f4b10581
5
+ SHA512:
6
+ metadata.gz: a13760c47272faa5dc452879ac36e614600ff153eb5832a732c30ca0c9607370561ea7612bce44aca4a202ed294784fb0697f83b878645e89ec3d2368335cc54
7
+ data.tar.gz: bb155668e332b5adb205ed991f39663a672b2bb9c0fce3b2947820cc86225e44405bb6ea838e177b614404a9a7ec6acd71c324d3822477fed4e25567c53c4037
@@ -0,0 +1,7 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/log/*.log
6
+ test/dummy/tmp/
7
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in alchemy-solidus.gemspec
4
+ gemspec
5
+
6
+ gem 'sqlite3'
7
+ gem 'alchemy-devise'
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2012-14, magic labs*
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation and/or
12
+ other materials provided with the distribution.
13
+
14
+ * Neither the name of magic labs* nor the names of its contributors may be used to
15
+ endorse or promote products derived from this software without specific prior written permission.
16
+
17
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
18
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
19
+ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
20
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22
+ OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,226 @@
1
+ # Alchemy CMS Solidus Integration
2
+
3
+ The World's Most Flexible E-Commerce Platform meets The World's Most Flexible Content Management System!
4
+
5
+ This gem is a [Alchemy CMS](https://github.com/AlchemyCMS/alchemy_cms) and [Solidus](https://github.com/solidusio/solidus) connector.
6
+
7
+ ### For now it does this:
8
+
9
+ 1. It provides tabs in Alchemy and Solidus menus to easily switch between both backends
10
+ 2. It offers two new Essences for Alchemy called `EssenceSpreeProduct` and `EssenceSpreeTaxon` that you can use to place Spree products and/or Taxons on your pages.
11
+ 3. Shares admin sessions and user abilities between Alchemy and Solidus.
12
+
13
+ ### Compatibility
14
+
15
+ ## Solidus
16
+
17
+ This version runs with Solidus 1.0 and above.
18
+
19
+ ## Alchemy
20
+
21
+ This version runs with Alchemy 3.2 and above.
22
+
23
+ ## Installation
24
+
25
+ Add this line to your application's Gemfile:
26
+
27
+ ```ruby
28
+ gem 'alchemy-solidus', github: 'AlchemyCMS/alchemy-solidus', branch: 'master'
29
+ ```
30
+
31
+ Install the gem with:
32
+
33
+ ```shell
34
+ $ bundle install
35
+ ```
36
+
37
+ ### Authentication system installation
38
+
39
+ Both Alchemy and Solidus come without an authentication system in place. You will need to choose an authentication system yourself. There are 3 available options. Whichever you choose, you need to instruct Solidus & Alchemy about your choice of authentication system.
40
+
41
+ Here are the steps for each option:
42
+
43
+ #### 1. Option: Use [Solidus Auth Devise](https://github.com/solidusio/solidus_auth_devise)
44
+
45
+ **Recommended for:**
46
+ - An existing Solidus installation (`gem 'solidus_auth_devise'` should already be in your Gemfile).
47
+ - You are just adding Alchemy
48
+
49
+ To use Solidus Auth Devise, instruct Alchemy to use the `Spree::User` class:
50
+
51
+ ```ruby
52
+ # config/initializers/alchemy.rb
53
+
54
+ # Tell Alchemy to use the Spree::User class
55
+ Alchemy.user_class_name = 'Spree::User'
56
+ Alchemy.current_user_method = :spree_current_user
57
+
58
+ # Load the Spree.user_class decorator for Alchemy roles
59
+ require 'alchemy/solidus/spree_user_decorator'
60
+
61
+ # Include the Spree controller helpers to render the
62
+ # alchemy pages within the default Spree layout
63
+ Alchemy::BaseHelper.send :include, Spree::BaseHelper
64
+ Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Common
65
+ Alchemy::BaseController.send :include, Spree::Core::ControllerHelpers::Store
66
+ ```
67
+
68
+ #### 2. Option: Use [Alchemy Devise](https://github.com/AlchemyCMS/alchemy-devise)
69
+
70
+ **Recommended for:**
71
+ - An existing Alchemy installation
72
+ - You don't have an authentication system and don't want to role an authentication system on your own.
73
+
74
+ Add `alchemy-devise` to your `Gemfile`
75
+
76
+ ```ruby
77
+ # Gemfile
78
+ gem 'alchemy-devise', '~> 3.2'
79
+ ```
80
+
81
+ and install it:
82
+
83
+ ```shell
84
+ $ bundle install
85
+ $ bundle exec rails g alchemy:devise:install
86
+ ```
87
+
88
+ Run the Solidus installer:
89
+
90
+ *NOTE*: Skip this if you already have a running Solidus installation.
91
+
92
+ ```shell
93
+ $ bundle exec rails g spree:install
94
+ ```
95
+
96
+ Then run the solidus custom user generator:
97
+
98
+ ```shell
99
+ $ bundle exec rails g spree:custom_user Alchemy::User
100
+ ```
101
+
102
+ Now you'll need to instruct Solidus to use the Alchemy User class:
103
+
104
+ ```ruby
105
+ # config/initializers/spree.rb
106
+ ...
107
+ Spree.user_class = "Alchemy::User"
108
+ require 'alchemy/solidus/alchemy_user_decorator'
109
+ ...
110
+ ```
111
+
112
+ and tell Solidus about Alchemy's path helpers:
113
+
114
+ ```ruby
115
+ # lib/spree/authentication_helpers.rb
116
+ ...
117
+ def spree_login_path
118
+ alchemy.login_path
119
+ end
120
+
121
+ def spree_signup_path
122
+ alchemy.signup_path
123
+ end
124
+
125
+ def spree_logout_path
126
+ alchemy.logout_path
127
+ end
128
+ ...
129
+ ```
130
+
131
+ #### 3. Option: Build their own authentication
132
+
133
+ Please follow the [spree custom authentication](https://guides.spreecommerce.com/developer/authentication.html) and the [Alchemy custom authentication](http://guides.alchemy-cms.com/edge/custom_authentication.html) guides in order to integrate your custom user with Solidus and Alchemy.
134
+
135
+ #### In either case
136
+
137
+ Install the migrations
138
+
139
+ ```shell
140
+ $ bundle exec rake alchemy_solidus:install:migrations
141
+ ```
142
+
143
+ Run the installer of Alchemy
144
+
145
+ ```shell
146
+ $ bundle exec rake alchemy:install
147
+ ```
148
+
149
+ and follow the on screen instructions.
150
+
151
+ ### Render Alchemy Content in Solidus views
152
+
153
+ If you plan to render Alchemy content in your Solidus views (ie. a global header or footer section), you need to include the Alchemy view helpers and language store in your Solidus controllers.
154
+
155
+ ```ruby
156
+ # config/initializers/solidus.rb
157
+ ...
158
+ Spree::BaseController.class_eval do
159
+ include Alchemy::ControllerActions
160
+ end
161
+ ```
162
+
163
+ #### With Solidus::Auth::Devise
164
+
165
+ If you also use the `Spree::User` class you need to additionally tell the Solidus user sessions controller to include the Alchemy related helpers and methods.
166
+
167
+ ```ruby
168
+ # config/initializers/spree.rb
169
+ ...
170
+ Spree::UserSessionsController.class_eval do
171
+ include Alchemy::ControllerActions
172
+ end
173
+ ```
174
+
175
+ ## Usage
176
+
177
+ ### Create a new Element for Alchemy
178
+
179
+ ```yaml
180
+ # config/alchemy/elements.yml
181
+ - name: product
182
+ contents:
183
+ - name: spree_product
184
+ type: EssenceSpreeProduct
185
+
186
+ - name: product_category
187
+ contents:
188
+ - name: spree_taxon
189
+ type: EssenceSpreeTaxon
190
+ ```
191
+
192
+ ### Generate the views
193
+
194
+ ```sh
195
+ $ rails g alchemy:elements --skip
196
+ ```
197
+
198
+ ### Place this element on a page layout
199
+
200
+ ```yaml
201
+ # config/alchemy/page_layouts.yml
202
+ - name: product
203
+ elements: [product]
204
+ - name: products
205
+ elements: [product_category]
206
+ ```
207
+
208
+ ### You can haz Solidus product and taxons!
209
+
210
+ ```erb
211
+ # app/views/alchemy/elements/_product_view.html.erb
212
+ <%= element.ingredient('spree_product') %>
213
+
214
+ # app/views/alchemy/elements/_product_category_view.html.erb
215
+ <%= element.ingredient('spree_taxon') %>
216
+ ```
217
+
218
+ Alchemy :heart: Solidus!
219
+
220
+ ## Contributing
221
+
222
+ 1. Fork it
223
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
224
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
225
+ 4. Push to the branch (`git push origin my-new-feature`)
226
+ 5. Create new Pull Request
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'AlchemySolidus'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/alchemy/solidus/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Thomas von Deyen"]
6
+ gem.email = ["tvd@magiclabs.de"]
7
+ gem.description = %q{A Alchemy CMS and Solidus connector}
8
+ gem.summary = %q{The World's Most Flexible E-Commerce Platform meets The World's Most Flexible Content Management System!}
9
+ gem.homepage = "https://github.com/AlchemyCMS/alchemy-solidus"
10
+ gem.license = 'BSD New'
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "alchemy-solidus"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Alchemy::Solidus::VERSION
17
+
18
+ gem.add_dependency('alchemy_cms', ['~> 3.2'])
19
+ gem.add_dependency('solidus', ['~> 1.0'])
20
+ gem.add_dependency('deface', ['~> 1.0'])
21
+ end
@@ -0,0 +1,14 @@
1
+ module Alchemy
2
+ class EssenceSpreeProduct < ActiveRecord::Base
3
+ belongs_to :product, class_name: "Spree::Product", foreign_key: 'spree_product_id'
4
+
5
+ acts_as_essence(
6
+ ingredient_column: 'spree_product_id',
7
+ preview_text_method: 'name'
8
+ )
9
+
10
+ def ingredient
11
+ product
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Alchemy
2
+ class EssenceSpreeTaxon < ActiveRecord::Base
3
+ belongs_to :taxon, class_name: "Spree::Taxon", foreign_key: 'taxon_id'
4
+
5
+ acts_as_essence(
6
+ ingredient_column: 'taxon_id',
7
+ preview_text_method: 'name'
8
+ )
9
+
10
+ def ingredient
11
+ taxon
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ Deface::Override.new(
2
+ virtual_path: "spree/admin/shared/_menu",
3
+ name: "alchemy_cms_tab",
4
+ insert_bottom: '[data-hook="admin_tabs"]',
5
+ partial: "alchemy/admin/shared/alchemy_solidus_tab"
6
+ )
@@ -0,0 +1,3 @@
1
+ <% if Spree.user_class && can?(:edit_content, Alchemy::Page) %>
2
+ <%= tab *[:cms], url: alchemy.admin_pages_path, icon: 'copy' %>
3
+ <% end %>
@@ -0,0 +1,9 @@
1
+ <div class="content_editor essence_spree_product">
2
+ <label><%= render_content_name(content) %></label>
3
+ <%= select_tag(
4
+ content.form_field_name,
5
+ options_from_collection_for_select(Spree::Product.not_deleted, :id, :name, content.essence.spree_product_id),
6
+ class: ['alchemy_selectbox very_long', html_options[:class]].join(' '),
7
+ style: html_options[:style]
8
+ ) %>
9
+ </div>
@@ -0,0 +1,16 @@
1
+ <div class="content_editor">
2
+ <label><%= render_content_name(content) %></label>
3
+ <%= select_tag(
4
+ content.form_field_name,
5
+ option_groups_from_collection_for_select(
6
+ Spree::Taxon.all,
7
+ :children,
8
+ :name,
9
+ :id,
10
+ :name,
11
+ content.essence.taxon_id
12
+ ),
13
+ :class => ['alchemy_selectbox very_long', html_options[:class]].join(' '),
14
+ :style => html_options[:style]
15
+ ) %>
16
+ </div>
@@ -0,0 +1,10 @@
1
+ Alchemy::Modules.register_module({
2
+ engine_name: 'spree',
3
+ name: 'solidus',
4
+ navigation: {
5
+ controller: 'spree/admin/orders',
6
+ action: 'index',
7
+ name: 'Shop',
8
+ image: 'alchemy/solidus/alchemy_module_icon.png'
9
+ }
10
+ })
@@ -0,0 +1,8 @@
1
+ class CreateAlchemyEssenceSpreeProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table 'alchemy_essence_spree_products' do |t|
4
+ t.integer :spree_product_id
5
+ end
6
+ add_index :alchemy_essence_spree_products, :spree_product_id
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ class CreateAlchemyEssenceSpreeTaxons < ActiveRecord::Migration
2
+ def change
3
+ create_table :alchemy_essence_spree_taxons do |t|
4
+ t.references :taxon
5
+
6
+ t.timestamps
7
+ end
8
+ add_index :alchemy_essence_spree_taxons, :taxon_id
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ require "alchemy_cms"
2
+ require "solidus"
3
+ require "alchemy/solidus/engine"
@@ -0,0 +1,10 @@
1
+ Alchemy::User.class_eval do
2
+
3
+ def spree_roles
4
+ if admin?
5
+ ::Spree::Role.where(name: 'admin')
6
+ else
7
+ ::Spree::Role.none
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ module Alchemy
2
+ module Solidus
3
+ class Engine < ::Rails::Engine
4
+ engine_name 'alchemy_solidus'
5
+
6
+ def self.activate
7
+ Alchemy.register_ability(::Spree::Ability)
8
+ end
9
+
10
+ config.to_prepare &method(:activate).to_proc
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ Spree::User.class_eval do
2
+
3
+ def alchemy_roles
4
+ if has_spree_role?(:admin)
5
+ %w(admin)
6
+ else
7
+ []
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Alchemy
2
+ module Solidus
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alchemy-solidus
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Thomas von Deyen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: alchemy_cms
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: solidus
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: deface
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ description: A Alchemy CMS and Solidus connector
56
+ email:
57
+ - tvd@magiclabs.de
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE
65
+ - README.md
66
+ - Rakefile
67
+ - alchemy-solidus.gemspec
68
+ - app/assets/images/alchemy/solidus/alchemy_module_icon.png
69
+ - app/models/alchemy/essence_spree_product.rb
70
+ - app/models/alchemy/essence_spree_taxon.rb
71
+ - app/overrides/alchemy_solidus_tab.rb
72
+ - app/views/alchemy/admin/shared/_alchemy_solidus_tab.html.erb
73
+ - app/views/alchemy/essences/_essence_spree_product_editor.html.erb
74
+ - app/views/alchemy/essences/_essence_spree_product_view.html.erb
75
+ - app/views/alchemy/essences/_essence_spree_taxon_editor.html.erb
76
+ - app/views/alchemy/essences/_essence_spree_taxon_view.html.erb
77
+ - config/initializers/alchemy.rb
78
+ - db/migrate/20120229160509_create_alchemy_essence_spree_products.rb
79
+ - db/migrate/20131030140218_create_alchemy_essence_spree_taxons.rb
80
+ - lib/alchemy-solidus.rb
81
+ - lib/alchemy/solidus/alchemy_user_decorator.rb
82
+ - lib/alchemy/solidus/engine.rb
83
+ - lib/alchemy/solidus/spree_user_decorator.rb
84
+ - lib/alchemy/solidus/version.rb
85
+ homepage: https://github.com/AlchemyCMS/alchemy-solidus
86
+ licenses:
87
+ - BSD New
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.4.8
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: The World's Most Flexible E-Commerce Platform meets The World's Most Flexible
109
+ Content Management System!
110
+ test_files: []