effective_posts 1.1.9 → 2.0.1

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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +4 -9
  4. data/app/controllers/admin/posts_controller.rb +10 -125
  5. data/app/controllers/effective/posts_controller.rb +20 -15
  6. data/app/datatables/effective_posts_datatable.rb +3 -1
  7. data/app/helpers/effective_posts_helper.rb +8 -27
  8. data/app/mailers/effective/posts_mailer.rb +2 -1
  9. data/app/models/effective/post.rb +45 -60
  10. data/app/views/admin/posts/_form.html.haml +8 -11
  11. data/app/views/admin/posts/excerpts.html.haml +2 -2
  12. data/app/views/effective/posts/_form.html.haml +2 -3
  13. data/app/views/effective/posts/_post.html.haml +1 -1
  14. data/app/views/effective/posts/_recent_posts.html.haml +1 -4
  15. data/app/views/effective/posts/_sidebar.html.haml +1 -2
  16. data/app/views/effective/posts/show.html.haml +1 -2
  17. data/app/views/effective/posts/submitted.html.haml +1 -1
  18. data/config/effective_posts.rb +2 -37
  19. data/config/routes.rb +7 -10
  20. data/db/migrate/01_create_effective_posts.rb.erb +1 -2
  21. data/lib/effective_posts.rb +14 -49
  22. data/lib/effective_posts/engine.rb +1 -1
  23. data/lib/effective_posts/version.rb +1 -1
  24. metadata +9 -60
  25. data/app/assets/javascripts/effective/snippets/read_more_divider.js.coffee +0 -22
  26. data/app/helpers/effective_truncate_html_helper.rb +0 -73
  27. data/app/models/effective/access_denied.rb +0 -17
  28. data/app/models/effective/datatables/posts.rb +0 -40
  29. data/app/models/effective/snippets/read_more_divider.rb +0 -11
  30. data/app/views/admin/posts/_actions.html.haml +0 -13
  31. data/app/views/admin/posts/edit.html.haml +0 -3
  32. data/app/views/admin/posts/new.html.haml +0 -3
  33. data/app/views/effective/snippets/_read_more_divider.html.haml +0 -9
@@ -3,7 +3,13 @@
3
3
 
4
4
  - if f.object.persisted? || f.object.errors.include?(:slug)
5
5
  - current_url = effective_posts.post_path(f.object)
6
- = f.text_field :slug, hint: "The slug controls this post's internet address. Be careful, changing the slug will break links that other websites may have to the old address.<br>#{('This post is currently reachable via ' + link_to(current_url.gsub(f.object.slug, '<strong>' + f.object.slug + '</strong>').html_safe, current_url)) if current_url && f.object.slug.present? }".html_safe
6
+
7
+ = f.text_field :slug, required: f.object.persisted?,
8
+ hint: "The slug controls this post's internet address. Be careful, changing the slug will break links that other websites may have to the old address.<br>#{('This post is currently reachable via ' + link_to(current_url.gsub(f.object.slug, '<strong>' + f.object.slug + '</strong>').html_safe, current_url)) if current_url && f.object.slug.present? }".html_safe
9
+
10
+ = f.rich_text_area :excerpt, hint: 'Will be used for the post excerpt on index pages.'
11
+
12
+ = f.text_field :description, hint: 'The content of the post meta tags.', maxlength: 150
7
13
 
8
14
  - if Array(EffectivePosts.categories).length > 1
9
15
  = f.select :category, EffectivePosts.categories
@@ -13,8 +19,7 @@
13
19
  - if EffectivePosts.use_active_storage
14
20
  = f.file_field :image, hint: 'An image for your post'
15
21
 
16
- = f.ck_editor :excerpt, hint: 'Will be used for the post excerpt on index pages.'
17
- = f.text_field :description, hint: 'The content of the post meta tags.', maxlength: 150
22
+ = f.rich_text_area :body, hint: 'The main body of your post'
18
23
 
19
24
  = render partial: '/effective/posts/additional_fields', locals: { post: post, form: f, f: f }
20
25
 
@@ -22,19 +27,11 @@
22
27
 
23
28
  = f.check_box :draft, hint: 'Save this post as a draft. It will not be accessible on the website.'
24
29
 
25
- - unless EffectivePosts.use_fullscreen_editor
26
- = f.ck_editor :body, hint: 'The content of your post.'
27
-
28
30
  - if defined?(EffectiveRoles) && f.object.respond_to?(:roles) && EffectivePosts.use_effective_roles
29
31
  = render partial: '/admin/posts/roles', locals: { post: post, form: f, f: f }
30
32
 
31
33
  = f.submit do
32
34
  = f.save 'Save'
33
-
34
- - if EffectivePosts.use_fullscreen_editor
35
- = f.save 'Save and Edit Content', class: 'btn btn-secondary'
36
-
37
35
  = f.save 'Save and View', class: 'btn btn-secondary'
38
-
39
36
  - if f.object.persisted?
40
37
  = f.save 'Duplicate', class: 'btn btn-info'
@@ -6,10 +6,10 @@
6
6
  %h2.post-title= link_to post, effective_post_path(post)
7
7
  .row
8
8
  .col-sm-6
9
- %pre= effective_region(post, :body, editable: false)
9
+ %pre= post.body
10
10
 
11
11
  .col-sm-6
12
- %pre= post_excerpt(post)
12
+ %pre= post.excerpt
13
13
 
14
14
  .row
15
15
  .col-sm-12
@@ -13,7 +13,7 @@
13
13
  - if EffectivePosts.use_active_storage
14
14
  = f.file_field :image, hint: 'An image for your post'
15
15
 
16
- = f.ck_editor :excerpt, hint: 'Will be used for the post excerpt on index pages.'
16
+ = f.rich_text_area :excerpt, hint: 'Will be used for the post excerpt on index pages.'
17
17
  = f.text_field :description, hint: 'The content of the post meta tags.', maxlength: 150
18
18
 
19
19
  = render partial: '/effective/posts/additional_fields', locals: { post: post, form: f, f: f }
@@ -22,7 +22,6 @@
22
22
 
23
23
  = f.check_box :draft, hint: 'Save this post as a draft. It will not be accessible on the website.'
24
24
 
25
- - unless EffectivePosts.use_fullscreen_editor
26
- = f.ck_editor :body, hint: 'The content of your post.'
25
+ = f.rich_text_area :body, hint: 'The main body of your post'
27
26
 
28
27
  = f.submit 'Save'
@@ -6,4 +6,4 @@
6
6
  = admin_post_status_badge(post)
7
7
 
8
8
  .post-content.post-excerpt
9
- = post_excerpt(post)
9
+ = post.excerpt
@@ -1,5 +1,2 @@
1
1
  .effective-posts-recent-posts
2
- - posts.each do |post|
3
- .effective-post
4
- %p= link_to post, effective_post_path(post)
5
-
2
+ = render(posts)
@@ -18,11 +18,10 @@
18
18
  - if posts.length == 0
19
19
  %li= link_to 'None', effective_posts.posts_path, class: 'disabled'
20
20
 
21
- - if EffectivePosts.authorized?(self, :admin, :effective_posts)
21
+ - if EffectiveResources.authorized?(self, :admin, :effective_posts)
22
22
  %h4.dashboard-title Admin
23
23
  %ul.list-unstyled
24
24
  %li= link_to 'All Posts', effective_posts.admin_posts_path
25
25
 
26
26
  - if @post.present?
27
- %li= link_to 'Edit Post Content', effective_regions.edit_path(effective_posts.post_path(@post, exit: effective_posts.post_path(@post)))
28
27
  %li= link_to 'Edit Post Settings', effective_posts.edit_admin_post_path(@post)
@@ -9,5 +9,4 @@
9
9
  = render 'effective/posts/event', post: @post
10
10
 
11
11
  .post-body.post-content
