refinerycms-products 1.0.0 → 1.0.1
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.
- data/app/controllers/addresses_controller.rb +22 -22
- data/app/controllers/admin/carts_controller.rb +7 -7
- data/app/controllers/admin/categories_controller.rb +50 -50
- data/app/controllers/admin/customers_controller.rb +12 -12
- data/app/controllers/admin/line_items_controller.rb +7 -7
- data/app/controllers/admin/products_controller.rb +23 -23
- data/app/controllers/carts_controller.rb +110 -110
- data/app/controllers/categories_controller.rb +32 -32
- data/app/controllers/customers_controller.rb +33 -33
- data/app/controllers/line_items_controller.rb +8 -8
- data/app/controllers/products_controller.rb +61 -61
- data/app/controllers/profiles_controller.rb +36 -36
- data/app/helpers/address_helper.rb +20 -20
- data/app/helpers/products_helper.rb +41 -33
- data/app/models/address.rb +18 -18
- data/app/models/cart.rb +54 -54
- data/app/models/category.rb +28 -28
- data/app/models/customer.rb +32 -32
- data/app/models/line_item.rb +28 -28
- data/app/models/product.rb +46 -46
- data/app/views/addresses/edit.html.erb +42 -42
- data/app/views/admin/carts/_actions.html.erb +27 -27
- data/app/views/admin/carts/_cart.html.erb +18 -18
- data/app/views/admin/carts/_carts.html.erb +1 -1
- data/app/views/admin/carts/_form.html.erb +24 -24
- data/app/views/admin/carts/_records.html.erb +17 -17
- data/app/views/admin/carts/_sortable_list.html.erb +7 -7
- data/app/views/admin/carts/edit.html.erb +1 -1
- data/app/views/admin/carts/index.html.erb +10 -10
- data/app/views/admin/carts/new.html.erb +1 -1
- data/app/views/admin/categories/_actions.html.erb +27 -27
- data/app/views/admin/categories/_categories.html.erb +1 -1
- data/app/views/admin/categories/_category.html.erb +25 -25
- data/app/views/admin/categories/_form.html.erb +49 -49
- data/app/views/admin/categories/_records.html.erb +17 -17
- data/app/views/admin/categories/_sortable_list.html.erb +10 -10
- data/app/views/admin/categories/edit.html.erb +1 -1
- data/app/views/admin/categories/index.html.erb +12 -12
- data/app/views/admin/categories/new.html.erb +1 -1
- data/app/views/admin/customers/_actions.html.erb +27 -27
- data/app/views/admin/customers/_customer.html.erb +18 -18
- data/app/views/admin/customers/_customers.html.erb +1 -1
- data/app/views/admin/customers/_form.html.erb +40 -40
- data/app/views/admin/customers/_records.html.erb +17 -17
- data/app/views/admin/customers/_sortable_list.html.erb +7 -7
- data/app/views/admin/customers/edit.html.erb +1 -1
- data/app/views/admin/customers/index.html.erb +10 -10
- data/app/views/admin/customers/new.html.erb +1 -1
- data/app/views/admin/customers/show.html.erb +59 -59
- data/app/views/admin/line_items/_actions.html.erb +27 -27
- data/app/views/admin/line_items/_form.html.erb +29 -29
- data/app/views/admin/line_items/_line_item.html.erb +18 -18
- data/app/views/admin/line_items/_line_items.html.erb +1 -1
- data/app/views/admin/line_items/_records.html.erb +17 -17
- data/app/views/admin/line_items/_sortable_list.html.erb +7 -7
- data/app/views/admin/line_items/edit.html.erb +1 -1
- data/app/views/admin/line_items/index.html.erb +10 -10
- data/app/views/admin/line_items/new.html.erb +1 -1
- data/app/views/admin/products/_actions.html.erb +42 -42
- data/app/views/admin/products/_form.html.erb +120 -120
- data/app/views/admin/products/_product.html.erb +23 -23
- data/app/views/admin/products/_products.html.erb +1 -1
- data/app/views/admin/products/_records.html.erb +17 -17
- data/app/views/admin/products/_sortable_list.html.erb +13 -13
- data/app/views/admin/products/edit.html.erb +1 -1
- data/app/views/admin/products/index.html.erb +12 -12
- data/app/views/admin/products/new.html.erb +1 -1
- data/app/views/carts/show.html.erb +56 -56
- data/app/views/categories/index.html.erb +11 -11
- data/app/views/categories/show.html.erb +33 -33
- data/app/views/customers/index.html.erb +11 -11
- data/app/views/customers/show.html.erb +52 -52
- data/app/views/line_items/index.html.erb +11 -11
- data/app/views/line_items/show.html.erb +39 -39
- data/app/views/products/index.html.erb +33 -33
- data/app/views/products/show.html.erb +65 -65
- data/app/views/profiles/_order_history.html.erb +23 -23
- data/app/views/profiles/_show_address.html.erb +3 -3
- data/app/views/profiles/account_details.html.erb +31 -31
- data/app/views/profiles/address_details.html.erb +9 -9
- data/app/views/profiles/index.html.erb +75 -75
- data/app/views/profiles/order_history_details.html.erb +39 -39
- data/config/locales/en.yml +97 -97
- data/config/locales/fr.yml +25 -25
- data/config/locales/lolcat.yml +25 -25
- data/config/locales/nb.yml +21 -21
- data/config/locales/nl.yml +21 -21
- data/config/routes.rb +58 -58
- data/lib/generators/refinerycms_products_generator.rb +5 -5
- data/lib/refinerycms-carts.rb +31 -31
- data/lib/refinerycms-categories.rb +30 -30
- data/lib/refinerycms-customers.rb +34 -34
- data/lib/refinerycms-line_items.rb +30 -30
- data/lib/refinerycms-products.rb +65 -65
- data/lib/tasks/products.rake +12 -12
- metadata +95 -98
data/config/routes.rb
CHANGED
@@ -1,58 +1,58 @@
|
|
1
|
-
::Refinery::Application.routes.draw do
|
2
|
-
devise_for :customers
|
3
|
-
|
4
|
-
resources :products, :only => [:index, :show]
|
5
|
-
|
6
|
-
resources :categories, :only => [:index, :show] do
|
7
|
-
resources :products, :only => [:index, :show]
|
8
|
-
end
|
9
|
-
|
10
|
-
resources :customers, :only => [:show]
|
11
|
-
resources :addresses
|
12
|
-
resources :profiles
|
13
|
-
resources :carts, :only => [:show]
|
14
|
-
resources :line_items, :only => [:delete]
|
15
|
-
|
16
|
-
match "account_details" => "profiles#account_details", :as => "account_details"
|
17
|
-
match "address_details" => "profiles#address_details", :as => "address_details"
|
18
|
-
|
19
|
-
match "add_to_cart/:product_id" => "carts#add_to_cart", :as => "add_to_cart"
|
20
|
-
match "show_cart" => "carts#show_cart", :as => "show_cart"
|
21
|
-
match "increment_cart/:product_id" => "carts#increment_cart", :as => "increment_cart"
|
22
|
-
match "destroy_line_item/:id" => "line_items#destroy", :as => "destroy_line_item"
|
23
|
-
|
24
|
-
# Famous Categories
|
25
|
-
match 'best_selling' => 'products#best_selling', :as => :best_selling
|
26
|
-
match 'featured' => 'products#featured', :as => :featured
|
27
|
-
match 'new_product' => 'products#new_product', :as => :new_product
|
28
|
-
|
29
|
-
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
|
30
|
-
resources :products do
|
31
|
-
collection do
|
32
|
-
put :update_prices
|
33
|
-
post :update_positions
|
34
|
-
end
|
35
|
-
end
|
36
|
-
resources :categories, :except => :show do
|
37
|
-
resources :products
|
38
|
-
collection do
|
39
|
-
post :update_positions
|
40
|
-
end
|
41
|
-
end
|
42
|
-
resources :customers do
|
43
|
-
collection do
|
44
|
-
post :update_positions
|
45
|
-
end
|
46
|
-
end
|
47
|
-
resources :carts, :except => :show do
|
48
|
-
collection do
|
49
|
-
post :update_positions
|
50
|
-
end
|
51
|
-
end
|
52
|
-
resources :line_items, :except => :show do
|
53
|
-
collection do
|
54
|
-
post :update_positions
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
1
|
+
::Refinery::Application.routes.draw do
|
2
|
+
devise_for :customers
|
3
|
+
|
4
|
+
resources :products, :only => [:index, :show]
|
5
|
+
|
6
|
+
resources :categories, :only => [:index, :show] do
|
7
|
+
resources :products, :only => [:index, :show]
|
8
|
+
end
|
9
|
+
|
10
|
+
resources :customers, :only => [:show]
|
11
|
+
resources :addresses
|
12
|
+
resources :profiles
|
13
|
+
resources :carts, :only => [:show]
|
14
|
+
resources :line_items, :only => [:delete]
|
15
|
+
|
16
|
+
match "account_details" => "profiles#account_details", :as => "account_details"
|
17
|
+
match "address_details" => "profiles#address_details", :as => "address_details"
|
18
|
+
|
19
|
+
match "add_to_cart/:product_id" => "carts#add_to_cart", :as => "add_to_cart"
|
20
|
+
match "show_cart" => "carts#show_cart", :as => "show_cart"
|
21
|
+
match "increment_cart/:product_id" => "carts#increment_cart", :as => "increment_cart"
|
22
|
+
match "destroy_line_item/:id" => "line_items#destroy", :as => "destroy_line_item"
|
23
|
+
|
24
|
+
# Famous Categories
|
25
|
+
match 'best_selling' => 'products#best_selling', :as => :best_selling
|
26
|
+
match 'featured' => 'products#featured', :as => :featured
|
27
|
+
match 'new_product' => 'products#new_product', :as => :new_product
|
28
|
+
|
29
|
+
scope(:path => 'refinery', :as => 'admin', :module => 'admin') do
|
30
|
+
resources :products do
|
31
|
+
collection do
|
32
|
+
put :update_prices
|
33
|
+
post :update_positions
|
34
|
+
end
|
35
|
+
end
|
36
|
+
resources :categories, :except => :show do
|
37
|
+
resources :products
|
38
|
+
collection do
|
39
|
+
post :update_positions
|
40
|
+
end
|
41
|
+
end
|
42
|
+
resources :customers do
|
43
|
+
collection do
|
44
|
+
post :update_positions
|
45
|
+
end
|
46
|
+
end
|
47
|
+
resources :carts, :except => :show do
|
48
|
+
collection do
|
49
|
+
post :update_positions
|
50
|
+
end
|
51
|
+
end
|
52
|
+
resources :line_items, :except => :show do
|
53
|
+
collection do
|
54
|
+
post :update_positions
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
class RefinerycmsProducts < Refinery::Generators::EngineInstaller
|
2
|
-
|
3
|
-
source_root File.expand_path('../../../', __FILE__)
|
4
|
-
engine_name "products"
|
5
|
-
|
1
|
+
class RefinerycmsProducts < Refinery::Generators::EngineInstaller
|
2
|
+
|
3
|
+
source_root File.expand_path('../../../', __FILE__)
|
4
|
+
engine_name "products"
|
5
|
+
|
6
6
|
end
|
data/lib/refinerycms-carts.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
require 'refinerycms-base'
|
2
|
-
|
3
|
-
module Refinery
|
4
|
-
module Carts
|
5
|
-
|
6
|
-
class << self
|
7
|
-
attr_accessor :root
|
8
|
-
def root
|
9
|
-
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Engine < Rails::Engine
|
14
|
-
initializer "static assets" do |app|
|
15
|
-
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
16
|
-
end
|
17
|
-
|
18
|
-
config.after_initialize do
|
19
|
-
Refinery::Plugin.register do |plugin|
|
20
|
-
plugin.name = "carts"
|
21
|
-
plugin.pathname = root
|
22
|
-
plugin.activity = {
|
23
|
-
:class => Cart
|
24
|
-
}
|
25
|
-
plugin.hide_from_menu = true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
1
|
+
require 'refinerycms-base'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module Carts
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :root
|
8
|
+
def root
|
9
|
+
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Engine < Rails::Engine
|
14
|
+
initializer "static assets" do |app|
|
15
|
+
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
16
|
+
end
|
17
|
+
|
18
|
+
config.after_initialize do
|
19
|
+
Refinery::Plugin.register do |plugin|
|
20
|
+
plugin.name = "carts"
|
21
|
+
plugin.pathname = root
|
22
|
+
plugin.activity = {
|
23
|
+
:class => Cart
|
24
|
+
}
|
25
|
+
plugin.hide_from_menu = true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
32
|
require File.expand_path('../refinerycms-line_items', __FILE__)
|
@@ -1,30 +1,30 @@
|
|
1
|
-
require 'refinerycms-base'
|
2
|
-
|
3
|
-
module Refinery
|
4
|
-
module Categories
|
5
|
-
|
6
|
-
class << self
|
7
|
-
attr_accessor :root
|
8
|
-
def root
|
9
|
-
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Engine < Rails::Engine
|
14
|
-
initializer "static assets" do |app|
|
15
|
-
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
16
|
-
end
|
17
|
-
|
18
|
-
config.after_initialize do
|
19
|
-
Refinery::Plugin.register do |plugin|
|
20
|
-
plugin.name = "categories"
|
21
|
-
plugin.pathname = root
|
22
|
-
plugin.activity = {
|
23
|
-
:class => Category,
|
24
|
-
:title => 'name'
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
require 'refinerycms-base'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module Categories
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :root
|
8
|
+
def root
|
9
|
+
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Engine < Rails::Engine
|
14
|
+
initializer "static assets" do |app|
|
15
|
+
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
16
|
+
end
|
17
|
+
|
18
|
+
config.after_initialize do
|
19
|
+
Refinery::Plugin.register do |plugin|
|
20
|
+
plugin.name = "categories"
|
21
|
+
plugin.pathname = root
|
22
|
+
plugin.activity = {
|
23
|
+
:class => Category,
|
24
|
+
:title => 'name'
|
25
|
+
}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,34 +1,34 @@
|
|
1
|
-
require 'refinerycms-base'
|
2
|
-
|
3
|
-
module Refinery
|
4
|
-
module Customers
|
5
|
-
|
6
|
-
class << self
|
7
|
-
attr_accessor :root
|
8
|
-
def root
|
9
|
-
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Engine < Rails::Engine
|
14
|
-
initializer "static assets" do |app|
|
15
|
-
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
16
|
-
end
|
17
|
-
|
18
|
-
initializer 'Customer.helper' do |app|
|
19
|
-
ActionView::Base.send :include, AddressHelper
|
20
|
-
end
|
21
|
-
|
22
|
-
config.after_initialize do
|
23
|
-
Refinery::Plugin.register do |plugin|
|
24
|
-
plugin.name = "customers"
|
25
|
-
plugin.pathname = root
|
26
|
-
plugin.activity = {
|
27
|
-
:class => Customer,
|
28
|
-
:title => 'name'
|
29
|
-
}
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
require 'refinerycms-base'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module Customers
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :root
|
8
|
+
def root
|
9
|
+
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Engine < Rails::Engine
|
14
|
+
initializer "static assets" do |app|
|
15
|
+
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer 'Customer.helper' do |app|
|
19
|
+
ActionView::Base.send :include, AddressHelper
|
20
|
+
end
|
21
|
+
|
22
|
+
config.after_initialize do
|
23
|
+
Refinery::Plugin.register do |plugin|
|
24
|
+
plugin.name = "customers"
|
25
|
+
plugin.pathname = root
|
26
|
+
plugin.activity = {
|
27
|
+
:class => Customer,
|
28
|
+
:title => 'name'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
require 'refinerycms-base'
|
2
|
-
|
3
|
-
module Refinery
|
4
|
-
module LineItems
|
5
|
-
|
6
|
-
class << self
|
7
|
-
attr_accessor :root
|
8
|
-
def root
|
9
|
-
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Engine < Rails::Engine
|
14
|
-
initializer "static assets" do |app|
|
15
|
-
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
16
|
-
end
|
17
|
-
|
18
|
-
config.after_initialize do
|
19
|
-
Refinery::Plugin.register do |plugin|
|
20
|
-
plugin.name = "line_items"
|
21
|
-
plugin.pathname = root
|
22
|
-
plugin.activity = {
|
23
|
-
:class => LineItem
|
24
|
-
}
|
25
|
-
plugin.hide_from_menu = true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
1
|
+
require 'refinerycms-base'
|
2
|
+
|
3
|
+
module Refinery
|
4
|
+
module LineItems
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :root
|
8
|
+
def root
|
9
|
+
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class Engine < Rails::Engine
|
14
|
+
initializer "static assets" do |app|
|
15
|
+
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
16
|
+
end
|
17
|
+
|
18
|
+
config.after_initialize do
|
19
|
+
Refinery::Plugin.register do |plugin|
|
20
|
+
plugin.name = "line_items"
|
21
|
+
plugin.pathname = root
|
22
|
+
plugin.activity = {
|
23
|
+
:class => LineItem
|
24
|
+
}
|
25
|
+
plugin.hide_from_menu = true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/refinerycms-products.rb
CHANGED
@@ -1,65 +1,65 @@
|
|
1
|
-
require 'refinerycms-base'
|
2
|
-
require 'refinerycms-categories'
|
3
|
-
require 'refinerycms-customers'
|
4
|
-
require 'refinerycms-carts'
|
5
|
-
require 'refinerycms-line_items'
|
6
|
-
require 'refinery'
|
7
|
-
|
8
|
-
module Refinery
|
9
|
-
module Products
|
10
|
-
|
11
|
-
class << self
|
12
|
-
attr_accessor :root
|
13
|
-
def root
|
14
|
-
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Engine < Rails::Engine
|
19
|
-
initializer "static assets" do |app|
|
20
|
-
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
21
|
-
end
|
22
|
-
|
23
|
-
initializer 'Products.helper' do |app|
|
24
|
-
ActionView::Base.send :include, ProductsHelper
|
25
|
-
end
|
26
|
-
|
27
|
-
#refinery.after_inclusion do
|
28
|
-
# #Page.send :has_many_page_images
|
29
|
-
# #Product.class_eval { has_many :variants }
|
30
|
-
# #LineItem.class_eval { belongs_to :variant}
|
31
|
-
#
|
32
|
-
# #require 'line_item'
|
33
|
-
# #require 'product'
|
34
|
-
#
|
35
|
-
# LineItem rescue NameError #this is the ugliest thing ever. Need to reference so it autoloads and then we check for it
|
36
|
-
# Product rescue NameError #this is the ugliest thing ever. Need to reference so it autoloads and then we check for it
|
37
|
-
#
|
38
|
-
# puts "******************************** defined?(LineItem)= #{defined?(LineItem)}"
|
39
|
-
# puts "******************************** defined?(Product)= #{defined?(Product)}"
|
40
|
-
#
|
41
|
-
# Product.class_eval { has_many :variants }
|
42
|
-
# LineItem.class_eval { belongs_to :variant}
|
43
|
-
#
|
44
|
-
# #LineItem.send :include, Refinery::Variants::LineItemExtender
|
45
|
-
# #Product.send :include, Refinery::Variants::ProductExtender
|
46
|
-
#end
|
47
|
-
|
48
|
-
#config.to_prepare do
|
49
|
-
# Product.class_eval { has_many :variants }
|
50
|
-
# LineItem.class_eval { belongs_to :variant}
|
51
|
-
#end
|
52
|
-
|
53
|
-
config.after_initialize do
|
54
|
-
Refinery::Plugin.register do |plugin|
|
55
|
-
plugin.name = "products"
|
56
|
-
plugin.pathname = root
|
57
|
-
plugin.activity = {
|
58
|
-
:class => Product,
|
59
|
-
:title => 'name'
|
60
|
-
}
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
1
|
+
require 'refinerycms-base'
|
2
|
+
require 'refinerycms-categories'
|
3
|
+
require 'refinerycms-customers'
|
4
|
+
require 'refinerycms-carts'
|
5
|
+
require 'refinerycms-line_items'
|
6
|
+
require 'refinery'
|
7
|
+
|
8
|
+
module Refinery
|
9
|
+
module Products
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :root
|
13
|
+
def root
|
14
|
+
@root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Engine < Rails::Engine
|
19
|
+
initializer "static assets" do |app|
|
20
|
+
app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/public"
|
21
|
+
end
|
22
|
+
|
23
|
+
initializer 'Products.helper' do |app|
|
24
|
+
ActionView::Base.send :include, ProductsHelper
|
25
|
+
end
|
26
|
+
|
27
|
+
#refinery.after_inclusion do
|
28
|
+
# #Page.send :has_many_page_images
|
29
|
+
# #Product.class_eval { has_many :variants }
|
30
|
+
# #LineItem.class_eval { belongs_to :variant}
|
31
|
+
#
|
32
|
+
# #require 'line_item'
|
33
|
+
# #require 'product'
|
34
|
+
#
|
35
|
+
# LineItem rescue NameError #this is the ugliest thing ever. Need to reference so it autoloads and then we check for it
|
36
|
+
# Product rescue NameError #this is the ugliest thing ever. Need to reference so it autoloads and then we check for it
|
37
|
+
#
|
38
|
+
# puts "******************************** defined?(LineItem)= #{defined?(LineItem)}"
|
39
|
+
# puts "******************************** defined?(Product)= #{defined?(Product)}"
|
40
|
+
#
|
41
|
+
# Product.class_eval { has_many :variants }
|
42
|
+
# LineItem.class_eval { belongs_to :variant}
|
43
|
+
#
|
44
|
+
# #LineItem.send :include, Refinery::Variants::LineItemExtender
|
45
|
+
# #Product.send :include, Refinery::Variants::ProductExtender
|
46
|
+
#end
|
47
|
+
|
48
|
+
#config.to_prepare do
|
49
|
+
# Product.class_eval { has_many :variants }
|
50
|
+
# LineItem.class_eval { belongs_to :variant}
|
51
|
+
#end
|
52
|
+
|
53
|
+
config.after_initialize do
|
54
|
+
Refinery::Plugin.register do |plugin|
|
55
|
+
plugin.name = "products"
|
56
|
+
plugin.pathname = root
|
57
|
+
plugin.activity = {
|
58
|
+
:class => Product,
|
59
|
+
:title => 'name'
|
60
|
+
}
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|