ack_rocket_cms_catalog 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) 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 +46 -0
  8. data/Rakefile +1 -0
  9. data/ack_rocket_cms_catalog.gemspec +40 -0
  10. data/app/assets/javascripts/ack_rocket_cms_catalog/ack_rocket_cms_catalog.coffee +0 -0
  11. data/app/assets/stylesheets/ack_rocket_cms_catalog/ack_rocket_cms_catalog.sass +0 -0
  12. data/app/controllers/ack_rocket_cms_catalog/item_categories_controller.rb +5 -0
  13. data/app/controllers/ack_rocket_cms_catalog/items_controller.rb +5 -0
  14. data/app/models/ack_rocket_cms_catalog/item.rb +7 -0
  15. data/app/models/ack_rocket_cms_catalog/item_category.rb +7 -0
  16. data/app/models/ack_rocket_cms_catalog/item_category_image.rb +7 -0
  17. data/app/models/ack_rocket_cms_catalog/item_image.rb +7 -0
  18. data/app/views/ack_rocket_cms_catalog/item_categories/index.html.slim +29 -0
  19. data/app/views/ack_rocket_cms_catalog/item_categories/show.html.slim +84 -0
  20. data/app/views/ack_rocket_cms_catalog/items/index.html.slim +28 -0
  21. data/app/views/ack_rocket_cms_catalog/items/show.html.slim +32 -0
  22. data/bin/console +14 -0
  23. data/bin/setup +7 -0
  24. data/config/initializers/rails_admin.rb +8 -0
  25. data/config/routes.rb +9 -0
  26. data/lib/ack_rocket_cms_catalog.rb +51 -0
  27. data/lib/ack_rocket_cms_catalog/admin.rb +209 -0
  28. data/lib/ack_rocket_cms_catalog/configuration.rb +36 -0
  29. data/lib/ack_rocket_cms_catalog/controllers/item_categories.rb +76 -0
  30. data/lib/ack_rocket_cms_catalog/controllers/items.rb +61 -0
  31. data/lib/ack_rocket_cms_catalog/engine.rb +5 -0
  32. data/lib/ack_rocket_cms_catalog/models/item.rb +27 -0
  33. data/lib/ack_rocket_cms_catalog/models/item_category.rb +35 -0
  34. data/lib/ack_rocket_cms_catalog/models/item_category_image.rb +10 -0
  35. data/lib/ack_rocket_cms_catalog/models/item_image.rb +10 -0
  36. data/lib/ack_rocket_cms_catalog/models/mongoid/item.rb +34 -0
  37. data/lib/ack_rocket_cms_catalog/models/mongoid/item_category.rb +28 -0
  38. data/lib/ack_rocket_cms_catalog/models/mongoid/item_category_image.rb +24 -0
  39. data/lib/ack_rocket_cms_catalog/models/mongoid/item_image.rb +24 -0
  40. data/lib/ack_rocket_cms_catalog/version.rb +3 -0
  41. data/release.sh +7 -0
  42. metadata +174 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d211895039aa934594d9eaac3cc6701b07610a0