12
- = effective_region @post, :body do
13
- %p Default content
12
+ = @post.body
@@ -2,7 +2,7 @@
2
2
 
3
3
  %p= EffectivePosts.submissions_note
4
4
 
5
- - if EffectivePosts.authorized?(controller, :edit, @post)
5
+ - if EffectiveResources.authorized?(controller, :edit, @post)
6
6
  %p= link_to 'Edit Post', effective_posts.edit_post_path(@post), class: 'btn btn-primary btn-edit-post'
7
7
 
8
8
  %hr
@@ -29,46 +29,12 @@ EffectivePosts.setup do |config|
29
29
  # The author is the user that created the Effective::Post object
30
30
  config.post_meta_author = true
31
31
 
32
- # Authorization Method
33
- #
34
- # This method is called by all controller actions with the appropriate action and resource
35
- # If the method returns false, an Effective::AccessDenied Error will be raised (see README.md for complete info)
36
- #
37
- # Use via Proc (and with CanCan):
38
- # config.authorization_method = Proc.new { |controller, action, resource| can?(action, resource) }
39
- #
40
- # Use via custom method:
41
- # config.authorization_method = :my_authorization_method
42
- #
43
- # And then in your application_controller.rb:
44
- #
45
- # def my_authorization_method(action, resource)
46
- # current_user.is?(:admin)
47
- # end
48
- #
49
- # Or disable the check completely:
50
- # config.authorization_method = false
51
- config.authorization_method = Proc.new do |controller, action, resource|
52
- authorize!(action, resource)
53
- resource.respond_to?(:roles_permit?) ? resource.roles_permit?(current_user) : true
54
- end
55
-
56
32
  # Layout Settings
57
- # Configure the Layout per controller, or all at once
58
- config.layout = {
59
- posts: 'application',
60
- admin: 'admin'
61
- }
62
-
63
- # Add additional permitted params
64
- # config.permitted_params += [:additional_field]
33
+ # config.layout = { application: 'application', admin: 'admin' }
65
34
 
66
35
  # Display the effective roles 'choose roles' input when an admin creates a new post
67
36
  config.use_effective_roles = false
68
37
 
69
- # Hides the Save and Edit Content links from admin. They can just use the textarea input.
70
- config.use_fullscreen_editor = true
71
-
72
38
  # Display a file upload field when the admin creates a new post to collect a post.image
73
39
  config.use_active_storage = true
74
40
 
@@ -107,8 +73,7 @@ EffectivePosts.setup do |config|
107
73
  default_from: 'info@example.com',
108
74
  admin_email: 'admin@example.com',
109
75
 
110
- deliver_method: nil, # :deliver (rails < 4.2), :deliver_now (rails >= 4.2) or :deliver_later
111
- delayed_job_deliver: false
76
+ deliver_method: :deliver_now
112
77
  }
113
78
 
114
79
  end
data/config/routes.rb CHANGED
@@ -1,15 +1,15 @@
1
1
  EffectivePosts::Engine.routes.draw do
2
2
  namespace :admin do
3
- resources :posts, except: [:show]
4
-
5
- if EffectivePosts.submissions_enabled && EffectivePosts.submissions_require_approval
6
- match 'posts/:id/approve', to: 'posts#approve', via: :get, as: :approve_post
3
+ resources :posts, except: [:show] do
4
+ if EffectivePosts.submissions_enabled && EffectivePosts.submissions_require_approval
5
+ post :approve, on: :member
6
+ end
7
7
  end
8
8
 
9
9
  match 'posts/excerpts', to: 'posts#excerpts', via: :get
10
10
  end
11
11
 
12
- scope :module => 'effective' do
12
+ scope module: 'effective' do
13
13
  categories = Array(EffectivePosts.categories).map { |cat| cat.to_s unless cat == 'posts'}.compact
14
14
  onlies = ([:index, :show] unless EffectivePosts.submissions_enabled)
15
15
 
@@ -33,9 +33,6 @@ EffectivePosts::Engine.routes.draw do
33
33
 
