effective_posts 2.0.1 → 2.0.2
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.
- checksums.yaml +4 -4
- data/README.md +1 -49
- data/app/helpers/effective_posts_helper.rb +2 -2
- data/app/models/effective/post.rb +2 -2
- data/config/routes.rb +19 -22
- data/lib/effective_posts.rb +0 -1
- data/lib/effective_posts/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8aa5788677bbc314a5bf40d373e1d8fcd3ec888fcff06ceb309dc28b027304db
|
4
|
+
data.tar.gz: bc87d5b89781c026ee5db81ee123aeefbf5de29e8bd65c102e282c362b38ae2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 175315b793aa0e096a29a20b66e568c93812ae804156e4c2bd169fa28ad20084041e0058f238fea7c063f87093d7f2e74330a2a15a10e47712470649ee7546b0
|
7
|
+
data.tar.gz: 2dc2137a2e10ec1c63e0cfbcfb63c92ee8b045568f8acb2ac991b7888eba0b4242ed7f9188f1c76cbd1b67ea4c423ada138798c02c85d47af7448bbf9eb98b07
|
data/README.md
CHANGED
@@ -85,54 +85,7 @@ The per_page for posts may be configured via the `/app/config/initializers/effec
|
|
85
85
|
|
86
86
|
## Authorization
|
87
87
|
|
88
|
-
All authorization checks are handled via the
|
89
|
-
|
90
|
-
It is intended for flow through to CanCan or Pundit, but neither of those gems are required.
|
91
|
-
|
92
|
-
This method is called by all controller actions with the appropriate action and resource
|
93
|
-
|
94
|
-
Action will be one of [:index, :show, :new, :create, :edit, :update, :destroy]
|
95
|
-
|
96
|
-
Resource will the appropriate Effective::Post object or class
|
97
|
-
|
98
|
-
The authorization method is defined in the initializer file:
|
99
|
-
|
100
|
-
```ruby
|
101
|
-
# As a Proc (with CanCan)
|
102
|
-
config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) }
|
103
|
-
```
|
104
|
-
|
105
|
-
```ruby
|
106
|
-
# As a Custom Method
|
107
|
-
config.authorization_method = :my_authorization_method
|
108
|
-
```
|
109
|
-
|
110
|
-
and then in your application_controller.rb:
|
111
|
-
|
112
|
-
```ruby
|
113
|
-
def my_authorization_method(action, resource)
|
114
|
-
current_user.is?(:admin) || EffectivePunditPolicy.new(current_user, resource).send('#{action}?')
|
115
|
-
end
|
116
|
-
```
|
117
|
-
|
118
|
-
or disabled entirely:
|
119
|
-
|
120
|
-
```ruby
|
121
|
-
config.authorization_method = false
|
122
|
-
```
|
123
|
-
|
124
|
-
If the method or proc returns false (user is not authorized) an Effective::AccessDenied exception will be raised
|
125
|
-
|
126
|
-
You can rescue from this exception by adding the following to your application_controller.rb:
|
127
|
-
|
128
|
-
```ruby
|
129
|
-
rescue_from Effective::AccessDenied do |exception|
|
130
|
-
respond_to do |format|
|
131
|
-
format.html { render 'static_pages/access_denied', :status => 403 }
|
132
|
-
format.any { render :text => 'Access Denied', :status => 403 }
|
133
|
-
end
|
134
|
-
end
|
135
|
-
```
|
88
|
+
All authorization checks are handled via the effective_resources gem found in the `config/initializers/effective_resources.rb` file.
|
136
89
|
|
137
90
|
### Permissions
|
138
91
|
|
@@ -155,7 +108,6 @@ There are some obvious additional features that have yet to be implemented:
|
|
155
108
|
- Some kind of helper for displaying a sidebar for the categories
|
156
109
|
- Post archives and date filtering
|
157
110
|
|
158
|
-
|
159
111
|
## License
|
160
112
|
|
161
113
|
MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
|
@@ -61,8 +61,8 @@ module EffectivePostsHelper
|
|
61
61
|
def post_meta(post, date: true, datetime: false, category: true, author: true)
|
62
62
|
[
|
63
63
|
'Published',
|
64
|
-
("on #{post.published_at.strftime('%B %d, %Y')}" if date),
|
65
|
-
("on #{post.published_at.strftime('%B %d, %Y at %l:%M %p')}" if datetime),
|
64
|
+
("on #{post.published_at.strftime('%B %d, %Y')}" if date && post.published_at),
|
65
|
+
("on #{post.published_at.strftime('%B %d, %Y at %l:%M %p')}" if datetime && post.published_at),
|
66
66
|
("to #{link_to_post_category(post.category)}" if category && Array(EffectivePosts.categories).length > 1),
|
67
67
|
("by #{post.user.to_s.presence || 'Unknown'}" if author && EffectivePosts.post_meta_author && post.user.present?)
|
68
68
|
].compact.join(' ').html_safe
|
@@ -47,7 +47,7 @@ module Effective
|
|
47
47
|
validates :title, presence: true, length: { maximum: 255 }
|
48
48
|
validates :description, presence: true, length: { maximum: 150 }
|
49
49
|
validates :category, presence: true
|
50
|
-
validates :published_at, presence: true
|
50
|
+
validates :published_at, presence: true, unless: -> { draft? }
|
51
51
|
|
52
52
|
validates :start_at, presence: true, if: -> { category == 'events' }
|
53
53
|
|
@@ -107,7 +107,7 @@ module Effective
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def send_post_submitted_to_admin!
|
110
|
-
deliver_method = EffectivePosts.mailer[:deliver_method] ||
|
110
|
+
deliver_method = EffectivePosts.mailer[:deliver_method] || EffectiveResources.deliver_method
|
111
111
|
Effective::PostsMailer.post_submitted_to_admin(to_param).send(deliver_method)
|
112
112
|
end
|
113
113
|
|
data/config/routes.rb
CHANGED
@@ -1,38 +1,35 @@
|
|
1
1
|
EffectivePosts::Engine.routes.draw do
|
2
2
|
namespace :admin do
|
3
3
|
resources :posts, except: [:show] do
|
4
|
-
|
5
|
-
post :approve, on: :member
|
6
|
-
end
|
4
|
+
post :approve, on: :member
|
7
5
|
end
|
8
|
-
|
9
|
-
match 'posts/excerpts', to: 'posts#excerpts', via: :get
|
10
6
|
end
|
11
7
|
|
12
8
|
scope module: 'effective' do
|
13
|
-
|
14
|
-
|
9
|
+
# Post Routes
|
10
|
+
resources :posts
|
15
11
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
# Blog Routes
|
13
|
+
match 'blog/category/:category', to: 'posts#index', via: :get, constraints: lambda { |req|
|
14
|
+
EffectivePosts.use_blog_routes && EffectivePosts.categories.include?(req.params['category'].to_sym)
|
15
|
+
}
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
match category, to: 'posts#index', via: :get, defaults: { category: category }
|
25
|
-
match "#{category}/:id", to: 'posts#show', via: :get, defaults: { category: category }
|
26
|
-
end
|
17
|
+
resources :posts, only: [:index, :show], path: 'blog', constraints: lambda { |req|
|
18
|
+
EffectivePosts.use_blog_routes
|
19
|
+
}
|
27
20
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
21
|
+
# Category routes
|
22
|
+
match ':category', to: 'posts#index', via: :get, constraints: lambda { |req|
|
23
|
+
EffectivePosts.use_category_routes && EffectivePosts.categories.include?(req.params['category'].to_sym)
|
24
|
+
}
|
25
|
+
|
26
|
+
match ":category/:id", to: 'posts#show', via: :get, constraints: lambda { |req|
|
27
|
+
EffectivePosts.use_category_routes && EffectivePosts.categories.include?(req.params['category'].to_sym)
|
28
|
+
}
|
32
29
|
end
|
33
30
|
|
34
31
|
end
|
35
32
|
|
36
33
|
Rails.application.routes.draw do
|
37
|
-
mount EffectivePosts::Engine => '/', :
|
34
|
+
mount EffectivePosts::Engine => '/', as: 'effective_posts'
|
38
35
|
end
|
data/lib/effective_posts.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_posts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|