enjoy_cms_news 0.4.0.beta3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +4 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +41 -0
  9. data/Rakefile +1 -0
  10. data/app/assets/javascripts/enjoy_cms_news.coffee +0 -0
  11. data/app/assets/stylesheets/enjoy_cms_news.sass +0 -0
  12. data/app/controllers/concerns/enjoy/news/decorators/categories.rb +5 -0
  13. data/app/controllers/concerns/enjoy/news/decorators/news_controller.rb +5 -0
  14. data/app/controllers/enjoy/news/categories_controller.rb +7 -0
  15. data/app/controllers/enjoy/news/news_controller.rb +7 -0
  16. data/app/models/concerns/enjoy/news/decorators/category.rb +5 -0
  17. data/app/models/concerns/enjoy/news/decorators/image.rb +5 -0
  18. data/app/models/concerns/enjoy/news/decorators/news.rb +5 -0
  19. data/app/models/enjoy/news/category.rb +11 -0
  20. data/app/models/enjoy/news/image.rb +16 -0
  21. data/app/models/enjoy/news/news.rb +16 -0
  22. data/app/views/enjoy/news/news/_list.html.slim +6 -0
  23. data/app/views/enjoy/news/news/index.html.slim +4 -0
  24. data/app/views/enjoy/news/news/show.html.slim +8 -0
  25. data/bin/console +14 -0
  26. data/bin/setup +7 -0
  27. data/config/initializers/enjoy_news.rb +72 -0
  28. data/config/locales/enjoy.news.ru.yml +13 -0
  29. data/enjoy_cms_news.gemspec +38 -0
  30. data/lib/enjoy/news/admin/category.rb +143 -0
  31. data/lib/enjoy/news/admin/image.rb +31 -0
  32. data/lib/enjoy/news/admin/news.rb +101 -0
  33. data/lib/enjoy/news/admin.rb +6 -0
  34. data/lib/enjoy/news/configuration.rb +61 -0
  35. data/lib/enjoy/news/controllers/categories.rb +72 -0
  36. data/lib/enjoy/news/controllers/news.rb +39 -0
  37. data/lib/enjoy/news/engine.rb +7 -0
  38. data/lib/enjoy/news/models/active_record/category.rb +25 -0
  39. data/lib/enjoy/news/models/active_record/image.rb +16 -0
  40. data/lib/enjoy/news/models/active_record/news.rb +29 -0
  41. data/lib/enjoy/news/models/category.rb +62 -0
  42. data/lib/enjoy/news/models/image.rb +20 -0
  43. data/lib/enjoy/news/models/mongoid/category.rb +28 -0
  44. data/lib/enjoy/news/models/mongoid/image.rb +22 -0
  45. data/lib/enjoy/news/models/mongoid/news.rb +39 -0
  46. data/lib/enjoy/news/models/news.rb +57 -0
  47. data/lib/enjoy/news/routes.rb +56 -0
  48. data/lib/enjoy/news/version.rb +5 -0
  49. data/lib/enjoy_cms_news.rb +69 -0
  50. data/lib/generators/enjoy/news/all_generator.rb +17 -0
  51. data/lib/generators/enjoy/news/config/install_generator.rb +13 -0
  52. data/lib/generators/enjoy/news/config/templates/enjoy_news.erb +28 -0
  53. data/lib/generators/enjoy/news/controllers/all_generator.rb +28 -0
  54. data/lib/generators/enjoy/news/controllers/category_generator.rb +43 -0
  55. data/lib/generators/enjoy/news/controllers/news_generator.rb +43 -0
  56. data/lib/generators/enjoy/news/controllers/templates/categories_controller.erb +10 -0
  57. data/lib/generators/enjoy/news/controllers/templates/news_controller.erb +10 -0
  58. data/lib/generators/enjoy/news/migrations/migration_generator.rb +18 -0
  59. data/lib/generators/enjoy/news/migrations/templates/news.rb +92 -0
  60. data/lib/generators/enjoy/news/models/all_generator.rb +33 -0
  61. data/lib/generators/enjoy/news/models/category_generator.rb +39 -0
  62. data/lib/generators/enjoy/news/models/image_generator.rb +39 -0
  63. data/lib/generators/enjoy/news/models/news_generator.rb +34 -0
  64. data/lib/generators/enjoy/news/models/templates/category.erb +30 -0
  65. data/lib/generators/enjoy/news/models/templates/image.erb +30 -0
  66. data/lib/generators/enjoy/news/models/templates/item.erb +38 -0
  67. data/release.sh +7 -0
  68. metadata +194 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 427c33f8fec9da42bf8cd9e13cd1572ab65e9256
4
+ data.tar.gz: 4bb62174579b77dc3289f0fea31d6f37cd39cb21
5
+ SHA512:
6
+ metadata.gz: 1f23fedba1907c0d31a0fbcae4b548bb5797c3d71b8f2bce1403261dc1be7b4714962db61ae69caa7f4c74832d20567c0ebbc25e6bb4c607cab71fada42c1c4c
7
+ data.tar.gz: 358af92a6bf1f42cb5b875c5d6c8107adaa3f21e02c5f259b2d053a4e60b39b67c6de22c86afe8418832df7e822f41887ff2ae720d3ed70ccd054cad30b52c45
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ enjoy_cms_news
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.3.1
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in enjoy_cms_news.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 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.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # EnjoyCmsNews
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/enjoy_cms_news`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'enjoy_cms_news'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install enjoy_cms_news
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/enjoy_cms_news.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ module Enjoy::News::Decorators
2
+ module Categories
3
+ extend ActiveSupport::Concern
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Enjoy::News::Decorators
2
+ module NewsController
3
+ extend ActiveSupport::Concern
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module Enjoy::News
2
+ class CategoriesController < ApplicationController
3
+ include Enjoy::News::Controllers::Categories
4
+
5
+ include Enjoy::News::Decorators::Categories
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Enjoy::News
2
+ class NewsController < ApplicationController
3
+ include Enjoy::News::Controllers::News
4
+
5
+ include Enjoy::News::Decorators::NewsController
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Enjoy::News::Decorators
2
+ module Category
3
+ extend ActiveSupport::Concern
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Enjoy::News::Decorators
2
+ module Image
3
+ extend ActiveSupport::Concern
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Enjoy::News::Decorators
2
+ module News
3
+ extend ActiveSupport::Concern
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ module Enjoy::News
2
+ class Category
3
+ include Enjoy::News::Models::Category
4
+
5
+ include Enjoy::News::Decorators::Category
6
+
7
+ rails_admin(&Enjoy::News::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 Enjoy::News.config.gallery_support
2
+ module Enjoy::News
3
+ _parent_class = Enjoy::Gallery::Image if Enjoy::News.active_record?
4
+ _parent_class = Enjoy::Gallery::EmbeddedImage if Enjoy::News.mongoid?
5
+
6
+ class Image < _parent_class
7
+ include Enjoy::News::Models::Image
8
+
9
+ include Enjoy::News::Decorators::Image
10
+
11
+ rails_admin(&Enjoy::News::Admin::Image.config(nil, rails_admin_add_fields) { |config|
12
+ rails_admin_add_config(config)
13
+ })
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Enjoy::News
2
+ if Enjoy::News.active_record?
3
+ class News < ActiveRecord::Base
4
+ end
5
+ end
6
+
7
+ class News
8
+ include Enjoy::News::Models::News
9
+
10
+ include Enjoy::News::Decorators::News
11
+
12
+ rails_admin(&Enjoy::News::Admin::News.config(rails_admin_add_fields) { |config|
13
+ rails_admin_add_config(config)
14
+ })
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ - @news.each do |news|
2
+ .enjoy-news-date= l(news.time.to_date)
3
+ = link_to news.name, news, class: "enjoy-news-title", title: news.name
4
+ - if Enjoy::News.config.gallery_support and news.image?
5
+ .enjoy-news-image= image_tag news.image.url(:thumb)
6
+ .enjoy-news-excerpt== news.excerpt
@@ -0,0 +1,4 @@
1
+ .enjoy-news-index
2
+ h1= t('enjoy.news')
3
+ = render partial: "enjoy/news/news/list"
4
+ = paginate @news
@@ -0,0 +1,8 @@
1
+ .enjoy-news-show
2
+ h1.enjoy-news-title= @news.name
3
+ .enjoy-news-date= l(@news.time.to_date)
4
+ .enjoy-news-text== @news.content
5
+ - if !Enjoy::News.config.news_image_styles.nil? && @news.image?
6
+ .enjoy-news-image= image_tag @news.image.url(:main)
7
+ .enjoy-news-content
8
+ = render 'shared/obj', obj: @news
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "enjoy_cms_news"
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
data/bin/setup ADDED
@@ -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,72 @@
1
+ Enjoy.rails_admin_configure do |config|
2
+ config.action_visible_for :nested_set, 'Enjoy::News::Category'
3
+
4
+ if Enjoy::News.active_record?
5
+ config.action_visible_for :nested_set, 'Enjoy::News::Image'
6
+ elsif Enjoy::News.mongoid?
7
+ config.action_visible_for :sort_embedded, 'Enjoy::News::News'
8
+ end
9
+
10
+ if defined?(RailsAdminComments)
11
+ config.action_visible_for :comments, 'Enjoy::News::News'
12
+ config.action_visible_for :comments, 'Enjoy::News::Category'
13
+ if Enjoy::News.active_record?
14
+ config.action_visible_for :comments, 'Enjoy::News::Image'
15
+ end
16
+ config.action_visible_for :model_comments, 'Enjoy::News::News'
17
+ config.action_visible_for :model_comments, 'Enjoy::News::Category'
18
+ if Enjoy::News.active_record?
19
+ config.action_visible_for :model_comments, 'Enjoy::News::Image'
20
+ end
21
+ end
22
+
23
+ if defined?(RailsAdminMultipleFileUpload)
24
+ if Enjoy::News.mongoid?
25
+ config.action_visible_for :multiple_file_upload, 'Enjoy::News::News'
26
+ end
27
+ end
28
+ end
29
+
30
+ Enjoy.configure do |config|
31
+ _actions = [:new, :edit, :update, :multiple_file_upload, :sort_embedded]
32
+ if Enjoy::News.active_record?
33
+ _actions.delete(:multiple_file_upload)
34
+ _actions.delete(:sort_embedded)
35
+ end
36
+ config.ability_manager_config << {
37
+ method: :can,
38
+ model: Enjoy::News::News,
39
+ actions: _actions
40
+ }
41
+ config.ability_admin_config << {
42
+ method: :can,
43
+ model: Enjoy::News::News,
44
+ actions: :manage
45
+ }
46
+
47
+ _actions = [:new, :edit, :update, :nested_set, :multiple_file_upload, :sort_embedded]
48
+ if Enjoy::News.active_record?
49
+ _actions.delete(:multiple_file_upload)
50
+ _actions.delete(:sort_embedded)
51
+ end
52
+ config.ability_manager_config << {
53
+ method: :can,
54
+ model: Enjoy::News::Category,
55
+ actions: _actions
56
+ }
57
+ config.ability_manager_config << {
58
+ method: :can,
59
+ model: Enjoy::News::Image,
60
+ actions: _actions
61
+ }
62
+ config.ability_admin_config << {
63
+ method: :can,
64
+ model: Enjoy::News::Category,
65
+ actions: :manage
66
+ }
67
+ config.ability_admin_config << {
68
+ method: :can,
69
+ model: Enjoy::News::Image,
70
+ actions: :manage
71
+ }
72
+ end
@@ -0,0 +1,13 @@
1
+ ru:
2
+ enjoy:
3
+ news: 'Новости'
4
+
5
+ mongoid: &mongoid
6
+ models:
7
+ enjoy/news/news: Новости
8
+ enjoy/news/image: Фотогалерея новости
9
+ enjoy/news/category: Разделы
10
+ attributes:
11
+
12
+ activerecord:
13
+ <<: *mongoid
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'enjoy/news/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "enjoy_cms_news"
8
+ spec.version = Enjoy::News::VERSION
9
+ spec.authors = ["Alexander Kiseliev"]
10
+ spec.email = ["i43ack@gmail.com"]
11
+
12
+ spec.summary = %q{enjoy_cms_news}
13
+ spec.description = %q{enjoy_cms_news}
14
+ spec.homepage = "https://github.com/enjoycreative/enjoy_cms_news"
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.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+
33
+ spec.add_dependency 'enjoy_cms', "~> 0.4.0.beta3"
34
+ spec.add_dependency 'stringex'
35
+ spec.add_dependency 'smart_excerpt'
36
+
37
+ spec.add_dependency 'kaminari'
38
+ end
@@ -0,0 +1,143 @@
1
+ module Enjoy::News
2
+ module Admin
3
+ module Category
4
+ def self.config(fields = {})
5
+ Proc.new {
6
+ navigation_label I18n.t('enjoy.news')
7
+
8
+ list do
9
+ scopes [:sorted, :enabled, nil]
10
+
11
+ field :enabled, :toggle do
12
+ searchable false
13
+ end
14
+ field :name do
15
+ searchable true
16
+ end
17
+ if Enjoy::News.config.pages_support
18
+ field :connected_pages, :enjoy_connectable
19
+ end
20
+ end
21
+
22
+ edit do
23
+ field :enabled, :toggle
24
+ field :name
25
+ if Enjoy::News.config.pages_support
26
+ group :connected_pages do
27
+ active false
28
+ field :connected_pages, :enjoy_connectable
29
+ end
30
+ end
31
+ group :URL do
32
+ active false
33
+ field :slugs, :enum do
34
+ enum_method do
35
+ :slugs
36
+ end
37
+ visible do
38
+ bindings[:view].current_user.admin?
39
+ end
40
+ multiple do
41
+ true
42
+ end
43
+ end
44
+ field :text_slug
45
+ end
46
+
47
+
48
+ if Enjoy::News.config.gallery_support
49
+ group :image do
50
+ active false
51
+ field :image, :jcrop do
52
+ jcrop_options do
53
+ :image_jcrop_options
54
+ end
55
+ end
56
+ # field :item_category_images
57
+ end
58
+ end
59
+
60
+ group :content do
61
+ active false
62
+ field :excerpt, :enjoy_html
63
+ field :content, :enjoy_html
64
+ end
65
+
66
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
67
+
68
+ if Enjoy::News.config.seo_support
69
+ group :seo do
70
+ active false
71
+ field :seo do
72
+ active true
73
+ end
74
+ end
75
+ group :sitemap_data do
76
+ active false
77
+ field :sitemap_data do
78
+ active true
79
+ end
80
+ end
81
+ end
82
+
83
+ group :news do
84
+ active false
85
+ field :news do
86
+ read_only true
87
+ help 'Список Новостей'
88
+
89
+ pretty_value do
90
+ bindings[:object].news.to_a.map { |n|
91
+ route = (bindings[:view] || bindings[:controller])
92
+ model_name = n.rails_admin_model
93
+ route.link_to(n.name, route.rails_admin.show_path(model_name: model_name, id: n.id), title: n.name)
94
+ }.join("<br>").html_safe
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ show do
101
+ field :name
102
+ field :slugs, :enum do
103
+ enum_method do
104
+ :slugs
105
+ end
106
+ visible do
107
+ bindings[:view].current_user.admin?
108
+ end
109
+ multiple do
110
+ true
111
+ end
112
+ end
113
+ field :text_slug
114
+ field :enabled
115
+ field :image
116
+ field :excerpt
117
+ field :content
118
+
119
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
120
+
121
+ field :news do
122
+ read_only true
123
+
124
+ pretty_value do
125
+ bindings[:object].news.to_a.map { |n|
126
+ route = (bindings[:view] || bindings[:controller])
127
+ model_name = n.rails_admin_model
128
+ route.link_to(n.name, route.rails_admin.show_path(model_name: model_name, id: n.id), title: n.name)
129
+ }.join("<br>").html_safe
130
+ end
131
+ end
132
+ end
133
+
134
+ nested_set({max_depth: 2, scopes: []})
135
+
136
+ if block_given?
137
+ yield self
138
+ end
139
+ }
140
+ end
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,31 @@
1
+ module Enjoy::News
2
+ module Admin
3
+ module Image
4
+ def self.config(nav_label = nil, fields = {})
5
+ if Enjoy::News.config.gallery_support
6
+ if Enjoy::News.mongoid?
7
+ if block_given?
8
+ Enjoy::Gallery::Admin::EmbeddedImage.config(fields) do |config|
9
+ yield config
10
+ end
11
+ else
12
+ Enjoy::Gallery::Admin::EmbeddedImage.config(fields)
13
+ end
14
+
15
+ else
16
+ nav_label ||= I18n.t('enjoy.news')
17
+ if block_given?
18
+ Enjoy::Gallery::Admin::Image.config(nav_label, fields) do |config|
19
+ yield config
20
+ end
21
+ else
22
+ Enjoy::Gallery::Admin::Image.config(nav_label, fields)
23
+ end
24
+ end #if Enjoy::News.mongoid?
25
+ end #if Enjoy::News.config.gallery_support
26
+
27
+ end #def self.config(fields = {})
28
+
29
+ end #module Image
30
+ end #module Admin
31
+ end #module Enjoy::News
@@ -0,0 +1,101 @@
1
+ module Enjoy::News
2
+ module Admin
3
+ module News
4
+ def self.config(fields = {})
5
+ Proc.new {
6
+ navigation_label I18n.t('enjoy.news')
7
+ list do
8
+ scopes [:by_date, :enabled, nil]
9
+ end
10
+
11
+ field :enabled, :toggle do
12
+ searchable false
13
+ end
14
+ field :time do
15
+ searchable false
16
+ sort_reverse true
17
+ end
18
+ field :name do
19
+ searchable true
20
+ end
21
+ if Enjoy::News.config.pages_support
22
+ group :connected_pages do
23
+ active false
24
+ field :connected_pages, :enjoy_connectable
25
+ end
26
+ end
27
+
28
+ if Enjoy::News.config.gallery_support
29
+ group :image do
30
+ active false
31
+ field :image, :jcrop do
32
+ jcrop_options :image_jcrop_options
33
+ end
34
+ field :images
35
+ end
36
+ end
37
+ group :content do
38
+ active false
39
+ field :excerpt, :enjoy_html do
40
+ searchable true
41
+ end
42
+ # field :excerpt_html, :ck_editor
43
+ # field :excerpt_clear, :toggle
44
+ end
45
+ group :URL do
46
+ active false
47
+ field :slugs, :enum do
48
+ searchable true
49
+ enum_method do
50
+ :slugs
51
+ end
52
+ visible do
53
+ bindings[:view].current_user.admin?
54
+ end
55
+ multiple do
56
+ true
57
+ end
58
+ end
59
+ field :text_slug do
60
+ searchable true
61
+ end
62
+ end
63
+
64
+ list do
65
+ sort_by :time
66
+ end
67
+
68
+ edit do
69
+ group :content do
70
+ active false
71
+ field :content, :enjoy_html
72
+ # field :content_html, :ck_editor
73
+ # field :content_clear, :toggle
74
+ end
75
+
76
+ Enjoy::RailsAdminGroupPatch::enjoy_cms_group(self, fields)
77
+
78
+ if Enjoy::News.config.seo_support
79
+ group :seo do
80
+ active false
81
+ field :seo do
82
+ active true
83
+ end
84
+ end
85
+ group :sitemap_data do
86
+ active false
87
+ field :sitemap_data do
88
+ active true
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ if block_given?
95
+ yield self
96
+ end
97
+ }
98
+ end
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,6 @@
1
+ module Enjoy::News
2
+ module Admin
3
+ class << self
4
+ end
5
+ end
6
+ end