4
+ data.tar.gz: 7e1625b74e7f6ccc343f5b7cf82f6d5c64f0917b
5
+ SHA512:
6
+ metadata.gz: fbc4a019dc2c5c3152af6ba7a29d1f9e30bfb2eb27fba5dbf3de8b8f6fc404413c2b0b450847f1de07948bbfe5ec5c16b352da14b656226cef07749c2991c8d4
7
+ data.tar.gz: 16cea71f603a53f4d379f002318d5e2c6377ebde491efb7b619f19210a6163a207f624b30b033f373f9f09636bdf306fc82bb1dac6a6aa2dda7ce77b3ffce348
@@ -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
+ ack_rocket_cms_catalog
@@ -0,0 +1 @@
1
+ 2.2.3
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,46 @@
1
+ # AckRocketCmsCatalog
2
+
3
+ Item Catalog with ack_rocket_cms support. Items, Categories, embedded image galleries.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ack_rocket_cms_catalog'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ack_rocket_cms_catalog
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ack43/ack_rocket_cms_catalog.
34
+
35
+ ## TODO
36
+
37
+ * Do it more flexible.
38
+ * Documentation fixes.
39
+ * More configs (routes, paginations, views....)
40
+ * Find and fix bugs. I am sure, bugs are here.
41
+ * Add Search
42
+
43
+
44
+ ## License
45
+
46
+ 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,40 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ack_rocket_cms_catalog/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ack_rocket_cms_catalog"
8
+ spec.version = AckRocketCmsCatalog::VERSION
9
+ spec.authors = ["Alexander Kiseliev"]
10
+ spec.email = ["i43ack@gmail.com"]
11
+
12
+ spec.summary = "Items catalog with AckRocketCMS support."
13
+ spec.description = "Items catalog with AckRocketCMS support."
14
+ spec.homepage = "https://github.com/ack43/ack_rocket_cms_catalog"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ # spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.10"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+
34
+ spec.add_dependency 'rails', '>= 4.1.0', '< 5.0'
35
+
36
+ spec.add_dependency 'money-rails'
37
+ spec.add_dependency 'mongoid_money_field'
38
+
39
+ spec.add_dependency 'ack_rocket_cms'
40
+ end
@@ -0,0 +1,5 @@
1
+ module AckRocketCmsCatalog # AckRocketCmsCatalog
2
+ class ItemCategoriesController < ApplicationController
3
+ include AckRocketCmsCatalog::Controllers::ItemCategories
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module AckRocketCmsCatalog # AckRocketCmsCatalog
2
+ class ItemsController < ApplicationController
3
+ include AckRocketCmsCatalog::Controllers::Items
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module AckRocketCmsCatalog # AckRocketCmsCatalog
2
+ class Item
3
+ include AckRocketCmsCatalog::Models::Item
4
+ # RocketCMS.apply_patches self
5
+ rails_admin &AckRocketCmsCatalog.item_config
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module AckRocketCmsCatalog # AckRocketCmsCatalog
2
+ class ItemCategory
3
+ include AckRocketCmsCatalog::Models::ItemCategory
4
+ # RocketCMS.apply_patches self
5
+ rails_admin &AckRocketCmsCatalog.item_category_config
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module AckRocketCmsCatalog # AckRocketCmsCatalog
2
+ class ItemCategoryImage < EmbeddedGalleryImage
3
+ include AckRocketCmsCatalog::Models::ItemCategoryImage
4
+ # RocketCMS.apply_patches self
5
+ rails_admin &AckRocketCmsCatalog.item_category_image_config
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module AckRocketCmsCatalog # AckRocketCmsCatalog
2
+ class ItemImage < EmbeddedGalleryImage
3
+ include AckRocketCmsCatalog::Models::ItemImage
4
+ # RocketCMS.apply_patches self
5
+ rails_admin &AckRocketCmsCatalog.item_image_config
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ = render partial: "blocks/seo_block"
2
+
3
+ .ic_content
4
+ //- @item_categories.each do |ic|
5
+ - unless @root_catalog.blank?
6
+
7
+ - @root_catalog.each do |ic|
8
+
9
+ .ic_block
10
+
11
+ = link_to ack_rocket_cms_catalog.item_category_path(ic), title: ic.name do
12
+
13
+ .ic_img_block
14
+
15
+ .ic_image_block
16
+ = image_tag ic.image.url(:main), alt: ic.name, title: ic.name
17
+
18
+ .ic_block_mask
19
+ .ic_block_mask-1
20
+ .ic_block_mask-2
21
+
22
+ .ic_text_block
23
+ h3.ic_title_block
24
+ = ic.name
25
+ //.ic_excerpt_block
26
+ == ic.excerpt
27
+
28
+
29
+ .cf{style="clear: both"}
@@ -0,0 +1,84 @@
1
+ = render partial: "blocks/seo_block_with_obj", locals: {obj: @item_category}
2
+
3
+
4
+ .ic_content
5
+ //- @item_categories.each do |ic|
6
+ //- root_catalog = ItemCategory.enabled.roots.sorted.all.to_a
7
+ //- unless root_catalog.blank?
8
+
9
+ //- root_catalog.each do |ic|
10
+ - label = @item_category.name
11
+ h3.icpage_title = label
12
+
13
+ - unless @item_category.content.blank?
14
+ .ic_description_block
15
+ == @item_category.content
16
+ - if @children.blank? or @items.blank?
17
+ hr
18
+
19
+ - unless @children.blank?
20
+ .icc_block
21
+ - @children.each do |icc|
22
+
23
+ .ic_block
24
+
25
+ = link_to ack_rocket_cms_catalog.item_category_path(icc), title: icc.name do
26
+
27
+ .ic_img_block
28
+
29
+ .ic_image_block
30
+ = image_tag icc.image.url(:main), alt: icc.name, title: icc.name
31
+
32
+ .ic_block_mask
33
+ .ic_block_mask-1
34
+ .ic_block_mask-2
35
+
36
+ .ic_text_block
37
+ h3.ic_title_block
38
+ = icc.name
39
+ //.ic_excerpt_block
40
+ == ic.excerpt
41
+
42
+
43
+ .cf{style="clear: both"}
44
+ br
45
+ - unless @items.blank?
46
+ hr
47
+ br
48
+ //- items = @item_category.items.enabled.sorted.all.to_a
49
+ - unless @items.blank?
50
+ .items_block
51
+ - @items.each do |i|
52
+
53
+
54
+ .item_block
55
+ = link_to ack_rocket_cms_catalog.item_path(i), title: i.name do
56
+ .i_block
57
+
58
+
59
+
60
+ .i_img_block
61
+
62
+ .i_image_block
63
+ = image_tag i.image.url(:main), alt: i.name, title: i.name
64
+
65
+ .i_block_mask
66
+ .i_block_mask-1
67
+ .i_block_mask-2
68
+
69
+ .i_text_block
70
+ h4.i_title_block
71
+ = i.name
72
+ / h5.i_fullname
73
+ / =i.full_name
74
+ hr
75
+ .i_excerpt_block
76
+ == i.excerpt
77
+
78
+
79
+ .cf{style="clear: both"}
80
+
81
+
82
+ / - if @children.blank? and items.blank? and @item_category.content.blank?
83
+ .items_block
84
+ h3= Settings.ns('item_categories').empty_category(default: "Приносим свои извинения. Страница находится на стадии разработки.", label: "Сообщение об отсутсвии товаров в категории", kind: :text)
@@ -0,0 +1,28 @@
1
+ = render partial: "blocks/seo_block_with_obj", locals: {obj: @item}
2
+
3
+
4
+ .i_content
5
+ - unless @items.blank?
6
+ - @items.each do |i|
7
+ .item_block
8
+ = link_to ack_rocket_cms_catalog.item_path(i), title: i.name do
9
+ .i_block
10
+
11
+
12
+ .i_img_block
13
+
14
+ .i_image_block
15
+ = image_tag i.image.url(:main), alt: i.name, title: i.name
16
+
17
+ .i_block_mask
18
+ .i_block_mask-1
19
+ .i_block_mask-2
20
+
21
+ .i_text_block
22
+ h4.i_title_block
23
+ = i.name
24
+ / h5.i_fullname
25
+ / =i.full_name
26
+ hr
27
+ .i_excerpt_block
28
+ == i.excerpt
@@ -0,0 +1,32 @@
1
+ = render partial: "/blocks/seo_block_with_obj", locals: {obj: @item}
2
+
3
+ / .item_fulltitle=@item.full_name
4
+ .item_title= @item.name
5
+
6
+ .item_photoblock
7
+ .item_image_block
8
+ = image_tag @item.image.url(:main), title: @item.name, alt: @item.name, data: {big_image_url: @item.image.url(:big)}
9
+
10
+
11
+ .item_block
12
+ = link_to ack_rocket_cms_catalog.item_path(@item), title: @item.name do
13
+ .i_block
14
+
15
+
16
+ .i_img_block
17
+
18
+ .i_image_block
19
+ = image_tag @item.image.url(:main), alt: @item.name, title: @item.name
20
+
21
+ .i_block_mask
22
+ .i_block_mask-1
23
+ .i_block_mask-2
24
+
25
+ .i_text_block
26
+ h4.i_title_block
27
+ = @item.name
28
+ / h5.i_fullname
29
+ / =@item.full_name
30
+ hr
31
+ .i_excerpt_block
32
+ == @item.excerpt
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ack_rocket_cms_catalog"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ if defined?(RailsAdmin)
2
+ RailsAdmin.config do |config|
3
+ config.excluded_models << [
4
+ 'AckRocketCmsCatalog::ItemImage', 'AckRocketCmsCatalog::ItemCategoryImage'
5
+ ]
6
+ config.excluded_models.flatten!
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ AckRocketCmsCatalog::Engine.routes.draw do
2
+ resources :items, only: [:show] do
3
+ get '(/page/:page)', action: :index, on: :collection, as: ""
4
+ end
5
+ resources :item_categories, only: [:index, :show], path: "catalog" do
6
+ get 'items(/page/:page)', action: :items, on: :member, as: :items
7
+ end
8
+ get 'catalog' => 'item_categories#index', as: :catalog
9
+ end
@@ -0,0 +1,51 @@
1
+ require "ack_rocket_cms_catalog/version"
2
+
3
+ require 'money-rails'
4
+
5
+ require 'ack_rocket_cms_mongoid'
6
+
7
+ require 'ack_rocket_cms_catalog/configuration'
8
+ require 'ack_rocket_cms_catalog/engine'
9
+ require 'ack_rocket_cms_catalog/admin'
10
+
11
+ module AckRocketCmsCatalog
12
+ class << self
13
+ def orm
14
+ :mongoid
15
+ end
16
+ def mongoid?
17
+ true
18
+ # AckRocketCmsCatalog.orm == :mongoid
19
+ end
20
+ def active_record?
21
+ false
22
+ # AckRocketCmsCatalog.orm == :active_record
23
+ end
24
+ def model_namespace
25
+ "AckRocketCmsCatalog::Models::#{AckRocketCmsCatalog.orm.to_s.camelize}"
26
+ end
27
+ def orm_specific(name)
28
+ "#{model_namespace}::#{name}".constantize
29
+ end
30
+ end
31
+
32
+ module Models
33
+ autoload :Item, 'ack_rocket_cms_catalog/models/item'
34
+ autoload :ItemCategory, 'ack_rocket_cms_catalog/models/item_category'
35
+ autoload :ItemImage, 'ack_rocket_cms_catalog/models/item_image'
36
+ autoload :ItemCategoryImage, 'ack_rocket_cms_catalog/models/item_category_image'
37
+
38
+ module Mongoid
39
+ autoload :Item, 'ack_rocket_cms_catalog/models/mongoid/item'
40
+ autoload :ItemCategory, 'ack_rocket_cms_catalog/models/mongoid/item_category'
41
+ autoload :ItemImage, 'ack_rocket_cms_catalog/models/mongoid/item_image'
42
+ autoload :ItemCategoryImage, 'ack_rocket_cms_catalog/models/mongoid/item_category_image'
43
+ end
44
+ end
45
+
46
+ module Controllers
47
+ autoload :Items, 'ack_rocket_cms_catalog/controllers/items'
48
+ autoload :ItemCategories, 'ack_rocket_cms_catalog/controllers/item_categories'
49
+ end
50
+
51
+ end
@@ -0,0 +1,209 @@
1
+ module AckRocketCmsCatalog
2
+ class << self
3
+ def item_config(fields = {})
4
+ Proc.new {
5
+
6
+ # field :views_count do
7
+ # read_only true
8
+ # end
9
+
10
+ list do
11
+ scopes [:sorted, :enabled, nil]
12
+
13
+ field :enabled, :toggle
14
+ field :name
15
+ field :price
16
+ field :item_categories
17
+ field :image
18
+ end
19
+
20
+ edit do
21
+ field :enabled, :toggle
22
+ field :name
23
+ field :slugs, :enum do
24
+ enum_method do
25
+ :slugs
26
+ end
27
+ visible do
28
+ bindings[:view].current_user.admin?
29
+ end
30
+ multiple do
31
+ true
32
+ end
33
+ end
34
+ field :text_slug
35
+ field :image, :jcrop do
36
+ jcrop_options do
37
+ :image_jcrop_options
38
+ end
39
+ end
40
+ field :item_categories
41
+ field :excerpt, :ck_editor
42
+ field :content, :ck_editor
43
+
44
+ field :item_images
45
+
46
+ fields.each_pair do |name, type|
47
+ if type.nil?
48
+ field name
49
+ else
50
+ if type.is_a?(Array)
51
+ field name, type[0], &type[1]
52
+ else
53
+ field name, type
54
+ end
55
+ end
56
+ end
57
+
58
+ group :seo, &RocketCMS.seo_config
59
+ group :sitemap_data, &RocketCMS.sitemap_data_config
60
+ end
61
+
62
+ nested_set({max_depth: 1, scopes: []})
63
+
64
+ sort_embedded(
65
+ {
66
+ fields: [:item_images]
67
+ }
68
+ )
69
+
70
+ if block_given?
71
+ yield
72
+ end
73
+ }
74
+ end
75
+
76
+
77
+ def item_category_config(fields = {})
78
+ Proc.new {
79
+
80
+ list do
81
+ scopes [:sorted, :enabled, nil]
82
+
83
+ field :enabled, :toggle
84
+ field :name
85
+ field :image
86
+
87
+ field :items do
88
+ read_only true
89
+
90
+ pretty_value do
91
+ bindings[:object].items.to_a.map { |h|
92
+ (bindings[:view] || bindings[:controller]).link_to(h.name, (bindings[:view] || bindings[:controller]).rails_admin.show_path(model_name: "item", id: h.id), title: h.name)
93
+ }.join("<br>").html_safe
94
+ end
95
+ end
96
+ end
97
+
98
+ edit do
99
+ field :enabled, :toggle
100
+ field :name
101
+ field :slugs, :enum do
102
+ enum_method do
103
+ :slugs
104
+ end
105
+ visible do
106
+ bindings[:view].current_user.admin?
107
+ end
108
+ multiple do
109
+ true
110
+ end
111
+ end
112
+ field :text_slug
113
+ field :image, :jcrop do
114
+ jcrop_options do
115
+ :image_jcrop_options
116
+ end
117
+ end
118
+ field :excerpt, :ck_editor
119
+ field :content, :ck_editor
120
+
121
+ fields.each_pair do |name, type|
122
+ if type.nil?
123
+ field name
124
+ else
125
+ if type.is_a?(Array)
126
+ field name, type[0], &type[1]
127
+ else
128
+ field name, type
129
+ end
130
+ end
131
+ end
132
+
133
+ group :seo, &RocketCMS.seo_config
134
+ group :sitemap_data, &RocketCMS.sitemap_data_config
135
+
136
+ field :items do
137
+ read_only true
138
+ help 'Список товаров'
139
+
140
+ pretty_value do
141
+ bindings[:object].items.to_a.map { |h|
142
+ (bindings[:view] || bindings[:controller]).link_to(h.name, (bindings[:view] || bindings[:controller]).rails_admin.edit_path(model_name: "item", id: h.id), title: h.name)
143
+ }.join("<br>").html_safe
144
+ end
145
+ end
146
+ end
147
+
148
+ show do
149
+ field :name
150
+ field :sidebar_title
151
+ field :slugs, :enum do
152
+ enum_method do
153
+ :slugs
154
+ end
155
+ visible do
156
+ bindings[:view].current_user.admin?
157
+ end
158
+ multiple do
159
+ true
160
+ end
161
+ end
162
+ field :text_slug
163
+ field :enabled
164
+ field :image
165
+ field :excerpt
166
+ field :content
167
+
168
+ field :items do
169
+ read_only true
170
+
171
+ pretty_value do
172
+ bindings[:object].items.to_a.map { |h|
173
+ (bindings[:view] || bindings[:controller]).link_to(h.name, (bindings[:view] || bindings[:controller]).rails_admin.show_path(model_name: "item", id: h.id), title: h.name)
174
+ }.join("<br>").html_safe
175
+ end
176
+ end
177
+ end
178
+
179
+ nested_set({max_depth: 2, scopes: []})
180
+
181
+ sort_embedded(
182
+ {
183
+ fields: [:item_category_images]
184
+ }
185
+ )
186
+
187
+ if block_given?
188
+ yield
189
+ end
190
+ }
191
+ end
192
+
193
+
194
+ def item_image_config(fields = {})
195
+ Proc.new {
196
+ RocketCMS.embedded_image_config(fields)
197
+ }
198
+ end
199
+
200
+
201
+ def item_category_image_config(fields = {})
202
+ Proc.new {
203
+ RocketCMS.embedded_image_config(fields)
204
+ }
205
+ end
206
+
207
+
208
+ end
209
+ end
@@ -0,0 +1,36 @@
1
+ module AckRocketCmsCatalog
2
+ def self.configuration
3
+ @configuration ||= Configuration.new
4
+ end
5
+ def self.config
6
+ @configuration ||= Configuration.new
7
+ end
8
+
9
+ def self.configure
10
+ yield configuration
11
+ end
12
+
13
+ class Configuration
14
+ attr_accessor :item_image_styles
15
+ attr_accessor :item_per_page
16
+
17
+ attr_accessor :item_images_image_styles
18
+
19
+ attr_accessor :item_category_image_styles
20
+ attr_accessor :item_category_per_page
21
+
22
+ attr_accessor :item_category_images_image_styles
23
+
24
+ def initialize
25
+ @item_image_styles = {}
26
+ @item_per_page = 10
27
+
28
+ @item_images_image_styles = {}
29
+
30
+ @item_category_image_styles = {}
31
+ @item_category_per_page = 10
32
+
33
+ @item_category_images_image_styles = {}
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,76 @@
1
+ module AckRocketCmsCatalog
2
+ module Controllers
3
+ module ItemCategories
4
+ extend ActiveSupport::Concern
5
+
6
+ def index
7
+ @item_categories = item_category_class.enabled.sorted.to_a
8
+ @root_catalog = item_category_class.enabled.roots.sorted.all.to_a
9
+ # index_crumbs
10
+ end
11
+
12
+ def show
13
+ @item_category = item_category_class.enabled.find(params[:id])
14
+ if !@item_category.text_slug.blank? and @item_category.text_slug != params[:id]
15
+ redirect_to @item_category, status_code: 301
16
+ return
17
+ end
18
+ @seo_parent_page = find_seo_page(item_categories_path)
19
+
20
+ @children = @item_category.children.enabled.sorted.all.to_a
21
+ @items = @item_category.items.enabled.sorted.all.to_a
22
+
23
+ # index_crumbs
24
+ # category_crumbs
25
+ end
26
+
27
+ def page_title
28
+ if @item_category
29
+ @item_category.page_title
30
+ else
31
+ super
32
+ end
33
+ end
34
+
35
+ private
36
+ def item_category_class
37
+ ItemCategory
38
+ end
39
+ def item_class
40
+ Item
41
+ end
42
+
43
+ # def index_crumbs
44
+ # if @seo_parent_page
45
+ # catalog_title = Settings.ns('breadcrumbs').catalog_title(default: "Каталог", label: "'Каталог' в breadcrumbs")
46
+ # _crumb = catalog_title
47
+ # _crumb = @seo_parent_page.name if _crumb.blank?
48
+ # _crumb = @seo_parent_page.title if _crumb.blank?
49
+ # _crumb = @seo_parent_page.h1 if _crumb.blank?
50
+ # add_crumb _crumb, @seo_parent_page.fullpath
51
+ # else
52
+ # catalog_title = Settings.ns('breadcrumbs').catalog_title(default: "Каталог", label: "'Каталог' в breadcrumbs")
53
+ # _crumb = catalog_title
54
+ # add_crumb _crumb, item_categories_path
55
+ # end
56
+ # end
57
+ #
58
+ # def category_crumbs
59
+ # if @item_category
60
+ # _parent = @item_category.parent
61
+ # if _parent
62
+ # _crumb = _parent.name if _crumb.blank?
63
+ # _crumb = _parent.title if _crumb.blank?
64
+ # _crumb = _parent.h1 if _crumb.blank?
65
+ # add_crumb _crumb, item_category_path(_parent)
66
+ # _crumb = nil
67
+ # end
68
+ # _crumb = @item_category.name if _crumb.blank?
69
+ # _crumb = @item_category.title if _crumb.blank?
70
+ # _crumb = @item_category.h1 if _crumb.blank?
71
+ # add_crumb _crumb, item_category_path(@item_category)
72
+ # end
73
+ # end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,61 @@
1
+ module AckRocketCmsCatalog
2
+ module Controllers
3
+ module Items
4
+ extend ActiveSupport::Concern
5
+
6
+ def index
7
+ @items = item_class.enabled.sorted.to_a
8
+ # index_crumbs
9
+ end
10
+
11
+ def show
12
+ @item = item_class.enabled.find(params[:id])
13
+ if !@item.text_slug.blank? and @item.text_slug != params[:id]
14
+ redirect_to @item, status_code: 301
15
+ return
16
+ end
17
+ @parent_seo_page = find_seo_page(item_categories_path) if @seo_page.blank?
18
+ # item_crumbs
19
+ end
20
+
21
+ def page_title
22
+ if @item
23
+ @item.page_title
24
+ else
25
+ super
26
+ end
27
+ end
28
+
29
+ private
30
+ def item_category_class
31
+ ItemCategory
32
+ end
33
+ def item_class
34
+ Item
35
+ end
36
+
37
+ # def item_crumbs
38
+ # if @item
39
+ # if @item.item_categories.enabled.count == 1
40
+ # if @parent_seo_page
41
+ # _crumb = @parent_seo_page.name
42
+ # _crumb = @parent_seo_page.title if _crumb.blank?
43
+ # _crumb = @parent_seo_page.h1 if _crumb.blank?
44
+ # add_crumb _crumb, @parent_seo_page.fullpath
45
+ # end
46
+ #
47
+ # @item_category = @item.item_categories.enabled.first
48
+ # _crumb = @item_category.name
49
+ # _crumb = @item_category.title if _crumb.blank?
50
+ # _crumb = @item_category.h1 if _crumb.blank?
51
+ # add_crumb _crumb, item_category_path(@item_category)
52
+ # end
53
+ # _crumb = @item.name
54
+ # _crumb = @item.title if _crumb.blank?
55
+ # _crumb = @item.h1 if _crumb.blank?
56
+ # add_crumb _crumb, item_path(@item)
57
+ # end
58
+ # end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,5 @@
1
+ module AckRocketCmsCatalog
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace AckRocketCmsCatalog
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ module AckRocketCmsCatalog
2
+ module Models
3
+ module Item
4
+ extend ActiveSupport::Concern
5
+ include RocketCMS::Model
6
+ include AckRocketCmsCatalog.orm_specific('Item')
7
+
8
+ include Enableable
9
+ include Seoable
10
+ include SitemapData
11
+
12
+ include ManualSlug
13
+
14
+ included do
15
+ manual_slug :name
16
+
17
+ def clean_excerpt
18
+ Rails::Html::FullSanitizer.new.sanitize(self.excerpt.strip)
19
+ end
20
+
21
+ def clean_content
22
+ Rails::Html::FullSanitizer.new.sanitize(self.content.strip)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,35 @@
1
+ module AckRocketCmsCatalog
2
+ module Models
3
+ module ItemCategory
4
+ extend ActiveSupport::Concern
5
+ include RocketCMS::Model
6
+ include AckRocketCmsCatalog.orm_specific('ItemCategory')
7
+
8
+ include Enableable
9
+ include Seoable
10
+ include SitemapData
11
+
12
+ include ManualSlug
13
+
14
+ included do
15
+ manual_slug :name
16
+
17
+ def clean_excerpt
18
+ Rails::Html::FullSanitizer.new.sanitize(self.excerpt.strip)
19
+ end
20
+
21
+ def clean_content
22
+ Rails::Html::FullSanitizer.new.sanitize(self.content.strip)
23
+ end
24
+
25
+ def items
26
+ AckRocketCmsCatalog::Item.in(item_category_ids: self.id)
27
+ end
28
+
29
+ def all_items
30
+ AckRocketCmsCatalog::Item.any_in(item_category_ids: self.self_and_descendants.map(&:id))
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,10 @@
1
+ module AckRocketCmsCatalog
2
+ module Models
3
+ module ItemCategoryImage
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module AckRocketCmsCatalog
2
+ module Models
3
+ module ItemImage
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ module AckRocketCmsCatalog
2
+ module Models
3
+ module Mongoid
4
+ module Item
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ field :name, type: String, localize: RocketCMS.configuration.localize, default: ""
8
+
9
+ include RocketCMSMongoidPaperclip
10
+ rocket_cms_mongoid_attached_file(:image,
11
+ styles: AckRocketCmsCatalog.configuration.item_image_styles,
12
+ content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
13
+ )
14
+
15
+ acts_as_nested_set
16
+ scope :sorted, -> { order_by([:lft, :asc]) }
17
+
18
+ field :excerpt, type: String, localize: RocketCMS.configuration.localize, default: ""
19
+ field :content, type: String, localize: RocketCMS.configuration.localize, default: ""
20
+
21
+ has_and_belongs_to_many :item_categories, class_name: "AckRocketCmsCatalog::ItemCategory", inverse_of: nil
22
+
23
+ embeds_many :item_images, cascade_callbacks: true, class_name: "AckRocketCmsCatalog::ItemImage"
24
+ alias :images :item_images
25
+ accepts_nested_attributes_for :item_images, allow_destroy: true
26
+
27
+ has_and_belongs_to_many :related_items, :class_name => 'AckRocketCmsCatalog::Item', :inverse_of => :related_items
28
+
29
+ field :price, type: Money, default: nil, localize: RocketCMS.configuration.localize
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ module AckRocketCmsCatalog
2
+ module Models
3
+ module Mongoid
4
+ module ItemCategory
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ field :name, type: String, localize: RocketCMS.configuration.localize, default: ""
8
+
9
+ include RocketCMSMongoidPaperclip
10
+ rocket_cms_mongoid_attached_file(:image,
11
+ styles: AckRocketCmsCatalog.configuration.item_category_image_styles,
12
+ content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
13
+ )
14
+
15
+ acts_as_nested_set
16
+ scope :sorted, -> { order_by([:lft, :asc]) }
17
+
18
+ field :excerpt, type: String, localize: RocketCMS.configuration.localize, default: ""
19
+ field :content, type: String, localize: RocketCMS.configuration.localize, default: ""
20
+
21
+ embeds_many :item_categoty_images, cascade_callbacks: true, class_name: "AckRocketCmsCatalog::ItemCategoryImage"
22
+ alias :images :item_categoty_images
23
+ accepts_nested_attributes_for :item_categoty_images, allow_destroy: true
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,24 @@
1
+ module AckRocketCmsCatalog
2
+ module Models
3
+ module Mongoid
4
+ module ItemCategoryImage
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ embedded_in :item, class_name: "AckRocketCmsCatalog::ItemCategory"
8
+
9
+ include RocketCMSMongoidPaperclip
10
+ rocket_cms_mongoid_attached_file(:image,
11
+ styles: AckRocketCmsCatalog.configuration.item_category_images_image_styles,
12
+ content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] },
13
+ processors: [:rails_admin_jcropper]
14
+ )
15
+
16
+ include Mongoid::EmbeddedFindable
17
+ def self.find(id)
18
+ find_through(::ItemCategory, 'item_category_images', id)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ module AckRocketCmsCatalog
2
+ module Models
3
+ module Mongoid
4
+ module ItemImage
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ embedded_in :item, class_name: "AckRocketCmsCatalog::Item"
8
+
9
+ include RocketCMSMongoidPaperclip
10
+ rocket_cms_mongoid_attached_file(:image,
11
+ styles: AckRocketCmsCatalog.configuration.item_images_image_styles,
12
+ content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] },
13
+ processors: [:rails_admin_jcropper]
14
+ )
15
+
16
+ include Mongoid::EmbeddedFindable
17
+ def self.find(id)
18
+ find_through(::Item, 'item_images', id)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module AckRocketCmsCatalog
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/bash
2
+ bundle update
3
+ git add --all .
4
+ git commit -am "${*:1}"
5
+ git push
6
+ git push gh master
7
+ rake release
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ack_rocket_cms_catalog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Kiseliev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 4.1.0
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '5.0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 4.1.0
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '5.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: money-rails
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: mongoid_money_field
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: ack_rocket_cms
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ description: Items catalog with AckRocketCMS support.
104
+ email:
105
+ - i43ack@gmail.com
106
+ executables: []
107
+ extensions: []
108
+ extra_rdoc_files: []
109
+ files:
110
+ - ".gitignore"
111
+ - ".ruby-gemset"
112
+ - ".ruby-version"
113
+ - Gemfile
114
+ - LICENSE.txt
115
+ - README.md
116
+ - Rakefile
117
+ - ack_rocket_cms_catalog.gemspec
118
+ - app/assets/javascripts/ack_rocket_cms_catalog/ack_rocket_cms_catalog.coffee
119
+ - app/assets/stylesheets/ack_rocket_cms_catalog/ack_rocket_cms_catalog.sass
120
+ - app/controllers/ack_rocket_cms_catalog/item_categories_controller.rb
121
+ - app/controllers/ack_rocket_cms_catalog/items_controller.rb
122
+ - app/models/ack_rocket_cms_catalog/item.rb
123
+ - app/models/ack_rocket_cms_catalog/item_category.rb
124
+ - app/models/ack_rocket_cms_catalog/item_category_image.rb
125
+ - app/models/ack_rocket_cms_catalog/item_image.rb
126
+ - app/views/ack_rocket_cms_catalog/item_categories/index.html.slim
127
+ - app/views/ack_rocket_cms_catalog/item_categories/show.html.slim
128
+ - app/views/ack_rocket_cms_catalog/items/index.html.slim
129
+ - app/views/ack_rocket_cms_catalog/items/show.html.slim
130
+ - bin/console
131
+ - bin/setup
132
+ - config/initializers/rails_admin.rb
133
+ - config/routes.rb
134
+ - lib/ack_rocket_cms_catalog.rb
135
+ - lib/ack_rocket_cms_catalog/admin.rb
136
+ - lib/ack_rocket_cms_catalog/configuration.rb
137
+ - lib/ack_rocket_cms_catalog/controllers/item_categories.rb
138
+ - lib/ack_rocket_cms_catalog/controllers/items.rb
139
+ - lib/ack_rocket_cms_catalog/engine.rb
140
+ - lib/ack_rocket_cms_catalog/models/item.rb
141
+ - lib/ack_rocket_cms_catalog/models/item_category.rb
142
+ - lib/ack_rocket_cms_catalog/models/item_category_image.rb
143
+ - lib/ack_rocket_cms_catalog/models/item_image.rb
144
+ - lib/ack_rocket_cms_catalog/models/mongoid/item.rb
145
+ - lib/ack_rocket_cms_catalog/models/mongoid/item_category.rb
146
+ - lib/ack_rocket_cms_catalog/models/mongoid/item_category_image.rb
147
+ - lib/ack_rocket_cms_catalog/models/mongoid/item_image.rb
148
+ - lib/ack_rocket_cms_catalog/version.rb
149
+ - release.sh
150
+ homepage: https://github.com/ack43/ack_rocket_cms_catalog
151
+ licenses:
152
+ - MIT
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.4.8
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: Items catalog with AckRocketCMS support.
174
+ test_files: []