camaleon_spree 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/plugins/camaleon_spree/main.js +15 -0
- data/app/assets/stylesheets/plugins/camaleon_spree/custom.css.scss +39 -0
- data/app/assets/stylesheets/plugins/camaleon_spree/main.css +5 -0
- data/app/controllers/plugins/camaleon_spree/admin_controller.rb +15 -0
- data/app/helpers/plugins/camaleon_spree/main_helper.rb +83 -0
- data/app/plugins/camaleon_spree/product_decorator.rb +4 -0
- data/app/views/camaleon_cms/admin/installers/welcome.html.erb +8 -0
- data/app/views/plugins/camaleon_spree/admin/_render_custom_fields_product.html.erb +5 -0
- data/app/views/plugins/camaleon_spree/admin/cama_plugin_settings.html.erb +4 -0
- data/app/views/plugins/camaleon_spree/admin/custom_field/_spree_categories.html.erb +3 -0
- data/app/views/plugins/camaleon_spree/admin/custom_field/_spree_products.html.erb +3 -0
- data/app/views/plugins/camaleon_spree/admin/settings.html.erb +16 -0
- data/app/views/plugins/camaleon_spree/examples/_layout_menus.html.erb +23 -0
- data/app/views/plugins/camaleon_spree/examples/_product_custom_fields.html.erb +15 -0
- data/app/views/plugins/camaleon_spree/examples/template_product_page.html.erb +45 -0
- data/config/camaleon_plugin.json +24 -0
- data/config/initializers/bread_crumb_onrails.rb +18 -0
- data/config/initializers/camaleon.rb +104 -0
- data/config/initializers/routes.rb +43 -0
- data/config/initializers/spree.rb +64 -0
- data/config/initializers/will_paginate.rb +24 -0
- data/config/routes.rb +21 -0
- data/db/migrate/20160831160611_add_camaleon_user_data_to_spree.rb +15 -0
- data/lib/camaleon_spree.rb +4 -0
- data/lib/camaleon_spree/engine.rb +4 -0
- data/lib/camaleon_spree/version.rb +3 -0
- data/lib/tasks/camaleon_spree_tasks.rake +4 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 39d35ba38f34032cfce0332e9557ee52fb31c4a8
|
4
|
+
data.tar.gz: 8110a524ba6f5620a1da12acfd87d0c664eedc53
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1954178f245f8a37fe410edb1ded31d1235898eef589494434e5899335b9497f1754ff602ded158635d08afd92034aaf676febe2e537a5f1f706c0c2898f037e
|
7
|
+
data.tar.gz: 6bade47eb96dbdbbcae16de1004af7b80b0abfa38b0bb7284c6c7f8cf9616d90ebb2ed650958123a833ad006bd2a6828dd7833cc3280bddf02b1d8efa3bf3f22
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2016 Owen Peredo
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'CamaleonSpree'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,15 @@
|
|
1
|
+
//= require camaleon_cms/admin/_custom_fields
|
2
|
+
//= require camaleon_cms/admin/_i18n
|
3
|
+
//= require camaleon_cms/admin/_translator.js
|
4
|
+
|
5
|
+
//= require camaleon_cms/admin/uploader/uploader_manifest
|
6
|
+
//= require camaleon_cms/admin/jquery.validate
|
7
|
+
//= require_self
|
8
|
+
function modal_fix_multiple(){
|
9
|
+
var activeModal = $('.modal.in:last', 'body').data('bs.modal');
|
10
|
+
if (activeModal) {
|
11
|
+
activeModal.$body.addClass('modal-open');
|
12
|
+
activeModal.enforceFocus();
|
13
|
+
activeModal.handleUpdate();
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
@mixin link_round($radio: 30) {
|
2
|
+
border: 1px solid #bbb;
|
3
|
+
border-radius: 50%;
|
4
|
+
color: #656d78;
|
5
|
+
display: block;
|
6
|
+
float: left;
|
7
|
+
height: #{$radio}px;
|
8
|
+
line-height: #{$radio - 3}px;
|
9
|
+
margin-left: 3px;
|
10
|
+
text-align: center;
|
11
|
+
transition: all 200ms ease 0s;
|
12
|
+
width: #{$radio}px;
|
13
|
+
}
|
14
|
+
|
15
|
+
.c-field-group {
|
16
|
+
.panel-controls{
|
17
|
+
display: none;
|
18
|
+
}
|
19
|
+
.item-custom-field {
|
20
|
+
margin-bottom: 15px;
|
21
|
+
> label {
|
22
|
+
display: block;
|
23
|
+
.shortcode_field input{
|
24
|
+
min-width: 250px;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
.actions{
|
28
|
+
overflow: hidden;
|
29
|
+
width: 67px;
|
30
|
+
float: left;
|
31
|
+
.fa {
|
32
|
+
@include link_round;
|
33
|
+
}
|
34
|
+
& + .group-input-fields-content {
|
35
|
+
margin-left: 75px;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Plugins::CamaleonSpree::AdminController < CamaleonCms::Apps::PluginsAdminController
|
2
|
+
include Plugins::CamaleonSpree::MainHelper
|
3
|
+
# show settings form
|
4
|
+
def settings
|
5
|
+
end
|
6
|
+
|
7
|
+
# save values from settings form
|
8
|
+
def save_settings
|
9
|
+
@plugin.set_options(params[:options]) if params[:options].present? # save option values
|
10
|
+
@plugin.set_metas(params[:metas]) if params[:metas].present? # save meta values
|
11
|
+
@plugin.set_field_values(params[:field_options]) if params[:field_options].present? # save custom field values
|
12
|
+
redirect_to url_for(action: :settings), notice: 'Settings Saved Successfully'
|
13
|
+
end
|
14
|
+
# add custom methods below ....
|
15
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Plugins::CamaleonSpree::MainHelper
|
2
|
+
include Plugins::CamaleonSpree::PrivateHelper
|
3
|
+
def self.included(klass)
|
4
|
+
# klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views
|
5
|
+
end
|
6
|
+
|
7
|
+
# fix to avoid missing route for https://github.com/spree-contrib/spree_tax_cloud
|
8
|
+
def edit_admin_tax_cloud_settings_path
|
9
|
+
spree.edit_admin_tax_cloud_settings_path
|
10
|
+
end
|
11
|
+
|
12
|
+
# here all actions on going to active
|
13
|
+
# you can run sql commands like this:
|
14
|
+
# results = ActiveRecord::Base.connection.execute(query);
|
15
|
+
# plugin: plugin model
|
16
|
+
def camaleon_spree_on_active(plugin)
|
17
|
+
current_plugin.set_option('camaleon_cms_layout', 'spree/layouts/spree_application')
|
18
|
+
end
|
19
|
+
|
20
|
+
# here all actions on going to inactive
|
21
|
+
# plugin: plugin model
|
22
|
+
def camaleon_spree_on_inactive(plugin)
|
23
|
+
end
|
24
|
+
|
25
|
+
def camaleon_spree_front_default_layout(args)
|
26
|
+
args[:layout] = current_plugin.get_option('camaleon_cms_layout') if current_plugin.get_option('camaleon_cms_layout').present?
|
27
|
+
end
|
28
|
+
|
29
|
+
# permit to show spree products and taxonomies in admin->menus (camaleon cms)
|
30
|
+
def camaleon_spree_cama_nav_menus(args)
|
31
|
+
# Groups
|
32
|
+
Spree::Taxonomy.all.each do |taxonomy|
|
33
|
+
args[:custom_menus]["spree_menus"] = {link: "", title: "Spree #{taxonomy.name.pluralize}"}
|
34
|
+
taxonomy.taxons.each do |taxon|
|
35
|
+
args[:custom_menus]["spree_tax_#{taxon.id}"] = {link: spree.nested_taxons_path(taxon.permalink), title: taxon.name, kind: 'Spree::Taxon', id: taxon.id}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Products
|
40
|
+
args[:custom_menus]["spree_menus_products"] = {link: "", title: "Spree Products"}
|
41
|
+
Spree::Product.reorder(name: :ASC).all.each do |product|
|
42
|
+
args[:custom_menus]["spree_product_#{product.id}"] = {link: spree.product_path(product), title: product.name, kind: 'Spree::Product', id: product.id}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# permit to show spree products and taxonomies in admin->menus (camaleon cms)
|
47
|
+
def camaleon_spree_on_parse_custom_menu_item(args)
|
48
|
+
if args[:menu_item].kind == 'Spree::Taxon'
|
49
|
+
taxon = Spree::Taxon.find(args[:menu_item].url)
|
50
|
+
res = {name: taxon.name, link: spree.nested_taxons_path(taxon.permalink)}
|
51
|
+
res[:current] = site_current_path == res[:link] unless args[:is_from_backend]
|
52
|
+
args[:parsed_menu] = res
|
53
|
+
end
|
54
|
+
|
55
|
+
if args[:menu_item].kind == 'Spree::Product'
|
56
|
+
product = Spree::Product.find(args[:menu_item].url)
|
57
|
+
res = {name: product.name, link: spree.product_path(product)}
|
58
|
+
res[:current] = site_current_path == res[:link] unless args[:is_from_backend]
|
59
|
+
args[:parsed_menu] = res
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# here all actions to upgrade for a new version
|
64
|
+
# plugin: plugin model
|
65
|
+
def camaleon_spree_on_upgrade(plugin)
|
66
|
+
end
|
67
|
+
|
68
|
+
def camaleon_spree_on_plugin_options(args)
|
69
|
+
args[:links] << link_to('Settings', admin_plugins_camaleon_spree_settings_path)
|
70
|
+
end
|
71
|
+
|
72
|
+
# add spree role action for camaleon user group permissions
|
73
|
+
def camaleon_spree_user_roles_hook(args)
|
74
|
+
args[:roles_list][:manager] << { key: 'spree_role', label: t('plugins.spree_cama.admin.roles.label', default: 'Spree Ecommerce'), description: t('plugins.spree_cama.admin.roles.descr', default: 'Manage all sections of Spree Ecommerce')}
|
75
|
+
end
|
76
|
+
|
77
|
+
# render spree menu item added on admin->menus (camaleon cms)
|
78
|
+
def camaleon_spree_on_render_front_menu_item(args)
|
79
|
+
if args[:parsed_menu] != false && args[:menu_item].kind == 'external' && args[:parsed_menu][:current] == false
|
80
|
+
args[:parsed_menu][:current] = URI::parse(site_current_url).path == args[:parsed_menu][:link]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<div class="well">
|
2
|
+
<h3>Your site was created successfully.</h3>
|
3
|
+
<hr>
|
4
|
+
<p>Vist Frontend: <%= link_to("Here.", cama_root_url, target: "_blank") %></p>
|
5
|
+
<p>Visit Admin panel <%= link_to("Here.", cama_admin_dashboard_url, target: "_blank") %></p>
|
6
|
+
<p>user: <small>Use Spree Credentials</small></p>
|
7
|
+
<p>pass: <small>Use Spree Credentials</small></p>
|
8
|
+
</div>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<script>var root_admin_url = '<%= cama_admin_url %>'; var ADMIN_TRANSLATIONS = <%= raw current_site.get_languages.to_json %>;</script>
|
2
|
+
<%= javascript_include_tag 'plugins/camaleon_spree/main' %>
|
3
|
+
<%= stylesheet_link_tag 'plugins/camaleon_spree/main' %>
|
4
|
+
<div class="clearfix"></div>
|
5
|
+
<%= render partial: "camaleon_cms/admin/settings/custom_fields/render", locals: {record: @product, field_groups: @product.get_field_groups} %>
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<div class="group-input-fields-content">
|
2
|
+
<%= select_tag "#{field_name}[#{field.slug}][values][]", option_groups_from_collection_for_select(Spree::Taxonomy.all, :taxons, :name, :id, :name), include_blank: 'Select Category', class: "form-control input-value #{"required" if field.options[:required].to_s.to_bool}", id: '' %>
|
3
|
+
</div>
|
@@ -0,0 +1,3 @@
|
|
1
|
+
<div class="group-input-fields-content">
|
2
|
+
<%= select_tag "#{field_name}[#{field.slug}][values][]", options_from_collection_for_select(Spree::Product.active.order(name: :ASC), :id, :name), include_blank: 'Select Product', class: "form-control input-value #{"required" if field.options[:required].to_s.to_bool}", id: '' %>
|
3
|
+
</div>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="panel panel-default">
|
2
|
+
<div class="panel-heading">
|
3
|
+
<h4>Camaleon Spree Settings</h4>
|
4
|
+
</div>
|
5
|
+
<div class="panel-body">
|
6
|
+
<%= form_tag(url_for(action: :save_settings), class: 'validate') do %>
|
7
|
+
<div class="form-group">
|
8
|
+
<label>Camaleon CMS Layout</label><br><small>Permit you to use spree layout for camaleon pages</small>
|
9
|
+
<%= text_field_tag 'options[camaleon_cms_layout]', @plugin.get_option('camaleon_cms_layout'), class: 'form-control required' %>
|
10
|
+
</div>
|
11
|
+
<div class="form-group text-right">
|
12
|
+
<%= submit_tag 'Save Settings', class: 'btn btn-primary' %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
</div>
|
16
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<style>
|
2
|
+
#custom_cama_menu .current-link,
|
3
|
+
#custom_cama_menu .current-menu-ancestor > a{ color: #fff; }
|
4
|
+
#custom_cama_menu .dropdown-menu .current-link{ color: #bbb; }
|
5
|
+
</style> <!--TMP Harcoding-->
|
6
|
+
<nav id="custom_cama_menu" role="navigation">
|
7
|
+
<div class="navbar navbar-inverse navbar-static-top" style="margin-bottom: 0">
|
8
|
+
<div class="container">
|
9
|
+
<div style="position: absolute; top: 0;"><%= raw current_site.draw_languages("language-list list-inline", true) %></div>
|
10
|
+
<!-- .navbar-toggle is used as the toggle for collapsed navbar content -->
|
11
|
+
<div class="navbar-header">
|
12
|
+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
|
13
|
+
<span class="icon-bar"></span>
|
14
|
+
<span class="icon-bar"></span>
|
15
|
+
<span class="icon-bar"></span>
|
16
|
+
</button>
|
17
|
+
</div>
|
18
|
+
<div class="navbar-collapse collapse navbar-responsive-collapse">
|
19
|
+
<%= raw draw_menu({container_id: "menu-menu-1", container_class: "nav navbar-nav navbar-right"}) %>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
</nav>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if(pages = @product.get_fields('sample-pages')).present? %>
|
2
|
+
<h3>Related Pages</h3>
|
3
|
+
<div class="row">
|
4
|
+
<% pages.each do |page_id| p=CamaleonCms::Post.where(id: page_id).first.try(:decorate); next unless p.present? %>
|
5
|
+
<div class="col-md-3">
|
6
|
+
<a href="<%= p.the_url %>">
|
7
|
+
<%= image_tag(p.the_thumb_url, style: 'disply:block', width: '100%') %>
|
8
|
+
</a>
|
9
|
+
<a href="<%= p.the_url %>">
|
10
|
+
<%= p.the_title %>
|
11
|
+
</a>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<div class="col-md-12 page-view">
|
2
|
+
<article class="post-content">
|
3
|
+
<h1><%= raw @post.the_title.upcase %><%= @post.the_edit_link %></h1>
|
4
|
+
<div class="item-content">
|
5
|
+
<%= raw @post.the_content %>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<% if (fields = @post.the_fields('spree-categories')).present? %>
|
9
|
+
<h3>Related Categories</h3>
|
10
|
+
<ul>
|
11
|
+
<% fields.each do |category_id| taxon = Spree::Taxon.where(id: category_id).first; next unless taxon.present?; %>
|
12
|
+
<li><%= link_to(taxon.name, spree.nested_taxons_path(taxon.permalink)) %></li>
|
13
|
+
<% end %>
|
14
|
+
</ul>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<!-- Related Products -->
|
18
|
+
<% if (fields = @post.the_fields('related-products')).present? %>
|
19
|
+
<h3>Related Products</h3>
|
20
|
+
<div class="row">
|
21
|
+
<% fields.each do |product_id|
|
22
|
+
product = Spree::Product.where(id: product_id).first; next unless product.present?;
|
23
|
+
url = spree.product_url(product)
|
24
|
+
%>
|
25
|
+
<div id="product_<%= product.id %>" class="col-md-3 col-sm-6 col-xs-6 product-list-item" data-hook="products_list_item" itemscope itemtype="https://schema.org/Product">
|
26
|
+
<div class="panel panel-default">
|
27
|
+
<div class="panel-body text-center product-body">
|
28
|
+
<%= link_to url, itemprop: "url" do %>
|
29
|
+
<%= small_image(product, itemprop: "image") %><br/>
|
30
|
+
<%= content_tag(:span, truncate(product.name, length: 50), class: 'info', itemprop: "name", title: product.name) %>
|
31
|
+
<% end %>
|
32
|
+
<br/>
|
33
|
+
</div>
|
34
|
+
<div class="panel-footer text-center">
|
35
|
+
<span itemprop="offers" itemscope itemtype="https://schema.org/Offer">
|
36
|
+
<span class="price selling lead" itemprop="price"><%= display_price(product) %></span>
|
37
|
+
</span>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
</div>
|
41
|
+
<% end %>
|
42
|
+
</div>
|
43
|
+
<% end %>
|
44
|
+
</article>
|
45
|
+
</div>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"title": "Camaleon Spree",
|
3
|
+
"descr": "Permit to include Spree Commerce admin panel into Camaleon CMS",
|
4
|
+
"key": "camaleon_spree", // must be the name of the folder of your plugin, sample: app/views/plugins/<my_plugin> ==> 'my_plugin'
|
5
|
+
"helpers": [
|
6
|
+
"Plugins::CamaleonSpree::MainHelper"
|
7
|
+
],
|
8
|
+
"hooks": {
|
9
|
+
"on_active": [
|
10
|
+
"camaleon_spree_on_active"
|
11
|
+
],
|
12
|
+
"on_inactive": [
|
13
|
+
"camaleon_spree_on_inactive"
|
14
|
+
],
|
15
|
+
"available_user_roles_list": ["camaleon_spree_user_roles_hook"],
|
16
|
+
"extra_custom_fields": ["camaleon_spree_custom_fields"],
|
17
|
+
"custom_field_custom_models": ["camaleon_spree_custom_field_models"],
|
18
|
+
"on_render_front_menu_item": ["camaleon_spree_on_render_front_menu_item"],
|
19
|
+
"nav_menu_custom": ["camaleon_spree_cama_nav_menus"],
|
20
|
+
"parse_custom_menu_item": ["camaleon_spree_on_parse_custom_menu_item"],
|
21
|
+
"front_default_layout": ["camaleon_spree_front_default_layout"],
|
22
|
+
"plugin_options": ["camaleon_spree_on_plugin_options"]
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Rails.application.config.to_prepare do
|
2
|
+
module BreadcrumbsOnRails
|
3
|
+
module ActionController
|
4
|
+
module HelperMethods
|
5
|
+
def render_breadcrumbs(options = {}, &block)
|
6
|
+
builder = (options.delete(:builder) || Breadcrumbs::SimpleBuilder).new(self, @breadcrumbs, options)
|
7
|
+
content = builder.render.html_safe
|
8
|
+
if block_given?
|
9
|
+
capture(content, &block)
|
10
|
+
else
|
11
|
+
content
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
Rails.application.config.to_prepare do
|
2
|
+
# load basic helpers from spree into camaleon frontend
|
3
|
+
CamaleonCms::FrontendController.class_eval do
|
4
|
+
include Spree::Core::ControllerHelpers::Order
|
5
|
+
include Spree::Core::ControllerHelpers::Auth
|
6
|
+
include Spree::Core::ControllerHelpers::Store
|
7
|
+
|
8
|
+
helper Spree::BaseHelper
|
9
|
+
helper Spree::StoreHelper
|
10
|
+
end
|
11
|
+
|
12
|
+
########## changes to camaleon to include spree ##########
|
13
|
+
CamaleonCms::AdminController.class_eval do
|
14
|
+
before_action :set_spree_buttons
|
15
|
+
helper_method :current_store
|
16
|
+
|
17
|
+
def current_store
|
18
|
+
Spree::Store.current
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def set_spree_buttons
|
23
|
+
return if cannot? :manage, :spree_role
|
24
|
+
cama_content_prepend("
|
25
|
+
<div id=\"tmp_spree_menu\" style=\"display: none\"> #{render_to_string partial: 'spree/admin/shared/main_menu'} </div>
|
26
|
+
<script>
|
27
|
+
jQuery(function(){
|
28
|
+
// spree commerce menus
|
29
|
+
$('#sidebar-menu .sidebar-menu').append('<li id=\"spree_commerce_menu\" class=\"treeview\" data-key=\"settings\"> <a href=\"#\"><i class=\"fa fa-shopping-cart\"></i> <span class="">#{t('plugins.spree_cama.admin.menus.ecommerce', default: 'Spree Ecommerce')}</span> <i class=\"fa fa-angle-left pull-right\"></i></a> <ul class=\"treeview-menu\"></ul> </li>');
|
30
|
+
var items = $('#tmp_spree_menu').find('.nav-sidebar > .sidebar-menu-item').clone();
|
31
|
+
items.find('ul').attr('class', 'treeview-menu').each(function(){ $(this).prev().removeAttr('data-toggle').removeAttr('aria-expanded').append('<i class=\"fa fa-angle-left pull-right\"></i>'); });
|
32
|
+
items.find('a').prepend('<i class=\"fa fa-circle-o\"></i>');
|
33
|
+
$('#spree_commerce_menu .treeview-menu').html(items);
|
34
|
+
|
35
|
+
// menu spree as iframe
|
36
|
+
function spree_load_iframe(url){
|
37
|
+
$('#admin_content').html('<iframe style=\"width: 100%; height: 480px; margin-top: -66px;\" frameBorder=\"0\" src=\"'+url+'\">').find('iframe').load(function(){
|
38
|
+
$(this.contentWindow.document.body).css({'padding-bottom': '120px', 'min-height': '500px'});
|
39
|
+
this.style.height = this.contentWindow.document.body.offsetHeight + 15 + 'px';
|
40
|
+
if('history' in window && 'pushState' in history) window.history.pushState({}, '', '#{cama_admin_dashboard_path}?cama_spree_iframe_path='+this.contentWindow.location.href);
|
41
|
+
});
|
42
|
+
}
|
43
|
+
|
44
|
+
$('#spree_commerce_menu li[data-spree-ecommerce] a, #spree_commerce_menu a').click(function(e){
|
45
|
+
if($(this).attr('href').search('#') == 0) return e.preventDefault();
|
46
|
+
$(this).closest('li').addClass('active').siblings().removeClass('active');
|
47
|
+
spree_load_iframe($(this).attr('href'));
|
48
|
+
window.scrollTo(0, 0);
|
49
|
+
return false;
|
50
|
+
});
|
51
|
+
#{"spree_load_iframe('#{params[:cama_spree_iframe_path]}'); $('#spree_commerce_menu > a').click();" if params[:cama_spree_iframe_path].present?}
|
52
|
+
}); </script>")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# update camaleon session routes
|
57
|
+
module CamaleonCms::SessionHelper
|
58
|
+
def cama_current_user
|
59
|
+
@cama_current_user ||= lambda{
|
60
|
+
if spree_current_user.try(:id).present?
|
61
|
+
spree_current_user.decorate
|
62
|
+
end
|
63
|
+
}.call
|
64
|
+
end
|
65
|
+
|
66
|
+
def cama_admin_login_path
|
67
|
+
spree_login_path
|
68
|
+
end
|
69
|
+
alias_method :cama_admin_login_url, :cama_admin_login_path
|
70
|
+
|
71
|
+
def cama_admin_register_path
|
72
|
+
spree_signup_path
|
73
|
+
end
|
74
|
+
alias_method :cama_admin_register_url, :cama_admin_register_path
|
75
|
+
|
76
|
+
def cama_admin_logout_path
|
77
|
+
spree_logout_path
|
78
|
+
end
|
79
|
+
alias_method :cama_admin_logout_url, :cama_admin_logout_path
|
80
|
+
end
|
81
|
+
|
82
|
+
# custom models
|
83
|
+
CamaleonCms::User.class_eval do
|
84
|
+
alias_attribute :last_login_at, :last_sign_in_at
|
85
|
+
alias_attribute :username, :login
|
86
|
+
after_create :check_user_role
|
87
|
+
|
88
|
+
has_many :spree_roles, through: :role_users, class_name: 'Spree::Role', source: :role, after_add: :cama_update_roles, after_remove: :cama_update_roles
|
89
|
+
def has_spree_role?(role_in_question)
|
90
|
+
spree_roles.any? { |role| role.name == role_in_question.to_s } || self.role == role_in_question.to_s
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
def check_user_role
|
95
|
+
if self.admin?
|
96
|
+
Spree::User.find(self.id).spree_roles << Spree::Role.where(name: 'admin').first
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def cama_update_roles(role)
|
101
|
+
self.update_column(:role, spree_roles.where(spree_roles: {name: 'admin'}).any? ? 'admin' : 'user')
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Camaspreehelperroutes
|
2
|
+
def self.update_helper_routes
|
3
|
+
_routes = ['cama_profile', 'cama_search', 'cama_post_of_posttype', 'cama_save_comment', 'cama_save_form', 'cama_post_type', 'cama_hierarchy_post', 'cama_post_tag', 'cama_post', 'cama_root', 'cama_admin', 'cama_admin_dashboard']
|
4
|
+
_routes += Cama::PostType.pluck(:id).map{|id| "cama_post_type_#{id}"}
|
5
|
+
|
6
|
+
_cama_lang_routes = ['cama_category', 'cama_post_of_category', 'cama_post_of_post_type', 'cama_post_type']
|
7
|
+
Cama::Site.main_site.get_languages.each{|_l| _cama_lang_routes.each{|_r| _routes << "#{_r}_#{_l}" } }
|
8
|
+
_routes.each do |x|
|
9
|
+
Spree::BaseHelper.module_eval <<-eoruby, __FILE__, __LINE__ + 1
|
10
|
+
def #{x}_url(args=nil)
|
11
|
+
Rails.application.routes.url_helpers.#{x}_url(args)
|
12
|
+
end
|
13
|
+
|
14
|
+
def #{x}_path(args=nil)
|
15
|
+
Rails.application.routes.url_helpers.#{x}_path(args)
|
16
|
+
end
|
17
|
+
eoruby
|
18
|
+
end
|
19
|
+
|
20
|
+
['edit_cama_admin_post_type_post_tag_url', 'edit_cama_admin_post_type_post_url'].each do |u|
|
21
|
+
Spree::BaseHelper.module_eval <<-eoruby, __FILE__, __LINE__ + 1
|
22
|
+
def #{u}(pt_id, object, args)
|
23
|
+
Rails.application.routes.url_helpers.#{u}(pt_id, object, args)
|
24
|
+
end
|
25
|
+
eoruby
|
26
|
+
end
|
27
|
+
|
28
|
+
['edit_cama_admin_post_type_category_url', 'edit_cama_admin_settings_post_type_url'].each do |u|
|
29
|
+
Spree::BaseHelper.module_eval <<-eoruby, __FILE__, __LINE__ + 1
|
30
|
+
def #{u}(id, args)
|
31
|
+
Rails.application.routes.url_helpers.#{u}(id, args)
|
32
|
+
end
|
33
|
+
eoruby
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Rails.application.config.to_prepare do
|
39
|
+
if PluginRoutes.db_installed? && Cama::Site.any?
|
40
|
+
Camaspreehelperroutes.update_helper_routes
|
41
|
+
end
|
42
|
+
PluginRoutes.add_after_reload_routes 'Camaspreehelperroutes.update_helper_routes'
|
43
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
Rails.application.config.to_prepare do
|
2
|
+
########## changes for spree to works with camaleon ##########
|
3
|
+
Spree::UserSessionsController.class_eval do
|
4
|
+
private
|
5
|
+
def redirect_back_or_default(default)
|
6
|
+
redirect_to(cookies[:return_to] || session["spree_user_return_to"] || default)
|
7
|
+
session["spree_user_return_to"] = nil
|
8
|
+
cookies[:return_to] = nil
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Deface::Override.new(
|
13
|
+
virtual_path: 'spree/layouts/admin',
|
14
|
+
name: 'cama_admin_iframe_hide_sidebar',
|
15
|
+
insert_bottom: '[data-hook="admin_footer_scripts"]',
|
16
|
+
text: '<script>
|
17
|
+
jQuery(function(){
|
18
|
+
if(window.location != window.parent.location){ $("#wrapper").addClass("sidebar-minimized"); $("#main-part").css({"margin-left": 0, "padding-left": "35px"}); $("#main-sidebar").hide(); }
|
19
|
+
})
|
20
|
+
</script>'
|
21
|
+
)
|
22
|
+
|
23
|
+
Deface::Override.new(
|
24
|
+
virtual_path: 'spree/admin/products/_form',
|
25
|
+
name: 'cama_custom_fields',
|
26
|
+
insert_bottom: '[data-hook="admin_product_form_additional_fields"]',
|
27
|
+
partial: '/plugins/camaleon_spree/admin/render_custom_fields_product'
|
28
|
+
)
|
29
|
+
Deface::Override.new(
|
30
|
+
virtual_path: 'spree/admin/products/new',
|
31
|
+
name: 'cama_custom_fields_on_create',
|
32
|
+
insert_bottom: '[data-hook="new_product_attrs"]',
|
33
|
+
partial: '/plugins/camaleon_spree/admin/render_custom_fields_product'
|
34
|
+
)
|
35
|
+
|
36
|
+
# spree product add custom fields support
|
37
|
+
Spree::Product.class_eval do
|
38
|
+
include CamaleonCms::Metas
|
39
|
+
include CamaleonCms::CustomFieldsRead
|
40
|
+
include CamaleonCms::CustomFieldsConcern
|
41
|
+
def get_field_groups(args = {}) # needs to fix for multisite&multistore support
|
42
|
+
CamaleonCms::CustomFieldGroup.where(object_class: self.class.name)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
Spree::Admin::ProductsController.class_eval do
|
49
|
+
create.after :save_custom_fields
|
50
|
+
update.after :save_custom_fields
|
51
|
+
|
52
|
+
private
|
53
|
+
def save_custom_fields
|
54
|
+
@object.set_field_values(params[:field_options])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# redirect to cama dashboard
|
59
|
+
Spree::Admin::RootController.class_eval do
|
60
|
+
def index
|
61
|
+
redirect_to Rails.application.routes.url_helpers.cama_admin_dashboard_path
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
if defined?(WillPaginate)
|
2
|
+
module WillPaginate
|
3
|
+
module ActiveRecord
|
4
|
+
module RelationMethods
|
5
|
+
def per_page(num)
|
6
|
+
if (n = num.to_i) <= 0
|
7
|
+
self
|
8
|
+
else
|
9
|
+
limit(n).offset(offset_value / limit_value * n)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def total_pages
|
14
|
+
(total_count.to_f / limit_value).ceil
|
15
|
+
end
|
16
|
+
|
17
|
+
alias_method :per, :per_page
|
18
|
+
alias_method :num_pages, :total_pages
|
19
|
+
alias_method :total_count, :total_entries
|
20
|
+
alias_method :prev_page, :previous_page
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
scope PluginRoutes.system_info["relative_url_root"] do
|
4
|
+
#Admin Panel
|
5
|
+
scope :admin, as: 'admin', path: PluginRoutes.system_info['admin_path_name'] do
|
6
|
+
namespace 'plugins' do
|
7
|
+
namespace 'camaleon_spree' do
|
8
|
+
controller :admin do
|
9
|
+
get :settings
|
10
|
+
post :save_settings
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# main routes
|
17
|
+
#scope 'nico_chale', module: 'plugins/nico_chale/', as: 'nico_chale' do
|
18
|
+
# Here my routes for main routes
|
19
|
+
#end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class AddCamaleonUserDataToSpree < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
add_column(CamaleonCms::User.table_name, :email, :string) unless column_exists?(CamaleonCms::User.table_name, :email)
|
4
|
+
add_column(CamaleonCms::User.table_name, :role, :string, default: 'client', index: true) unless column_exists?(CamaleonCms::User.table_name, :role)
|
5
|
+
add_column(CamaleonCms::User.table_name, :parent_id, :integer) unless column_exists?(CamaleonCms::User.table_name, :parent_id)
|
6
|
+
add_column(CamaleonCms::User.table_name, :site_id, :integer, index: true, default: -1) unless column_exists?(CamaleonCms::User.table_name, :site_id)
|
7
|
+
add_column(CamaleonCms::User.table_name, :auth_token, :string) unless column_exists?(CamaleonCms::User.table_name, :auth_token)
|
8
|
+
add_column CamaleonCms::User.table_name, :first_name, :string unless column_exists?(CamaleonCms::User.table_name, :first_name)
|
9
|
+
add_column CamaleonCms::User.table_name, :last_name, :string unless column_exists?(CamaleonCms::User.table_name, :last_name)
|
10
|
+
|
11
|
+
Spree::User.includes(:spree_roles).where(spree_roles: {name: 'admin'}).each do |s_user|
|
12
|
+
s_user.update_column(:role, 'admin')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: camaleon_spree
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Owen Peredo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Permit to integrate Camaleon CMS + Spree Commerce
|
42
|
+
email:
|
43
|
+
- owenperedo@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- Rakefile
|
50
|
+
- app/assets/javascripts/plugins/camaleon_spree/main.js
|
51
|
+
- app/assets/stylesheets/plugins/camaleon_spree/custom.css.scss
|
52
|
+
- app/assets/stylesheets/plugins/camaleon_spree/main.css
|
53
|
+
- app/controllers/plugins/camaleon_spree/admin_controller.rb
|
54
|
+
- app/helpers/plugins/camaleon_spree/main_helper.rb
|
55
|
+
- app/plugins/camaleon_spree/product_decorator.rb
|
56
|
+
- app/views/camaleon_cms/admin/installers/welcome.html.erb
|
57
|
+
- app/views/plugins/camaleon_spree/admin/_render_custom_fields_product.html.erb
|
58
|
+
- app/views/plugins/camaleon_spree/admin/cama_plugin_settings.html.erb
|
59
|
+
- app/views/plugins/camaleon_spree/admin/custom_field/_spree_categories.html.erb
|
60
|
+
- app/views/plugins/camaleon_spree/admin/custom_field/_spree_products.html.erb
|
61
|
+
- app/views/plugins/camaleon_spree/admin/settings.html.erb
|
62
|
+
- app/views/plugins/camaleon_spree/examples/_layout_menus.html.erb
|
63
|
+
- app/views/plugins/camaleon_spree/examples/_product_custom_fields.html.erb
|
64
|
+
- app/views/plugins/camaleon_spree/examples/template_product_page.html.erb
|
65
|
+
- config/camaleon_plugin.json
|
66
|
+
- config/initializers/bread_crumb_onrails.rb
|
67
|
+
- config/initializers/camaleon.rb
|
68
|
+
- config/initializers/routes.rb
|
69
|
+
- config/initializers/spree.rb
|
70
|
+
- config/initializers/will_paginate.rb
|
71
|
+
- config/routes.rb
|
72
|
+
- db/migrate/20160831160611_add_camaleon_user_data_to_spree.rb
|
73
|
+
- lib/camaleon_spree.rb
|
74
|
+
- lib/camaleon_spree/engine.rb
|
75
|
+
- lib/camaleon_spree/version.rb
|
76
|
+
- lib/tasks/camaleon_spree_tasks.rake
|
77
|
+
homepage: ''
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.4.8
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Permit to integrate Camaleon CMS + Spree Commerce
|
101
|
+
test_files: []
|
102
|
+
has_rdoc:
|