radiant-shop_packages-extension 0.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.
Files changed (56) hide show
  1. data/.gitignore +2 -0
  2. data/README +3 -0
  3. data/Rakefile +138 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/.DS_Store +0 -0
  6. data/app/controllers/admin/shop/packages/packings_controller.rb +90 -0
  7. data/app/controllers/admin/shop/packages_controller.rb +63 -0
  8. data/app/datasets/shop_packages.rb +25 -0
  9. data/app/models/shop_package.rb +79 -0
  10. data/app/models/shop_packing.rb +22 -0
  11. data/app/views/admin/shop/packages/edit.html.haml +11 -0
  12. data/app/views/admin/shop/packages/edit/_foot.html.haml +17 -0
  13. data/app/views/admin/shop/packages/edit/_form.html.haml +15 -0
  14. data/app/views/admin/shop/packages/edit/_head.html.haml +4 -0
  15. data/app/views/admin/shop/packages/edit/_inputs.html.haml +2 -0
  16. data/app/views/admin/shop/packages/edit/_meta.html.haml +8 -0
  17. data/app/views/admin/shop/packages/edit/_parts.html.haml +9 -0
  18. data/app/views/admin/shop/packages/edit/_popups.html.haml +4 -0
  19. data/app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml +1 -0
  20. data/app/views/admin/shop/packages/edit/inputs/_name.html.haml +3 -0
  21. data/app/views/admin/shop/packages/edit/inputs/_price.html.haml +3 -0
  22. data/app/views/admin/shop/packages/edit/meta/_sku.html.haml +5 -0
  23. data/app/views/admin/shop/packages/edit/parts/_description.html.haml +1 -0
  24. data/app/views/admin/shop/packages/edit/parts/_products.html.haml +3 -0
  25. data/app/views/admin/shop/packages/edit/popups/_browse_products.html.haml +7 -0
  26. data/app/views/admin/shop/packages/edit/shared/_product.html.haml +8 -0
  27. data/app/views/admin/shop/packages/index.html.haml +13 -0
  28. data/app/views/admin/shop/packages/index/_foot.html.haml +8 -0
  29. data/app/views/admin/shop/packages/index/_head.html.haml +2 -0
  30. data/app/views/admin/shop/packages/index/_package.html.haml +9 -0
  31. data/app/views/admin/shop/packages/index/buttons/_new_package.html.haml +1 -0
  32. data/app/views/admin/shop/packages/new.html.haml +11 -0
  33. data/app/views/admin/shop/packages/remove.html.haml +12 -0
  34. data/config/locales/en.yml +11 -0
  35. data/config/routes.rb +13 -0
  36. data/cucumber.yml +1 -0
  37. data/db/migrate/20101015161749_setup_shop_packages.rb +27 -0
  38. data/lib/shop_packages/interface/packages.rb +34 -0
  39. data/lib/shop_packages/models/shop_packageable.rb +15 -0
  40. data/lib/shop_packages/tags/helpers.rb +41 -0
  41. data/lib/shop_packages/tags/package.rb +94 -0
  42. data/lib/tasks/shop_packages_extension_tasks.rake +55 -0
  43. data/public/javascripts/admin/extensions/shop/packages/edit.js +109 -0
  44. data/public/stylesheets/sass/admin/extensions/shop/packages/edit.sass +162 -0
  45. data/radiant-shop_packages-extension.gemspec +104 -0
  46. data/shop_packages_extension.rb +37 -0
  47. data/spec/controllers/admin/shop/packages/packings_controller_spec.rb +188 -0
  48. data/spec/controllers/admin/shop/packages_controller_spec.rb +32 -0
  49. data/spec/datasets/shop_packages.rb +23 -0
  50. data/spec/lib/shop_packages/tags/package_spec.rb +348 -0
  51. data/spec/models/shop_package_spec.rb +117 -0
  52. data/spec/models/shop_packing_spec.rb +67 -0
  53. data/spec/models/shop_product_spec.rb +25 -0
  54. data/spec/spec.opts +4 -0
  55. data/spec/spec_helper.rb +23 -0
  56. metadata +141 -0
