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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7fa99747e0baf6c175224b5d3ce645964ac5592137857a6cb28ae6d17687146
4
- data.tar.gz: 277fa3f03c1411d810f0dc09663f4deb6bb2be2c1a890cbf7cc88bc9d6b0bd9e
3
+ metadata.gz: 8aa5788677bbc314a5bf40d373e1d8fcd3ec888fcff06ceb309dc28b027304db
4
+ data.tar.gz: bc87d5b89781c026ee5db81ee123aeefbf5de29e8bd65c102e282c362b38ae2b
5
5
  SHA512:
6
- metadata.gz: efce23b1c3b45e66acbe5d5b055e114a7baa09add399a29a4a76074c2be854b46565deb2dfc3e9bd3f9559b6e6ec8c51a0fcb66f184c278f8edd8fed10578d18
7
- data.tar.gz: 2422db33dc37d6d3f39b3b206c7ea77cf0238a3c9194b44c7b4335058e870e1082449027bab23b71e46177c36e62d697a704359e3fecf7891c7921eef2a000fa
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 config.authorization_method found in the `app/config/initializers/effective_posts.rb` file.
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] || raise('expected an EffectivePosts.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
- if EffectivePosts.submissions_enabled && EffectivePosts.submissions_require_approval
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
- categories = Array(EffectivePosts.categories).map { |cat| cat.to_s unless cat == 'posts'}.compact
14
- onlies = ([:index, :show] unless EffectivePosts.submissions_enabled)
9
+ # Post Routes
10
+ resources :posts
15
11
 
16
- if EffectivePosts.use_blog_routes
17
- categories.each do |category|
18
- match "blog/category/#{category}", to: 'posts#index', via: :get, defaults: { category: category }
19
- end
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
- resources :posts, only: onlies, path: 'blog'
22
- elsif EffectivePosts.use_category_routes
23
- categories.each do |category|
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
- resources :posts, only: onlies
29
- else
30
- resources :posts, only: onlies
31
- end
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 => '/', :as => 'effective_posts'
34
+ mount EffectivePosts::Engine => '/', as: 'effective_posts'
38
35
  end
@@ -1,4 +1,3 @@
1
- require 'effective_datatables'
2
1
  require 'effective_resources'
3
2
  require 'effective_posts/engine'
4
3
  require 'effective_posts/version'
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
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.1
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-02-23 00:00:00.000000000 Z
11
+ date: 2021-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails