hancock_cms_news 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +48 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/hancock/news.coffee +3 -0
- data/app/assets/javascripts/hancock/news/init.coffee +2 -0
- data/app/assets/stylesheets/hancock/news.sass +3 -0
- data/app/controllers/concerns/hancock/news/decorators/categories.rb +35 -0
- data/app/controllers/concerns/hancock/news/decorators/news_controller.rb +30 -0
- data/app/controllers/hancock/news/categories_controller.rb +7 -0
- data/app/controllers/hancock/news/news_controller.rb +7 -0
- data/app/models/concerns/hancock/news/decorators/category.rb +46 -0
- data/app/models/concerns/hancock/news/decorators/image.rb +46 -0
- data/app/models/concerns/hancock/news/decorators/news.rb +65 -0
- data/app/models/hancock/news/category.rb +11 -0
- data/app/models/hancock/news/image.rb +16 -0
- data/app/models/hancock/news/news.rb +16 -0
- data/app/views/hancock/news/categories/_list.html.slim +10 -0
- data/app/views/hancock/news/categories/index.html.slim +12 -0
- data/app/views/hancock/news/categories/show.html.slim +12 -0
- data/app/views/hancock/news/news/_list.html.slim +13 -0
- data/app/views/hancock/news/news/index.html.slim +12 -0
- data/app/views/hancock/news/news/show.html.slim +17 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/locales/hancock.news.ru.yml +24 -0
- data/hancock_cms_news.gemspec +38 -0
- data/lib/generators/hancock/news/config/config_generator.rb +13 -0
- data/lib/generators/hancock/news/config/templates/hancock_news.erb +39 -0
- data/lib/generators/hancock/news/controllers/all_generator.rb +28 -0
- data/lib/generators/hancock/news/controllers/category_generator.rb +43 -0
- data/lib/generators/hancock/news/controllers/decorators_generator.rb +22 -0
- data/lib/generators/hancock/news/controllers/news_generator.rb +43 -0
- data/lib/generators/hancock/news/controllers/templates/categories_controller.erb +13 -0
- data/lib/generators/hancock/news/controllers/templates/news_controller.erb +16 -0
- data/lib/generators/hancock/news/migrations/migrations_generator.rb +18 -0
- data/lib/generators/hancock/news/migrations/templates/news.rb +96 -0
- data/lib/generators/hancock/news/models/all_generator.rb +33 -0
- data/lib/generators/hancock/news/models/category_generator.rb +39 -0
- data/lib/generators/hancock/news/models/decorators_generator.rb +21 -0
- data/lib/generators/hancock/news/models/image_generator.rb +51 -0
- data/lib/generators/hancock/news/models/news_generator.rb +34 -0
- data/lib/generators/hancock/news/models/templates/category.erb +49 -0
- data/lib/generators/hancock/news/models/templates/image.erb +52 -0
- data/lib/generators/hancock/news/models/templates/news.erb +72 -0
- data/lib/generators/hancock/news/views/for_generator.rb +57 -0
- data/lib/generators/hancock/news/views/views_generator.rb +33 -0
- data/lib/hancock/news/admin.rb +6 -0
- data/lib/hancock/news/admin/category.rb +168 -0
- data/lib/hancock/news/admin/image.rb +37 -0
- data/lib/hancock/news/admin/news.rb +145 -0
- data/lib/hancock/news/configuration.rb +76 -0
- data/lib/hancock/news/controllers/base.rb +64 -0
- data/lib/hancock/news/controllers/categories.rb +66 -0
- data/lib/hancock/news/controllers/news.rb +62 -0
- data/lib/hancock/news/engine.rb +7 -0
- data/lib/hancock/news/models/active_record/category.rb +25 -0
- data/lib/hancock/news/models/active_record/image.rb +16 -0
- data/lib/hancock/news/models/active_record/news.rb +29 -0
- data/lib/hancock/news/models/category.rb +85 -0
- data/lib/hancock/news/models/image.rb +16 -0
- data/lib/hancock/news/models/mongoid/category.rb +31 -0
- data/lib/hancock/news/models/mongoid/image.rb +20 -0
- data/lib/hancock/news/models/mongoid/news.rb +66 -0
- data/lib/hancock/news/models/news.rb +93 -0
- data/lib/hancock/news/routes.rb +56 -0
- data/lib/hancock/news/version.rb +5 -0
- data/lib/hancock_cms_news.rb +45 -0
- data/release.sh +6 -0
- metadata +193 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2f2e4f4f346416a25ffc9a62a2975e6bb8ac3dcb
|
4
|
+
data.tar.gz: 18a3cadccae68712059110b6ee124c60124cc14d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fb96c734e6b28b58866f099a07841eefbd6781b1ab4c58bddd547c9b042e86473e15c2bc2a1e36df79831275503e6c557bf07b891fe9e38a859f383c6feea4ce
|
7
|
+
data.tar.gz: e14060b978f7e86af02bbd6d95b1e01eb6bb535c87c40cf1f3632de591c441f91af82666da9a741105581b294ee0fd119f862001b0da70065b79d824988a5552
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
hancock_news
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
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,48 @@
|
|
1
|
+
# HancockCmsNews
|
2
|
+
|
3
|
+
### Remaded from [EnjoyCMSNews](https://github.com/enjoycreative/enjoy_cms_news)
|
4
|
+
|
5
|
+
News with categories and image galleries for [HancockCMS](https://github.com/red-rocks/hancock_cms).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'hancock_cms_news'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install hancock_cms_news
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Add in config/routes.rb
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
hancock_cms_news_routes
|
29
|
+
```
|
30
|
+
|
31
|
+
Then execute
|
32
|
+
|
33
|
+
$ rails g hancock:news:config
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
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.
|
38
|
+
|
39
|
+
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).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/red-rocks/hancock_cms_news.
|
44
|
+
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Hancock::News::Decorators
|
2
|
+
module Categories
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
# included do
|
6
|
+
#
|
7
|
+
# def after_initialize
|
8
|
+
# end
|
9
|
+
#
|
10
|
+
# def category_class
|
11
|
+
# Hancock::News::Category
|
12
|
+
# end
|
13
|
+
# def news_class
|
14
|
+
# Hancock::News::News
|
15
|
+
# end
|
16
|
+
# def page_title
|
17
|
+
# if @category and @category.class == category_class
|
18
|
+
# @category.page_title
|
19
|
+
# else
|
20
|
+
# super
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# def per_page
|
25
|
+
# Hancock::News.config.categories_per_page
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# def insert_breadcrumbs
|
29
|
+
# true
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Hancock::News::Decorators
|
2
|
+
module NewsController
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
# included do
|
6
|
+
#
|
7
|
+
# def category_class
|
8
|
+
# Hancock::News::Category
|
9
|
+
# end
|
10
|
+
# def news_class
|
11
|
+
# Hancock::News::News
|
12
|
+
# end
|
13
|
+
# def page_title
|
14
|
+
# if @news and @news.class == news_class
|
15
|
+
# @news.page_title
|
16
|
+
# else
|
17
|
+
# super
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
#
|
21
|
+
# def per_page
|
22
|
+
# Hancock::News.config.news_per_page
|
23
|
+
# end
|
24
|
+
# def after_initialize
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Hancock::News::Decorators
|
2
|
+
module Category
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
# # after_save :image_auto_rails_admin_jcrop
|
7
|
+
# def image_auto_rails_admin_jcrop
|
8
|
+
# auto_rails_admin_jcrop(:image) # or nil for cancel autocrop
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# # hancock_cms_attached_file(:image)
|
12
|
+
# def image_styles
|
13
|
+
# Hancock::News.configuration.category_image_styles
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# def image_jcrop_options
|
17
|
+
# {}
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# ############# rails_admin ##############
|
21
|
+
# def self.rails_admin_add_fields
|
22
|
+
# {}
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# def self.rails_admin_add_config(config)
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# def self.admin_can_user_defined_actions
|
29
|
+
# [].freeze
|
30
|
+
# end
|
31
|
+
# def self.admin_cannot_user_defined_actions
|
32
|
+
# [].freeze
|
33
|
+
# end
|
34
|
+
# def self.manager_can_user_defined_actions
|
35
|
+
# [].freeze
|
36
|
+
# end
|
37
|
+
# def self.manager_cannot_user_defined_actions
|
38
|
+
# [].freeze
|
39
|
+
# end
|
40
|
+
# def self.rails_admin_user_defined_visible_actions
|
41
|
+
# [].freeze
|
42
|
+
# end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Hancock::News::Decorators
|
2
|
+
module Image
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
# # after_save :image_auto_rails_admin_jcrop
|
7
|
+
# def image_auto_rails_admin_jcrop
|
8
|
+
# auto_rails_admin_jcrop(:image) # or nil for cancel autocrop
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# # hancock_cms_attached_file(:image)
|
12
|
+
# def image_styles
|
13
|
+
# Hancock::News.configuration.images_image_styles
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# def image_jcrop_options
|
17
|
+
# {}
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# ############# rails_admin ##############
|
21
|
+
# def self.rails_admin_add_fields
|
22
|
+
# {}
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# def self.rails_admin_add_config(config)
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# def self.admin_can_user_defined_actions
|
29
|
+
# [].freeze
|
30
|
+
# end
|
31
|
+
# def self.admin_cannot_user_defined_actions
|
32
|
+
# [].freeze
|
33
|
+
# end
|
34
|
+
# def self.manager_can_user_defined_actions
|
35
|
+
# [].freeze
|
36
|
+
# end
|
37
|
+
# def self.manager_cannot_user_defined_actions
|
38
|
+
# [].freeze
|
39
|
+
# end
|
40
|
+
# def self.rails_admin_user_defined_visible_actions
|
41
|
+
# [].freeze
|
42
|
+
# end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Hancock::News::Decorators
|
2
|
+
module News
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
# # after_save :image_auto_rails_admin_jcrop
|
7
|
+
# def image_auto_rails_admin_jcrop
|
8
|
+
# auto_rails_admin_jcrop(:image) # or nil for cancel autocrop
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# # hancock_cms_attached_file(:image)
|
12
|
+
# def image_styles
|
13
|
+
# Hancock::News.configuration.news_image_styles
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# def image_jcrop_options
|
17
|
+
# {}
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# scope :after_now, -> { where(:time.lt => Time.now) }
|
21
|
+
# scope :by_date, -> { desc(:time) }
|
22
|
+
#
|
23
|
+
# scope :published, -> { where(published: true) }
|
24
|
+
# scope :publicated, -> { all_of({:publicate_time.lt => Time.now}, {published: true}) }
|
25
|
+
# scope :by_publicate_date, -> { desc(:publicate_time) }
|
26
|
+
#
|
27
|
+
# scope :pinned, -> { where(pinned: true) }
|
28
|
+
# scope :pinned_first, -> { desc(:pinned) }
|
29
|
+
#
|
30
|
+
# scope :publicated_or_pinned, -> {
|
31
|
+
# any_of({"$and" => [{:publicate_time.lt => Time.now}, {published: true}]}, {pinned: true})
|
32
|
+
# }
|
33
|
+
#
|
34
|
+
# scope :after_now_or_pinned, -> {
|
35
|
+
# any_of({:time.lt => Time.now}, {pinned: true})
|
36
|
+
# }
|
37
|
+
#
|
38
|
+
#
|
39
|
+
# ############# rails_admin ##############
|
40
|
+
# def self.rails_admin_add_fields
|
41
|
+
# {}
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# def self.rails_admin_add_config(config)
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# def self.admin_can_user_defined_actions
|
48
|
+
# [].freeze
|
49
|
+
# end
|
50
|
+
# def self.admin_cannot_user_defined_actions
|
51
|
+
# [].freeze
|
52
|
+
# end
|
53
|
+
# def self.manager_can_user_defined_actions
|
54
|
+
# [].freeze
|
55
|
+
# end
|
56
|
+
# def self.manager_cannot_user_defined_actions
|
57
|
+
# [].freeze
|
58
|
+
# end
|
59
|
+
# def self.rails_admin_user_defined_visible_actions
|
60
|
+
# [].freeze
|
61
|
+
# end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Hancock::News
|
2
|
+
class Category
|
3
|
+
include Hancock::News::Models::Category
|
4
|
+
|
5
|
+
include Hancock::News::Decorators::Category
|
6
|
+
|
7
|
+
rails_admin(&Hancock::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 Hancock::News.config.gallery_support
|
2
|
+
module Hancock::News
|
3
|
+
_parent_class = Hancock::Gallery::Image if Hancock::News.active_record?
|
4
|
+
_parent_class = Hancock::Gallery::EmbeddedImage if Hancock::News.mongoid?
|
5
|
+
|
6
|
+
class Image < _parent_class
|
7
|
+
include Hancock::News::Models::Image
|
8
|
+
|
9
|
+
include Hancock::News::Decorators::Image
|
10
|
+
|
11
|
+
rails_admin(&Hancock::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 Hancock::News
|
2
|
+
if Hancock::News.active_record?
|
3
|
+
class News < ActiveRecord::Base
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class News
|
8
|
+
include Hancock::News::Models::News
|
9
|
+
|
10
|
+
include Hancock::News::Decorators::News
|
11
|
+
|
12
|
+
rails_admin(&Hancock::News::Admin::News.config(rails_admin_add_fields) { |config|
|
13
|
+
rails_admin_add_config(config)
|
14
|
+
})
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
- _cache_helper = (Hancock::News.config.cache_support ? :hancock_cache : :cache)
|
2
|
+
|
3
|
+
- @news_category.each do |news_category|
|
4
|
+
- send _cache_helper, news do
|
5
|
+
= link_to news_category.name, hancock_news_category_path(news_category), class: "hancock-news-category-title", title: news_category.name
|
6
|
+
.hancock-news-category-excerpt
|
7
|
+
- if Hancock::News.config.insertions_support
|
8
|
+
== news_category.page_excerpt
|
9
|
+
- else
|
10
|
+
== news_category.excerpt
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/ - if Hancock::News.config.breadcrumbs_on_rails_support
|
2
|
+
/ = render_breadcrumbs :separator => ' / '
|
3
|
+
/ = render partial: "blocks/breadcrumbs"
|
4
|
+
/ - _cache_helper = (Hancock::News.config.cache_support ? :hancock_cache : :cache)
|
5
|
+
|
6
|
+
- _partial_path = (Hancock::News.config.seo_support ? 'shared/obj_with_seo' : 'shared/obj')
|
7
|
+
= render _partial_path, obj: (@seo_page || @seo_parent_page)
|
8
|
+
|
9
|
+
.hancock-news-category-index
|
10
|
+
h1= t('hancock.news')
|
11
|
+
= render partial: "hancock/news/category/list"
|
12
|
+
= paginate @news_category
|