@@ -0,0 +1,55 @@
1
+ namespace :radiant do
2
+ namespace :extensions do
3
+ namespace :shop_packages do
4
+
5
+ desc "Runs the migration of the Shop Packages extension"
6
+ task :migrate => :environment do
7
+ require 'radiant/extension_migrator'
8
+ if ENV["VERSION"]
9
+ ShopPackagesExtension.migrator.migrate(ENV["VERSION"].to_i)
10
+ Rake::Task['db:schema:dump'].invoke
11
+ else
12
+ ShopPackagesExtension.migrator.migrate
13
+ Rake::Task['db:schema:dump'].invoke
14
+ end
15
+ end
16
+
17
+ desc "Copies public assets of the Shop Packages to the instance public/ directory."
18
+ task :update => :environment do
19
+ is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
20
+ puts "Copying assets from ShopPackagesExtension"
21
+ Dir[ShopPackagesExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
22
+ path = file.sub(ShopPackagesExtension.root, '')
23
+ directory = File.dirname(path)
24
+ mkdir_p RAILS_ROOT + directory, :verbose => false
25
+ cp file, RAILS_ROOT + path, :verbose => false
26
+ end
27
+ unless ShopPackagesExtension.root.starts_with? RAILS_ROOT # don't need to copy vendored tasks
28
+ puts "Copying rake tasks from ShopPackagesExtension"
29
+ local_tasks_path = File.join(RAILS_ROOT, %w(lib tasks))
30
+ mkdir_p local_tasks_path, :verbose => false
31
+ Dir[File.join ShopPackagesExtension.root, %w(lib tasks *.rake)].each do |file|
32
+ cp file, local_tasks_path, :verbose => false
33
+ end
34
+ end
35
+ end
36
+
37
+ desc "Syncs all available translations for this ext to the English ext master"
38
+ task :sync => :environment do
39
+ # The main translation root, basically where English is kept
40
+ language_root = ShopPackagesExtension.root + "/config/locales"
41
+ words = TranslationSupport.get_translation_keys(language_root)
42
+
43
+ Dir["#{language_root}/*.yml"].each do |filename|
44
+ next if filename.match('_available_tags')
45
+ basename = File.basename(filename, '.yml')
46
+ puts "Syncing #{basename}"
47
+ (comments, other) = TranslationSupport.read_file(filename, basename)
48
+ words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
49
+ other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
50
+ TranslationSupport.write_file(filename, basename, comments, other)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,109 @@
1
+ document.observe("dom:loaded", function() {
2
+ shop_package_edit = new ShopPackageEdit();
3
+ shop_package_edit.initialize();
4
+
5
+ Event.addBehavior({
6
+ '#available_products .product:click' : function(e) { shop_package_edit.productAttach($(this)) },
7
+ '#package_products .quantity:blur' : function(e) { shop_package_edit.productUpdate($(this)) },
8
+ '#package_products .delete:click' : function(e) { shop_package_edit.productRemove($(this)) }
9
+ })
10
+ });
11
+
12
+ var ShopPackageEdit = Class.create({
13
+
14
+ initialize: function() {
15
+ this.productsSort();
16
+ },
17
+
18
+ productsSort: function() {
19
+ var route = shop.getRoute('sort_admin_shop_package_packings_path');
20
+ Sortable.create('package_products', {
21
+ constraint: false,
22
+ overlap: 'horizontal',
23
+ containment: ['package_products'],
24
+ onUpdate: function(element) {
25
+ new Ajax.Request(route, {
26
+ method: 'put',
27
+ parameters: {
28
+ 'package_id': $('shop_package_id').value,
29
+ 'packings' : Sortable.serialize('package_products')
30
+ }
31
+ });
32
+ }
33
+ })
34
+ },
35
+
36
+ productAttach: function(element) {
37
+ var product = element;
38
+ var route = shop.getRoute('admin_shop_package_packings_path');
39
+
40
+ showStatus('Adding Product...');
41
+ new Ajax.Request(route, {
42
+ method: 'post',
43
+ parameters: {
44
+ 'package_id': $('shop_package_id').value,
45
+ 'product_id': element.getAttribute('data-product_id'),
46
+ },
47
+ onSuccess: function(data) {
48
+ $('package_products').insert({ 'bottom' : data.responseText});
49
+ shop_package_edit.productPostChanges(product);
50
+ }.bind(element),
51
+ onFailure: function() {
52
+ thi.productError();
53
+ }
54
+ });
55
+ },
56
+
57
+ productUpdate: function(element) {
58
+ var product = element.up('.product');
59
+ var packing_id = product.readAttribute('data-packing_id');
60
+ var route = shop.getRoute('admin_shop_package_packing_path', 'js', packing_id);
61
+
62
+ showStatus('Updating Quantity...');
63
+ new Ajax.Request(route, {
64
+ method: 'put',
65
+ parameters: {
66
+ 'quantity': element.value
67
+ },
68
+ onSuccess: function(data) {
69
+ hideStatus();
70
+ },
71
+ onFailure: function(data) {
72
+ shop_package_edit.errorStatus();
73
+ }
74
+ });
75
+ },
76
+
77
+ productRemove: function(element) {
78
+ var product = element.up('.product');
79
+ var packing_id = product.readAttribute('data-packing_id');
80
+ var route = shop.getRoute('admin_shop_package_packing_path', 'js', packing_id);
81
+
82
+ showStatus('Removing Product...');
83
+ element.hide();
84
+ new Ajax.Request(route, {
85
+ method: 'delete',
86
+ onSuccess: function(data) {
87
+ $('available_products').insert({ 'bottom' : data.responseText });
88
+ shop_package_edit.productPostChanges(product);
89
+ },
90
+ onFailure: function(data) {
91
+ shop_package_edit.errorStatus();
92
+ }
93
+ });
94
+ },
95
+
96
+ productPostChanges: function(element) {
97
+ element.remove();
98
+
99
+ this.productsSort();
100
+
101
+ hideStatus();
102
+ },
103
+
104
+ errorStatus: function() {
105
+ setStatus('Something went wrong, refreshing.');
106
+ location.reload(true);
107
+ }
108
+
109
+ });
@@ -0,0 +1,162 @@
1
+ ol#package_products
2
+ overflow: hidden
3
+ padding:
4
+ top: 10px
5
+
6
+ li.product
7
+ float: left
8
+ position: relative
9
+ padding: 10px
10
+ height: 100px
11
+ width: 100px
12
+ margin:
13
+ right: 10px
14
+ border:
15
+ radius: 6px
16
+ -moz:
17
+ border:
18
+ radius: 6px
19
+ -webkit:
20
+ border:
21
+ radius: 6px
22
+ cursor: move
23
+ overflow: hidden
24
+ *
25
+ vertical:
26
+ align: middle
27
+
28
+ .wrapper
29
+ display: table-cell
30
+ height: 100px
31
+ width: 100px
32
+ text:
33
+ align: center
34
+ vertical:
35
+ align: middle
36
+
37
+ img
38
+ width: 100px
39
+ max:
40
+ height: 100px
41
+
42
+ .title
43
+ font-size: 10px
44
+ position: absolute
45
+ display: block
46
+ width: 96%
47
+ top: 37.5px
48
+ left: 0
49
+ padding: 4px 2%
50
+ overflow: hidden
51
+
52
+ .quantity
53
+ visibility: hidden
54
+ font-size: 10px
55
+ position: absolute
56
+ display: block
57
+ width: 30px
58
+ bottom: 14px
59
+ left: 18px
60
+ padding: 2px 0
61
+
62
+ .save_quantity
63
+ width: 45px
64
+ visibility: hidden
65
+ position: absolute
66
+ right: 14px
67
+ bottom: 14px
68
+
69
+ .actions
70
+ position: absolute
71
+ display: block
72
+ width: 100%
73
+ top: 0
74
+ left: 0
75
+
76
+ .delete
77
+ position: absolute
78
+ right: 2px
79
+ top: 4px
80
+ width: 20px
81
+ height: 20px
82
+ overflow: hidden
83
+ display: block
84
+ cursor: pointer
85
+ background:
86
+ image: url('/images/admin/minus_disabled.png')
87
+ repeat: no-repeat
88
+ position: 0 0
89
+ cursor: pointer
90
+
91
+ &:hover
92
+ background:
93
+ image: url('/images/admin/minus.png')
94
+
95
+ &:hover
96
+ background:
97
+ color: #f9f6fe
98
+
99
+ .title, .quantity, .save_quantity
100
+ visibility: visible
101
+
102
+ .title
103
+ background-color: #f9f6fe
104
+
105
+ #browse_products_popup
106
+ position: relative
107
+ overflow: hidden
108
+
109
+ ul#available_products
110
+ width: 700px
111
+ padding: 5px 0 10px
112
+ overflow: hidden
113
+ position: relative
114
+
115
+ li.product
116
+ position: relative
117
+ background-color: #f9f6fe
118
+ display: block
119
+ float: left
120
+ height: 70px
121
+ width: 70px
122
+ padding: 10px
123
+ margin: 0 5px 5px
124
+ border:
125
+ radius: 6px
126
+ -moz:
127
+ border:
128
+ radius: 6px
129
+ -webkit:
130
+ border:
131
+ radius: 6px
132
+ cursor: pointer
133
+
134
+ *
135
+ vertical:
136
+ align: middle
137
+
138
+ .wrapper
139
+ display: table-cell
140
+ height: 70px
141
+ width: 70px
142
+ text:
143
+ align: center
144
+ vertical:
145
+ algin: middle
146
+
147
+ img
148
+ width: 70px
149
+
150
+ .title
151
+ font-size: 10px
152
+ position: absolute
153
+ display: block
154
+ width: 96%
155
+ top: 37.5px
156
+ left: 0
157
+ background-color: #f9f6fe
158
+ padding: 4px 2%
159
+ overflow: hidden
160
+
161
+ .actions, .quantity, .save_quantity
162
+ display: none
@@ -0,0 +1,104 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{radiant-shop_packages-extension}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dirk Kelly"]
12
+ s.date = %q{2010-11-10}
13
+ s.description = %q{RadiantShop: Group up Products into packages, you can assign a price to a package}
14
+ s.email = %q{dk@dirkkelly.com}
15
+ s.extra_rdoc_files = [
16
+ "README"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "README",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "app/controllers/.DS_Store",
24
+ "app/controllers/admin/shop/packages/packings_controller.rb",
25
+ "app/controllers/admin/shop/packages_controller.rb",
26
+ "app/datasets/shop_packages.rb",
27
+ "app/models/shop_package.rb",
28
+ "app/models/shop_packing.rb",
29
+ "app/views/admin/shop/packages/edit.html.haml",
30
+ "app/views/admin/shop/packages/edit/_foot.html.haml",
31
+ "app/views/admin/shop/packages/edit/_form.html.haml",
32
+ "app/views/admin/shop/packages/edit/_head.html.haml",
33
+ "app/views/admin/shop/packages/edit/_inputs.html.haml",
34
+ "app/views/admin/shop/packages/edit/_meta.html.haml",
35
+ "app/views/admin/shop/packages/edit/_parts.html.haml",
36
+ "app/views/admin/shop/packages/edit/_popups.html.haml",
37
+ "app/views/admin/shop/packages/edit/buttons/_browse_products.html.haml",
38
+ "app/views/admin/shop/packages/edit/inputs/_name.html.haml",
39
+ "app/views/admin/shop/packages/edit/inputs/_price.html.haml",
40
+ "app/views/admin/shop/packages/edit/meta/_sku.html.haml",
41
+ "app/views/admin/shop/packages/edit/parts/_description.html.haml",
42
+ "app/views/admin/shop/packages/edit/parts/_products.html.haml",
43
+ "app/views/admin/shop/packages/edit/popups/_browse_products.html.haml",
44
+ "app/views/admin/shop/packages/edit/shared/_product.html.haml",
45
+ "app/views/admin/shop/packages/index.html.haml",
46
+ "app/views/admin/shop/packages/index/_foot.html.haml",
47
+ "app/views/admin/shop/packages/index/_head.html.haml",
48
+ "app/views/admin/shop/packages/index/_package.html.haml",
49
+ "app/views/admin/shop/packages/index/buttons/_new_package.html.haml",
50
+ "app/views/admin/shop/packages/new.html.haml",
51
+ "app/views/admin/shop/packages/remove.html.haml",
52
+ "config/locales/en.yml",
53
+ "config/routes.rb",
54
+ "cucumber.yml",
55
+ "db/migrate/20101015161749_setup_shop_packages.rb",
56
+ "lib/shop_packages/interface/packages.rb",
57
+ "lib/shop_packages/models/shop_packageable.rb",
58
+ "lib/shop_packages/tags/helpers.rb",
59
+ "lib/shop_packages/tags/package.rb",
60
+ "lib/tasks/shop_packages_extension_tasks.rake",
61
+ "public/javascripts/admin/extensions/shop/packages/edit.js",
62
+ "public/stylesheets/sass/admin/extensions/shop/packages/edit.sass",
63
+ "radiant-shop_packages-extension.gemspec",
64
+ "shop_packages_extension.rb",
65
+ "spec/controllers/admin/shop/packages/packings_controller_spec.rb",
66
+ "spec/controllers/admin/shop/packages_controller_spec.rb",
67
+ "spec/datasets/shop_packages.rb",
68
+ "spec/lib/shop_packages/tags/package_spec.rb",
69
+ "spec/models/shop_package_spec.rb",
70
+ "spec/models/shop_packing_spec.rb",
71
+ "spec/models/shop_product_spec.rb",
72
+ "spec/spec.opts",
73
+ "spec/spec_helper.rb"
74
+ ]
75
+ s.homepage = %q{http://github.com/thefrontiergroup/radiant-shop_packages-extension}
76
+ s.rdoc_options = ["--charset=UTF-8"]
77
+ s.require_paths = ["lib"]
78
+ s.rubygems_version = %q{1.3.7}
79
+ s.summary = %q{Shop Packages Extension for Radiant CMS}
80
+ s.test_files = [
81
+ "spec/controllers/admin/shop/packages/packings_controller_spec.rb",
82
+ "spec/controllers/admin/shop/packages_controller_spec.rb",
83
+ "spec/datasets/shop_packages.rb",
84
+ "spec/lib/shop_packages/tags/package_spec.rb",
85
+ "spec/models/shop_package_spec.rb",
86
+ "spec/models/shop_packing_spec.rb",
87
+ "spec/models/shop_product_spec.rb",
88
+ "spec/spec_helper.rb"
89
+ ]
90
+
91
+ if s.respond_to? :specification_version then
92
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
93
+ s.specification_version = 3
94
+
95
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
96
+ s.add_runtime_dependency(%q<radiant-shop-extension>, [">= 0"])
97
+ else
98
+ s.add_dependency(%q<radiant-shop-extension>, [">= 0"])
99
+ end
100
+ else
101
+ s.add_dependency(%q<radiant-shop-extension>, [">= 0"])
102
+ end
103
+ end
104
+
@@ -0,0 +1,37 @@
1
+ # Uncomment this if you reference any of your controllers in activate
2
+ # require_dependency 'application_controller'
3
+
4
+ class ShopPackagesExtension < Radiant::Extension
5
+ version "1.0"
6
+ description "Describe your extension here"
7
+ url "http://yourwebsite.com/shop_packages"
8
+
9
+ extension_config do |config|
10
+ config.after_initialize do
11
+ #
12
+ end
13
+ end
14
+
15
+ UserActionObserver.instance.send :add_observer!, ShopPackage
16
+
17
+ def activate
18
+
19
+ tab "Shop" do
20
+ add_item "Packages", "/admin/shop/packages", :after => "products"
21
+ end
22
+
23
+ unless defined? admin.packages
24
+ Radiant::AdminUI.send :include, ShopPackages::Interface::Packages
25
+
26
+ admin.packages = Radiant::AdminUI.load_default_shop_packages_regions
27
+ end
28
+
29
+ ShopProduct.send :include, ShopPackages::Models::ShopPackageable
30
+ Page.send :include, ShopPackages::Tags::Package
31
+
32
+ if Radiant::Extension.descendants.any? { |extension| extension.extension_name == 'ShopDiscounts' }
33
+ ShopPackage.send :include, ShopDiscounts::Models::Discountable
34
+ end
35
+
36
+ end
37
+ end