hancock_cms_catalog 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +57 -0
  8. data/Rakefile +1 -0
  9. data/app/assets/javascripts/hancock/catalog.coffee +3 -0
  10. data/app/assets/javascripts/hancock/catalog/init.coffee +2 -0
  11. data/app/assets/stylesheets/hancock/catalog.sass +0 -0
  12. data/app/controllers/concerns/hancock/catalog/decorators/categories.rb +29 -0
  13. data/app/controllers/concerns/hancock/catalog/decorators/items.rb +29 -0
  14. data/app/controllers/hancock/catalog/categories_controller.rb +7 -0
  15. data/app/controllers/hancock/catalog/items_controller.rb +7 -0
  16. data/app/models/concerns/hancock/catalog/decorators/category.rb +53 -0
  17. data/app/models/concerns/hancock/catalog/decorators/category_image.rb +52 -0
  18. data/app/models/concerns/hancock/catalog/decorators/item.rb +52 -0
  19. data/app/models/concerns/hancock/catalog/decorators/item_image.rb +52 -0
  20. data/app/models/hancock/catalog/category.rb +11 -0
  21. data/app/models/hancock/catalog/category_image.rb +16 -0
  22. data/app/models/hancock/catalog/item.rb +11 -0
  23. data/app/models/hancock/catalog/item_image.rb +16 -0
  24. data/app/views/hancock/catalog/categories/index.html.slim +39 -0
  25. data/app/views/hancock/catalog/categories/show.html.slim +98 -0
  26. data/app/views/hancock/catalog/items/index.html.slim +38 -0
  27. data/app/views/hancock/catalog/items/show.html.slim +43 -0
  28. data/bin/console +14 -0
  29. data/bin/setup +7 -0
  30. data/config/locales/hancock.catalog.ru.yml +23 -0
  31. data/config/locales/ru.kaminari.yml +17 -0
  32. data/hancock_cms_catalog.gemspec +39 -0
  33. data/lib/generators/hancock/catalog/config/config_generator.rb +13 -0
  34. data/lib/generators/hancock/catalog/config/templates/hancock_catalog.erb +38 -0
  35. data/lib/generators/hancock/catalog/controllers/all_generator.rb +28 -0
  36. data/lib/generators/hancock/catalog/controllers/category_generator.rb +43 -0
  37. data/lib/generators/hancock/catalog/controllers/decorators_generator.rb +24 -0
  38. data/lib/generators/hancock/catalog/controllers/item_generator.rb +43 -0
  39. data/lib/generators/hancock/catalog/controllers/templates/categories_controller.erb +10 -0
  40. data/lib/generators/hancock/catalog/controllers/templates/items_controller.erb +10 -0
  41. data/lib/generators/hancock/catalog/models/all_generator.rb +38 -0
  42. data/lib/generators/hancock/catalog/models/category_generator.rb +43 -0
  43. data/lib/generators/hancock/catalog/models/category_image_generator.rb +43 -0
  44. data/lib/generators/hancock/catalog/models/decorators_generator.rb +24 -0
  45. data/lib/generators/hancock/catalog/models/item_generator.rb +34 -0
  46. data/lib/generators/hancock/catalog/models/item_image_generator.rb +43 -0
  47. data/lib/generators/hancock/catalog/models/templates/category.erb +54 -0
  48. data/lib/generators/hancock/catalog/models/templates/category_image.erb +53 -0
  49. data/lib/generators/hancock/catalog/models/templates/item.erb +56 -0
  50. data/lib/generators/hancock/catalog/models/templates/item_image.erb +53 -0
  51. data/lib/generators/hancock/catalog/views/for_generator.rb +57 -0
  52. data/lib/generators/hancock/catalog/views/views_generator.rb +33 -0
  53. data/lib/hancock/catalog/admin.rb +4 -0
  54. data/lib/hancock/catalog/admin/category.rb +175 -0
  55. data/lib/hancock/catalog/admin/category_image.rb +37 -0
  56. data/lib/hancock/catalog/admin/item.rb +133 -0
  57. data/lib/hancock/catalog/admin/item_image.rb +37 -0
  58. data/lib/hancock/catalog/configuration.rb +75 -0
  59. data/lib/hancock/catalog/controllers/categories.rb +91 -0
  60. data/lib/hancock/catalog/controllers/items.rb +61 -0
  61. data/lib/hancock/catalog/engine.rb +7 -0
  62. data/lib/hancock/catalog/models/category.rb +85 -0
  63. data/lib/hancock/catalog/models/category_image.rb +18 -0
  64. data/lib/hancock/catalog/models/item.rb +92 -0
  65. data/lib/hancock/catalog/models/item_image.rb +18 -0
  66. data/lib/hancock/catalog/models/mongoid/category.rb +37 -0
  67. data/lib/hancock/catalog/models/mongoid/category_image.rb +18 -0
  68. data/lib/hancock/catalog/models/mongoid/item.rb +39 -0
  69. data/lib/hancock/catalog/models/mongoid/item_image.rb +18 -0
  70. data/lib/hancock/catalog/routes.rb +79 -0
  71. data/lib/hancock/catalog/version.rb +5 -0
  72. data/lib/hancock_cms_catalog.rb +47 -0
  73. data/release.sh +6 -0
  74. metadata +178 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 81eaad517ca5da67a1208593531cf07bb4fc43c3