34
34
  end
35
35
 
36
- # Automatically mount the engine as an append
37
- Rails.application.routes.append do
38
- unless Rails.application.routes.routes.find { |r| r.name == 'effective_posts' }
39
- mount EffectivePosts::Engine => '/', :as => 'effective_posts'
40
- end
36
+ Rails.application.routes.draw do
37
+ mount EffectivePosts::Engine => '/', :as => 'effective_posts'
41
38
  end
@@ -2,10 +2,9 @@ class CreateEffectivePosts < ActiveRecord::Migration[4.2]
2
2
  def self.up
3
3
  create_table <%= @posts_table_name %> do |t|
4
4
  t.integer :user_id
5
+ t.string :user_type
5
6
 
6
7
  t.string :title
7
- t.text :excerpt
8
-
9
8
  t.string :description
10
9
 
11
10
  t.string :category
@@ -1,64 +1,29 @@
1
- require 'nokogiri'
2
1
  require 'effective_datatables'
3
- require 'effective_regions'
2
+ require 'effective_resources'
4
3
  require 'effective_posts/engine'
5
4
  require 'effective_posts/version'
6
5
 
7
6
  module EffectivePosts
8
- mattr_accessor :posts_table_name
9
7
 
10
- mattr_accessor :authorization_method
11
- mattr_accessor :permitted_params
12
-
13
- mattr_accessor :layout
14
- mattr_accessor :simple_form_options
15
- mattr_accessor :admin_simple_form_options
16
-
17
- mattr_accessor :categories
18
- mattr_accessor :use_category_routes
19
- mattr_accessor :use_blog_routes
20
-
21
- mattr_accessor :use_effective_roles
22
- mattr_accessor :use_fullscreen_editor
23
- mattr_accessor :use_active_storage
24
-
25
- mattr_accessor :per_page
26
- mattr_accessor :post_meta_author
27
-
28
- mattr_accessor :submissions_enabled
29
- mattr_accessor :submissions_require_current_user
30
- mattr_accessor :submissions_require_approval
31
- mattr_accessor :submissions_note
32
-
33
- # These are hashes of configs
34
- mattr_accessor :mailer
35
-
36
- def self.setup
37
- yield self
38
- end
39
-
40
- def self.authorized?(controller, action, resource)
41
- @_exceptions ||= [Effective::AccessDenied, (CanCan::AccessDenied if defined?(CanCan)), (Pundit::NotAuthorizedError if defined?(Pundit))].compact
42
-
43
- return !!authorization_method unless authorization_method.respond_to?(:call)
44
- controller = controller.controller if controller.respond_to?(:controller)
45
-
46
- begin
47
- !!(controller || self).instance_exec((controller || self), action, resource, &authorization_method)
48
- rescue *@_exceptions
49
- false
50
- end
8
+ def self.config_keys
9
+ [
10
+ :posts_table_name, :layout, :categories,
11
+ :use_category_routes, :use_blog_routes,
12
+ :use_effective_roles, :use_active_storage,
13
+ :per_page, :post_meta_author,
14
+ :submissions_enabled, :submissions_require_current_user,
15
+ :submissions_require_approval, :submissions_note,
16
+ :mailer
17
+ ]
51
18
  end
52
19
 
53
- def self.authorize!(controller, action, resource)
54
- raise Effective::AccessDenied.new('Access Denied', action, resource) unless authorized?(controller, action, resource)
55
- end
20
+ include EffectiveGem
56
21
 
57
22
  def self.permitted_params
58
- [
23
+ @permitted_params ||= [
59
24
  :title, :excerpt, :description, :draft, :category, :slug, :published_at, :body, :tags, :extra,
60
25
  :image, :start_at, :end_at, :location, :website_name, :website_href, roles: []
61
- ].compact
26
+ ]
62
27
  end
63
28
 
64
29
  end
@@ -10,7 +10,7 @@ module EffectivePosts
10
10
  end
11
11
 
12
12
  # Set up our default configuration options.
