alchemy_spree 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 301fe68273f680a0824558febf122a0dbc9af5d7
4
+ data.tar.gz: 3852285bdf2a9973c9ab163eee3152d5b447dce0
5
+ SHA512:
6
+ metadata.gz: 2f650b88632215540b284184e17f02358ddfd9b599ecfb142222c623e94519422e5bd004f299b7a55ac42a4f1b8525a4fac957df81407e2fed09f0f6b9eb1960
7
+ data.tar.gz: 4d326c6ede1c990b529868f33f2bb9451840c441134d61f7153b99331f42b4f06a67ea1b43f7a508bb43530b872299f5bb131ac5cc783ceb850db7b4386db118
data/Gemfile CHANGED
@@ -3,9 +3,8 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in alchemy_spree.gemspec
4
4
  gemspec
5
5
 
6
- gem 'alchemy_cms', '2.2.rc12', :github => 'magiclabs/alchemy_cms'
7
- gem 'spree', '1.2.0.beta', :github => 'spree/spree', :branch => 'auth-take-two'
8
-
9
6
  group :developmemt, :test do
7
+ gem "spree", github: 'tvdeyen/spree', branch: 'alchemy'
8
+ gem 'money', '~> 5.1'
10
9
  gem 'sqlite3'
11
10
  end
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Alchemy CMS Spree Connector
1
+ # Alchemy CMS Spree Extension
2
2
 
3
3
  The World's Most Flexible E-Commerce Platform meets The World's Most Flexible Content Management System!
4
4
 
@@ -7,12 +7,8 @@ This gem is a [Alchemy CMS](https://github.com/magiclabs/alchemy_cms) and [Spree
7
7
  ### For now it does this:
8
8
 
9
9
  1. It provides an Alchemy module that displays Spree admin in an iframe inside Alchemy admin.
10
- 2. It gives you a new Essence for Alchemy called EssenceSpreeProduct that you can use to place a Spree product on your page.
11
- 3. It adds a TinyMCE editor to the Spree product description textarea.
12
-
13
- ### TODO:
14
-
15
- 1. Share admin session between Alchemy and Spree.
10
+ 2. It gives you new Essences for Alchemy called EssenceSpreeProduct and EssenceSpreeTaxon that you can use to place a Spree product and Taxon on your pages.
11
+ 3. Shares admin session between Alchemy and Spree.
16
12
 
17
13
  ## Installation
18
14
 
@@ -28,35 +24,48 @@ Or install it yourself as:
28
24
 
29
25
  $ gem install alchemy_spree
30
26
 
31
- ## Usage
27
+ Install the migrations:
28
+
29
+ $ rake alchemy_spree:install:migrations
32
30
 
33
- ### Mount the engine into your routes
31
+ Migrate the database:
34
32
 
35
- # config/routes.rb
36
- mount AlchemySpree::Engine => '/'
33
+ $ rake db:migrate
34
+
35
+ ## Usage
37
36
 
38
37
  ### Create a new Element for Alchemy
39
38
 
40
- # config/alchemy/elements.yml
41
- - name: product
42
- contents:
43
- - name: spree_product
44
- type: EssenceSpreeProduct
39
+ # config/alchemy/elements.yml
40
+ - name: product
41
+ contents:
42
+ - name: spree_product
43
+ type: EssenceSpreeProduct
44
+
45
+ - name: product_category
46
+ contents:
47
+ - name: spree_taxon
48
+ type: EssenceSpreeTaxon
45
49
 
46
50
  ### Generate the views
47
51
 
48
- $ rails g alchemy:elements --skip
52
+ $ rails g alchemy:elements --skip
49
53
 
50
54
  ### Place this element on a page layout
51
55
 
52
- # config/alchemy/page_layouts.yml
53
- - name: products
54
- elements: [product]
56
+ # config/alchemy/page_layouts.yml
57
+ - name: product
58
+ elements: [product]
59
+ - name: products
60
+ elements: [product_category]
61
+
62
+ ### You can haz Spree product and taxons!
55
63
 
56
- ### You can haz Spree product!
64
+ # app/views/alchemy/elements/_product_view.html.erb
65
+ <%= element.ingredient('spree_product') %>
57
66
 
58
- # app/views/alchemy/elements/_product_view.html.erb
59
- <%= element.ingredient('spree_product') %>
67
+ # app/views/alchemy/elements/_product_category_view.html.erb
68
+ <%= element.ingredient('spree_taxon') %>
60
69
 
61
70
  Alchemy <3 Spree!
62
71
 
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/alchemy_spree/version', __FILE__)
2
+ require File.expand_path('../lib/alchemy/spree/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Thomas von Deyen"]
@@ -13,8 +13,8 @@ Gem::Specification.new do |gem|
13
13
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
14
  gem.name = "alchemy_spree"
15
15
  gem.require_paths = ["lib"]
16
- gem.version = AlchemySpree::VERSION
16
+ gem.version = Alchemy::Spree::VERSION
17
17
 
18
- #gem.add_dependency('alchemy_cms', ['~> 2.2.rc12'])
19
- #gem.add_dependency('spree', ['~> 1.1.0.beta'])
18
+ gem.add_dependency('alchemy_cms', ['~> 2.7.0'])
19
+ gem.add_dependency('spree', ['~> 2.0.0'])
20
20
  end
@@ -1,9 +1,5 @@
1
- module Alchemy
2
- module Admin
3
- class SpreeController < Alchemy::Admin::BaseController
4
- def index
5
- render
6
- end
7
- end
8
- end
1
+ class Alchemy::Admin::SpreeController < Alchemy::Admin::BaseController
2
+ def index
3
+ render
4
+ end
9
5
  end
@@ -1,15 +1,16 @@
1
1
  module Alchemy
2
- class EssenceSpreeProduct < ActiveRecord::Base
2
+ class EssenceSpreeProduct < ActiveRecord::Base
3
+ belongs_to :product, class_name: "Spree::Product", foreign_key: 'spree_product_id', readonly: true
3
4
 
4
- belongs_to :product, :class_name => "Spree::Product", :foreign_key => :spree_product_id, :readonly => true
5
- acts_as_essence(
6
- :ingredient_column => :spree_product_id,
7
- :preview_text_method => :name
8
- )
5
+ acts_as_essence(
6
+ ingredient_column: 'spree_product_id',
7
+ preview_text_method: 'name'
8
+ )
9
9
 
10
- def ingredient
11
- product
12
- end
10
+ attr_accessible :spree_product_id
13
11
 
14
- end
12
+ def ingredient
13
+ product
14
+ end
15
+ end
15
16
  end
@@ -0,0 +1,16 @@
1
+ module Alchemy
2
+ class EssenceSpreeTaxon < ActiveRecord::Base
3
+ belongs_to :taxon, class_name: "Spree::Taxon", foreign_key: 'taxon_id', readonly: true
4
+
5
+ acts_as_essence(
6
+ ingredient_column: 'taxon_id',
7
+ preview_text_method: 'name'
8
+ )
9
+
10
+ attr_accessible :taxon_id
11
+
12
+ def ingredient
13
+ taxon
14
+ end
15
+ end
16
+ end
@@ -1,14 +1,11 @@
1
- module Alchemy
2
- User.class_eval do
1
+ Alchemy::User.class_eval do
3
2
 
4
- def spree_roles
5
- @spree_admin_role ||= Spree::Role.find_or_create_by_name("admin")
6
- if admin?
7
- [@spree_admin_role]
8
- else
9
- []
10
- end
3
+ def spree_roles
4
+ if admin?
5
+ ::Spree::Role.where(name: 'admin')
6
+ else
7
+ ::Spree::Role.where('1 = 0') # aka. empty relation
11
8
  end
12
-
13
9
  end
10
+
14
11
  end
@@ -1,27 +1,33 @@
1
- <%= image_tag('alchemy/ajax_loader.gif', :id => "frame_load_info", :style => "position: absolute; top: 50%; left: 50%; margin-top: -12px; margin-left: -12px") %>
2
- <iframe src="<%= spree.admin_url(:protocol => Rails.env.production? ? 'https' : nil) %>" frameborder=0 width="100%" id="spree_admin" style="display: none"></iframe>
1
+ <iframe src="<%= spree.admin_url %>" frameborder=0 width="100%" id="spree_admin" style="display: none"></iframe>
3
2
  <script type="text/javascript">
4
3
  jQuery(document).ready(function($) {
5
4
  var $frame = $('iframe#spree_admin');
6
5
 
6
+ spinner = Alchemy.Spinner.medium();
7
+ spinner.spin($("#main_content")[0])
8
+
7
9
  function sizeSpreeFrame() {
8
10
  $frame.css({height: $(window).height() - 30});
9
11
  }
10
12
 
11
13
  $('#toolbar').remove();
12
- $('#archive_all').css({padding: 0});
14
+ $('#main_content').css({
15
+ padding: '27px 0px 0px 66px',
16
+ backgroundColor: 'white'
17
+ });
13
18
 
14
19
  $frame.on('load', function() {
15
20
  var frame_document;
16
21
  var frame_window = (this.contentWindow || this.contentDocument);
17
22
  var elements = ['header', 'footer', 'admin-menu', 'sub-menu', 'content'];
23
+ spinner.stop();
18
24
  if (frame_window.document) {
19
25
  frame_document = frame_window.document;
20
26
  } else {
21
27
  frame_document = frame_window;
22
28
  frame_window = frame_document.window;
23
29
  }
24
- frame_document.body.style.backgroundColor = '#EDEDED';
30
+ frame_document.body.style.backgroundColor = '#fff';
25
31
  frame_document.body.style.fontFamily = '"Lucida Grande", Arial, sans-serif';
26
32
  frame_document.body.style.fontSize = '12px';
27
33
  for (var i = elements.length - 1; i >= 0; i--) {
@@ -1,9 +1,9 @@
1
- <div class="content_editor">
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_select', html_options[:class]].join(' '),
7
- :style => html_options[:style]
8
- ) %>
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
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>
@@ -1,7 +1,5 @@
1
1
  authorization do
2
-
3
2
  role :admin do
4
3
  has_permission_on :alchemy_admin_spree, :to => [:index]
5
4
  end
6
-
7
5
  end
@@ -0,0 +1,10 @@
1
+ Alchemy::Modules.register_module({
2
+ engine_name: 'alchemy',
3
+ name: 'spree',
4
+ navigation: {
5
+ controller: 'alchemy/admin/spree',
6
+ action: 'index',
7
+ name: 'Spree',
8
+ image: '/assets/alchemy_spree/alchemy_module_icon.png'
9
+ }
10
+ })
data/config/routes.rb CHANGED
@@ -1,3 +1,3 @@
1
- AlchemySpree::Engine.routes.draw do
2
- match 'admin/spree' => 'alchemy/admin/spree#index', :as => :spree_admin
3
- end
1
+ Alchemy::Engine.routes.prepend do
2
+ get '/admin/spree' => 'admin/spree#index', :as => :spree_admin
3
+ end
@@ -0,0 +1,7 @@
1
+ class AddSpreeFieldsToCustomUserTable < ActiveRecord::Migration
2
+ def up
3
+ add_column "alchemy_users", :spree_api_key, :string, :limit => 48
4
+ add_column "alchemy_users", :ship_address_id, :integer
5
+ add_column "alchemy_users", :bill_address_id, :integer
6
+ end
7
+ 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,23 @@
1
+ require 'alchemy/spree/alchemy_language_store'
2
+
3
+ module Alchemy
4
+ module Spree
5
+ class Engine < ::Rails::Engine
6
+ engine_name 'alchemy_spree'
7
+
8
+ initializer 'spree.user_class', after: 'alchemy.include_authentication_helpers' do
9
+ ::Spree.user_class = "Alchemy::User"
10
+ require File.join(File.dirname(__FILE__), '../../spree/authentication_helpers')
11
+ end
12
+
13
+ def self.activate
14
+ Dir.glob(File.join(File.dirname(__FILE__), "../../../app/**/*_decorator*.rb")) do |c|
15
+ Rails.configuration.cache_classes ? require(c) : load(c)
16
+ end
17
+ Alchemy::Auth::Engine.get_instance.load(File.join(File.dirname(__FILE__), '../..', 'config/authorization_rules.rb'))
18
+ end
19
+
20
+ config.to_prepare &method(:activate).to_proc
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module Alchemy
2
+ module Spree
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
data/lib/alchemy_spree.rb CHANGED
@@ -1 +1,2 @@
1
- require "alchemy_spree/engine"
1
+ require "alchemy_cms"
2
+ require "alchemy/spree/engine"
@@ -8,7 +8,7 @@ module Spree
8
8
  end
9
9
 
10
10
  def spree_current_user
11
- current_alchemy_user
11
+ current_user
12
12
  end
13
13
 
14
14
  def spree_login_path
metadata CHANGED
@@ -1,16 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_spree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Thomas von Deyen
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-06-11 00:00:00.000000000 Z
13
- dependencies: []
11
+ date: 2013-11-07 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: 2.7.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 2.7.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: spree
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.0
14
41
  description: A Alchemy CMS and Spree connector
15
42
  email:
16
43
  - tvd@magiclabs.de
@@ -30,20 +57,23 @@ files:
30
57
  - app/controllers/spree/base_controller_decorator.rb
31
58
  - app/controllers/spree/user_sessions_controller_decorator.rb
32
59
  - app/models/alchemy/essence_spree_product.rb
60
+ - app/models/alchemy/essence_spree_taxon.rb
33
61
  - app/models/alchemy/user_decorator.rb
34
- - app/overrides/include_tinymce_js.rb
35
62
  - app/views/alchemy/admin/spree/index.html.erb
36
63
  - app/views/alchemy/essences/_essence_spree_product_editor.html.erb
37
64
  - app/views/alchemy/essences/_essence_spree_product_view.html.erb
38
- - app/views/partials/_tinymce_javascript.html.erb
65
+ - app/views/alchemy/essences/_essence_spree_taxon_editor.html.erb
66
+ - app/views/alchemy/essences/_essence_spree_taxon_view.html.erb
39
67
  - config/authorization_rules.rb
68
+ - config/initializers/alchemy.rb
40
69
  - config/routes.rb
41
70
  - db/migrate/20120229160509_create_alchemy_essence_spree_products.rb
71
+ - db/migrate/20131029215548_add_spree_fields_to_custom_user_table.rb
72
+ - db/migrate/20131030140218_create_alchemy_essence_spree_taxons.rb
73
+ - lib/alchemy/spree/alchemy_language_store.rb
74
+ - lib/alchemy/spree/engine.rb
75
+ - lib/alchemy/spree/version.rb
42
76
  - lib/alchemy_spree.rb
43
- - lib/alchemy_spree/alchemy_language_store.rb
44
- - lib/alchemy_spree/alchemy_module.rb
45
- - lib/alchemy_spree/engine.rb
46
- - lib/alchemy_spree/version.rb
47
77
  - lib/spree/authentication_helpers.rb
48
78
  - script/rails
49
79
  - test/alchemy_spree_test.rb
@@ -82,33 +112,26 @@ files:
82
112
  - test/test_helper.rb
83
113
  homepage: https://github.com/magiclabs/alchemy_spree
84
114
  licenses: []
115
+ metadata: {}
85
116
  post_install_message:
86
117
  rdoc_options: []
87
118
  require_paths:
88
119
  - lib
89
120
  required_ruby_version: !ruby/object:Gem::Requirement
90
- none: false
91
121
  requirements:
92
- - - ! '>='
122
+ - - '>='
93
123
  - !ruby/object:Gem::Version
94
124
  version: '0'
95
- segments:
96
- - 0
97
- hash: -1812501221866682820
98
125
  required_rubygems_version: !ruby/object:Gem::Requirement
99
- none: false
100
126
  requirements:
101
- - - ! '>='
127
+ - - '>='
102
128
  - !ruby/object:Gem::Version
103
129
  version: '0'
104
- segments:
105
- - 0
106
- hash: -1812501221866682820
107
130
  requirements: []
108
131
  rubyforge_project:
109
- rubygems_version: 1.8.24
132
+ rubygems_version: 2.1.10
110
133
  signing_key:
111
- specification_version: 3
134
+ specification_version: 4
112
135
  summary: The World's Most Flexible E-Commerce Platform meets The World's Most Flexible
113
136
  Content Management System!
114
137
  test_files:
@@ -1,6 +0,0 @@
1
- Deface::Override.new(
2
- :virtual_path => "spree/layouts/admin",
3
- :name => "include_tinymce_js",
4
- :insert_bottom => "[data-hook='admin_inside_head'], #admin_inside_head[data-hook]",
5
- :text => "<%= render :partial => 'partials/tinymce_javascript' -%>"
6
- )
@@ -1,36 +0,0 @@
1
- <% prefix = Rails.application.config.assets.prefix -%>
2
- <script type="text/javascript">
3
- var tinyMCEPreInit = {
4
- base: '<%= prefix -%>/tiny_mce',
5
- suffix: ''
6
- };
7
- </script>
8
- <script type="text/javascript" src="<%= prefix -%>/tiny_mce/tiny_mce.js"></script>
9
- <script type="text/javascript">
10
- jQuery(function($) {
11
- if ($('textarea#product_description').length > 0) {
12
- tinyMCE.init({
13
- mode : "exact",
14
- elements : 'product_description',
15
- theme : "advanced",
16
- language : '<%= ::I18n.locale.to_s.split('-')[0].downcase -%>',
17
- skin : "o2k7",
18
- skin_variant : 'silver',
19
- inlinepopups_skin : 'alchemy',
20
- popup_css : "<%= prefix -%>/alchemy/tinymce_dialog.css",
21
- content_css : "<%= prefix -%>/alchemy/tinymce_content.css",
22
- width : "100%",
23
- plugins : "paste,inlinepopups",
24
-
25
- // Theme options
26
- theme_advanced_buttons1 : "bold,italic,underline,strikethrough,sub,sup,|,numlist,bullist,indent,outdent,|,removeformat,cleanup",
27
- theme_advanced_buttons2 : "pastetext,pasteword,|,link,unlink,|,charmap,code,help",
28
- theme_advanced_buttons3 : "",
29
- theme_advanced_toolbar_location : "top",
30
- theme_advanced_toolbar_align : "left",
31
- theme_advanced_statusbar_location : "bottom",
32
- theme_advanced_resizing : true
33
- });
34
- }
35
- });
36
- </script>
@@ -1,16 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
-
3
- require "alchemy_cms"
4
-
5
- Alchemy::Modules.register_module({
6
- :name => 'spree',
7
- :engine_name => 'alchemy_spree',
8
- :navigation => {
9
- :controller => 'alchemy/admin/spree',
10
- :action => 'index',
11
- :name => 'Shop',
12
- :image => '/assets/alchemy_spree/alchemy_module_icon.png'
13
- }
14
- })
15
-
16
- Alchemy::AuthEngine.get_instance.load(File.join(File.dirname(__FILE__), '../..', 'config/authorization_rules.rb'))
@@ -1,23 +0,0 @@
1
- require "alchemy_spree/alchemy_module"
2
- require 'alchemy_spree/alchemy_language_store'
3
-
4
- module AlchemySpree
5
- class Engine < ::Rails::Engine
6
- engine_name 'alchemy_spree'
7
-
8
- if defined?(Spree.user_class)
9
- initializer 'spree.user_class', :after => 'alchemy.include_authentication_helpers' do
10
- Spree.user_class = "Alchemy::User"
11
- require File.join(File.dirname(__FILE__), '../spree/authentication_helpers')
12
- end
13
- end
14
-
15
- def self.activate
16
- Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
17
- Rails.configuration.cache_classes ? require(c) : load(c)
18
- end
19
- end
20
-
21
- config.to_prepare &method(:activate).to_proc
22
- end
23
- end
@@ -1,3 +0,0 @@
1
- module AlchemySpree
2
- VERSION = "0.1.5"
3
- end