4
+ data.tar.gz: 0377db987705c44f726c06c412c8078669d70337
5
+ SHA512:
6
+ metadata.gz: 7b9b6f82366572a7dc34240ca803a62a60693598601a041f80d737986833460e4ab6e214ad36aa8c696fd0bd373414ea65c4c8efb70ff16f9117ed5ba07732e9
7
+ data.tar.gz: ca3ebb07aba1c1140f80e21ee0bf0b8dd0de412962c0088125ee517605adb1e00e5b55ee96a27d8f31c84de4e637213f8185b8af07c731561d3e6204258a3e24
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
@@ -0,0 +1 @@
1
+ hancock_catalog
@@ -0,0 +1 @@
1
+ 2.3.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ack_rocket_cms_catalog.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Alexander Kiseliev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ # HancockCMSCatalog
2
+
3
+ Item Catalog for [HancockCMS](https://github.com/red-rocks/hancock_cms). Items, Categories, embedded image galleries.
4
+
5
+ ### Remaded from [EnjoyCMSCatalog](https://github.com/enjoycreative/enjoy_cms_catalog)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'hancock_cms_catalog'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install hancock_cms_catalog
22
+
23
+ ## Usage
24
+
25
+ Add in config/routes.rb
26
+
27
+ ```ruby
28
+ hancock_cms_catalog_routes
29
+ ```
30
+
31
+ Then execute
32
+
33
+ $ rails g hancock:catalog:config
34
+
35
+ and now you can edit config/initializers/hancock_catalog.rb
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/red-rocks/hancock_cms_catalog.
46
+
47
+ ## TODO
48
+
49
+ * Do it more flexible.
50
+ * Documentation fixes.
51
+ * More configs (routes, paginations, views....)
52
+ * Find and fix bugs. I am sure, bugs are here.
53
+ * Add Search
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,3 @@
1
+ #= require ./catalog/init
2
+
3
+ #= require_self
@@ -0,0 +1,2 @@
1
+ window.hancock_cms ||= {}
2
+ window.hancock_cms.catalog ||= {}
@@ -0,0 +1,29 @@
1
+ module Hancock::Catalog::Decorators
2
+ module Categories
3
+ extend ActiveSupport::Concern
4
+
5
+ # included do
6
+ #
7
+ # def page_title
8
+ # if @category
9
+ # @category.page_title
10
+ # else
11
+ # super
12
+ # end
13
+ # end
14
+ #
15
+ # def category_class
16
+ # Hancock::Catalog::Category
17
+ # end
18
+ # def item_class
19
+ # Hancock::Catalog::Item
20
+ # end
21
+ #
22
+ # def insert_breadcrumbs
23
+ # true
24
+ # end
25
+ #
26
+ # end
27
+
28
+ end
29
+ end
@@ -0,0 +1,29 @@
1
+ module Hancock::Catalog::Decorators
2
+ module Items
3
+ extend ActiveSupport::Concern
4
+
5
+ # included do
6
+ #
7
+ # def page_title
8
+ # if @item
9
+ # @item.page_title
10
+ # else
11
+ # super
12
+ # end
13
+ # end
14
+ #
15
+ # def category_class
16
+ # Hancock::Catalog::Category
17
+ # end
18
+ # def item_class
19
+ # Hancock::Catalog::Item
20
+ # end
21
+ #
22
+ # def insert_breadcrumbs
23
+ # true
24
+ # end
25
+ #
26
+ # end
27
+
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ module Hancock::Catalog
2
+ class CategoriesController < ApplicationController
3
+ include Hancock::Catalog::Controllers::Categories
4
+
5
+ include Hancock::Catalog::Decorators::Categories
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Hancock::Catalog
2
+ class ItemsController < ApplicationController
3
+ include Hancock::Catalog::Controllers::Items
4
+
5
+ include Hancock::Catalog::Decorators::Items
6
+ end
7
+ end
@@ -0,0 +1,53 @@
1
+ module Hancock::Catalog::Decorators
2
+ module Category
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ # def self.default_cache_keys
8
+ # []
9
+ # end
10
+ #
11
+ # # after_save :image_auto_rails_admin_jcrop
12
+ # def image_auto_rails_admin_jcrop
13
+ # auto_rails_admin_jcrop(:image) # or nil for cancel autocrop
14
+ # end
15
+ #
16
+ # # hancock_cms_attached_file(:image)
17
+ # def image_styles
18
+ # Hancock::Catalog.configuration.category_image_styles
19
+ # end
20
+ #
21
+ # def image_jcrop_options
22
+ # {}
23
+ # end
24
+ #
25
+ # ############# rails_admin ##############
26
+ # def self.rails_admin_add_fields
27
+ # {}
28
+ # end
29
+ #
30
+ # def self.rails_admin_add_config(config)
31
+ # end
32
+ #
33
+ # def self.admin_can_user_defined_actions
34
+ # [].freeze
35
+ # end
36
+ # def self.admin_cannot_user_defined_actions
37
+ # [].freeze
38
+ # end
39
+ # def self.manager_can_user_defined_actions
40
+ # [].freeze
41
+ # end
42
+ # def self.manager_cannot_user_defined_actions
43
+ # [].freeze
44
+ # end
45
+ # def self.rails_admin_user_defined_visible_actions
46
+ # [].freeze
47
+ # end
48
+
49
+ end
50
+
51
+
52
+ end
53
+ end
@@ -0,0 +1,52 @@
1
+ module Hancock::Catalog::Decorators
2
+ module CategoryImage
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ # def self.default_cache_keys
8
+ # []
9
+ # end
10
+ #
11
+ # # after_save :image_auto_rails_admin_jcrop
12
+ # def image_auto_rails_admin_jcrop
13
+ # auto_rails_admin_jcrop(:image) # or nil for cancel autocrop
14
+ # end
15
+ #
16
+ # # hancock_cms_attached_file(:image)
17
+ # def image_styles
18
+ # Hancock::Catalog.configuration.category_images_image_styles
19
+ # end
20
+ #
21
+ # def image_jcrop_options
22
+ # {}
23
+ # end
24
+ #
25
+ # ############# rails_admin ##############
26
+ # def self.rails_admin_add_fields
27
+ # {}
28
+ # end
29
+ #
30
+ # def self.rails_admin_add_config(config)
31
+ # end
32
+ #
33
+ # def self.admin_can_user_defined_actions
34
+ # [].freeze
35
+ # end
36
+ # def self.admin_cannot_user_defined_actions
37
+ # [].freeze
38
+ # end
39
+ # def self.manager_can_user_defined_actions
40
+ # [].freeze
41
+ # end
42
+ # def self.manager_cannot_user_defined_actions
43
+ # [].freeze
44
+ # end
45
+ # def self.rails_admin_user_defined_visible_actions
46
+ # [].freeze
47
+ # end
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,52 @@
1
+ module Hancock::Catalog::Decorators
2
+ module Item
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ # def self.default_cache_keys
8
+ # []
9
+ # end
10
+ #
11
+ # # after_save :image_auto_rails_admin_jcrop
12
+ # def image_auto_rails_admin_jcrop
13
+ # auto_rails_admin_jcrop(:image) # or nil for cancel autocrop
14
+ # end
15
+ #
16
+ # # hancock_cms_attached_file(:image)
17
+ # def image_styles
18
+ # Hancock::Catalog.configuration.item_image_styles
19
+ # end
20
+ #
21
+ # def image_jcrop_options
22
+ # {}
23
+ # end
24
+ #
25
+ # ############# rails_admin ##############
26
+ # def self.rails_admin_add_fields
27
+ # {}
28
+ # end
29
+ #
30
+ # def self.rails_admin_add_config(config)
31
+ # end
32
+ #
33
+ # def self.admin_can_user_defined_actions
34
+ # [].freeze
35
+ # end
36
+ # def self.admin_cannot_user_defined_actions
37
+ # [].freeze
38
+ # end
39
+ # def self.manager_can_user_defined_actions
40
+ # [].freeze
41
+ # end
42
+ # def self.manager_cannot_user_defined_actions
43
+ # [].freeze
44
+ # end
45
+ # def self.rails_admin_user_defined_visible_actions
46
+ # [].freeze
47
+ # end
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,52 @@
1
+ module Hancock::Catalog::Decorators
2
+ module ItemImage
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ # def self.default_cache_keys
8
+ # []
9
+ # end
10
+ #
11
+ # # after_save :image_auto_rails_admin_jcrop
12
+ # def image_auto_rails_admin_jcrop
13
+ # auto_rails_admin_jcrop(:image) # or nil for cancel autocrop
14
+ # end
15
+ #
16
+ # # hancock_cms_attached_file(:image)
17
+ # def image_styles
18
+ # Hancock::Catalog.configuration.item_images_image_styles
19
+ # end
20
+ #
21
+ # def image_jcrop_options
22
+ # {}
23
+ # end
24
+ #
25
+ # ############# rails_admin ##############
26
+ # def self.rails_admin_add_fields
27
+ # {}
28
+ # end
29
+ #
30
+ # def self.rails_admin_add_config(config)
31
+ # end
32
+ #
33
+ # def self.admin_can_user_defined_actions
34
+ # [].freeze
35
+ # end
36
+ # def self.admin_cannot_user_defined_actions
37
+ # [].freeze
38
+ # end
39
+ # def self.manager_can_user_defined_actions
40
+ # [].freeze
41
+ # end
42
+ # def self.manager_cannot_user_defined_actions
43
+ # [].freeze
44
+ # end
45
+ # def self.rails_admin_user_defined_visible_actions
46
+ # [].freeze
47
+ # end
48
+
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,11 @@
1
+ module Hancock::Catalog
2
+ class Category
3
+ include Hancock::Catalog::Models::Category
4
+
5
+ include Hancock::Catalog::Decorators::Category
6
+
7
+ rails_admin(&Hancock::Catalog::Admin::Category.config(rails_admin_add_fields) { |config|
8
+ rails_admin_add_config(config)
9
+ })
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ if Hancock::Catalog.config.gallery_support
2
+ module Hancock::Catalog
3
+ _parent_class = Hancock::Gallery::Image if Hancock::Catalog.active_record?
4
+ _parent_class = Hancock::Gallery::EmbeddedImage if Hancock::Catalog.mongoid?
5
+
6
+ class CategoryImage < _parent_class
7
+ include Hancock::Catalog::Models::CategoryImage
8
+
9
+ include Hancock::Catalog::Decorators::CategoryImage
10
+
11
+ rails_admin(&Hancock::Catalog::Admin::CategoryImage.config(nil, rails_admin_add_fields) { |config|
12
+ rails_admin_add_config(config)
13
+ })
14
+ end
15
+ end
16
+ end