13
- initializer "effective_posts.defaults", :before => :load_config_initializers do |app|
13
+ initializer "effective_posts.defaults", before: :load_config_initializers do |app|
14
14
  # Set up our defaults, as per our initializer template
15
15
  eval File.read("#{config.root}/config/effective_posts.rb")
16
16
  end
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = '1.1.9'.freeze
2
+ VERSION = '2.0.1'.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: 1.1.9
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-31 00:00:00.000000000 Z
11
+ date: 2021-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.0
19
+ version: '6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.0
26
+ version: '6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sass
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: nokogiri
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: effective_bootstrap
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -67,7 +53,7 @@ dependencies:
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
- name: effective_ckeditor
56
+ name: effective_resources
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
@@ -82,34 +68,6 @@ dependencies:
82
68
  version: '0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: effective_datatables
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: 4.0.0
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: 4.0.0
97
- - !ruby/object:Gem::Dependency
98
- name: effective_regions
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :runtime
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: effective_resources
113
71
  requirement: !ruby/object:Gem::Requirement
114
72
  requirements:
115
73
  - - ">="
@@ -132,7 +90,6 @@ extra_rdoc_files: []
132
90
  files:
133
91
  - MIT-LICENSE
134
92
  - README.md
135
- - app/assets/javascripts/effective/snippets/read_more_divider.js.coffee
136
93
  - app/assets/javascripts/effective_posts.js
137
94
  - app/assets/javascripts/effective_posts/additional_fields.js.coffee
138
95
  - app/assets/stylesheets/effective_posts.scss
@@ -140,19 +97,12 @@ files:
140
97
  - app/controllers/effective/posts_controller.rb
141
98
  - app/datatables/effective_posts_datatable.rb
142
99
  - app/helpers/effective_posts_helper.rb
143
- - app/helpers/effective_truncate_html_helper.rb
144
100
  - app/mailers/effective/posts_mailer.rb
145
- - app/models/effective/access_denied.rb
146
- - app/models/effective/datatables/posts.rb
147
101
  - app/models/effective/post.rb
148
- - app/models/effective/snippets/read_more_divider.rb
149
- - app/views/admin/posts/_actions.html.haml
150
102
  - app/views/admin/posts/_form.html.haml
151
103
  - app/views/admin/posts/_roles.html.haml
152
- - app/views/admin/posts/edit.html.haml
153
104
  - app/views/admin/posts/excerpts.html.haml
154
105
  - app/views/admin/posts/index.html.haml
155
- - app/views/admin/posts/new.html.haml
156
106
  - app/views/effective/posts/_additional_fields.html.haml
157
107
  - app/views/effective/posts/_categories.html.haml
158
108
  - app/views/effective/posts/_event.html.haml
@@ -169,7 +119,6 @@ files:
169
119
  - app/views/effective/posts/show.html.haml
170
120
  - app/views/effective/posts/submitted.html.haml
171
121
  - app/views/effective/posts_mailer/post_submitted_to_admin.html.haml
172
- - app/views/effective/snippets/_read_more_divider.html.haml
173
122
  - app/views/layouts/effective_posts_mailer_layout.html.haml
174
123
  - config/effective_posts.rb
175
124
  - config/routes.rb
@@ -183,7 +132,7 @@ homepage: https://github.com/code-and-effect/effective_posts
183
132
  licenses:
184
133
  - MIT
185
134
  metadata: {}
186
- post_install_message:
135
+ post_install_message:
187
136
  rdoc_options: []
188
137
  require_paths:
189
138
  - lib
@@ -198,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
147
  - !ruby/object:Gem::Version
199
148
  version: '0'
200
149
  requirements: []
201
- rubygems_version: 3.0.3
202
- signing_key:
150
+ rubygems_version: 3.1.2
151
+ signing_key:
203
152
  specification_version: 4
204
153
  summary: A blog implementation with WYSIWYG content editing, post scheduling, pagination
205
154
  and optional top level routes for each post category.