effective_posts 2.0.4 → 2.0.5
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/app/assets/config/effective_posts_manifest.js +2 -0
- data/app/controllers/admin/posts_controller.rb +0 -4
- data/app/controllers/effective/posts_controller.rb +3 -7
- data/app/mailers/effective/posts_mailer.rb +9 -26
- data/app/models/effective/post.rb +2 -3
- data/app/views/effective/posts/_form.html.haml +1 -1
- data/app/views/effective/posts/submitted.html.haml +1 -1
- data/app/views/effective/posts_mailer/{post_submitted_to_admin.html.haml → post_submitted.html.haml} +2 -2
- data/config/effective_posts.rb +14 -25
- data/lib/effective_posts/version.rb +1 -1
- data/lib/effective_posts.rb +6 -2
- data/lib/generators/templates/effective_posts_mailer_preview.rb +2 -2
- metadata +4 -4
- data/app/views/layouts/effective_posts_mailer_layout.html.haml +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64936be0ce130f2c9b5d5fe918d217cf01e77648adfd28440e288d24f45da34e
|
4
|
+
data.tar.gz: cf67a0e59a0f7d11b6d6083d83a8d561009f12716ad249fb7a3072dde2f72232
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 519ffb8e746373b2473129b55b9fe471fa824e4ed06b89bfca95f34a3908f029526d7d07654ce444bda2175106ae6c5233e200cf747129b086951070e322a94d
|
7
|
+
data.tar.gz: 271fc10da03adfe19b837b8bd0c72e5e8ccc074ecce114a098cde2979411ea0149b1583c999c440d4c303679df6229a3abd3f1dec840d526dab0465fd19ffcae
|
@@ -5,10 +5,6 @@ module Admin
|
|
5
5
|
|
6
6
|
include Effective::CrudController
|
7
7
|
|
8
|
-
if (config = EffectivePosts.layout)
|
9
|
-
layout(config.kind_of?(Hash) ? config[:admin] : config)
|
10
|
-
end
|
11
|
-
|
12
8
|
submit :save, 'Save'
|
13
9
|
submit :save, 'Save and Add New', redirect: :new
|
14
10
|
submit :save, 'Save and View', redirect: -> { effective_posts.post_path(resource) }
|
@@ -7,10 +7,6 @@ module Effective
|
|
7
7
|
|
8
8
|
include Effective::CrudController
|
9
9
|
|
10
|
-
if (config = EffectivePosts.layout)
|
11
|
-
layout(config.kind_of?(Hash) ? (config[:application] || config[:posts]) : config)
|
12
|
-
end
|
13
|
-
|
14
10
|
def index
|
15
11
|
@posts ||= Effective::Post.posts(
|
16
12
|
user: current_user,
|
@@ -79,7 +75,7 @@ module Effective
|
|
79
75
|
flash.now[:success] = 'Successfully submitted post'
|
80
76
|
|
81
77
|
if EffectivePosts.submissions_require_approval
|
82
|
-
@post.
|
78
|
+
@post.send_post_submitted!
|
83
79
|
end
|
84
80
|
|
85
81
|
render :submitted
|
@@ -104,12 +100,12 @@ module Effective
|
|
104
100
|
|
105
101
|
EffectiveResources.authorize!(self, :update, @post)
|
106
102
|
|
107
|
-
if @post.
|
103
|
+
if @post.update(post_params)
|
108
104
|
@page_title ||= 'Post Submitted'
|
109
105
|
flash.now[:success] = 'Successfully re-submitted post'
|
110
106
|
|
111
107
|
if EffectivePosts.submissions_require_approval && draft_was != true
|
112
|
-
@post.
|
108
|
+
@post.send_post_submitted!
|
113
109
|
end
|
114
110
|
|
115
111
|
render :submitted
|
@@ -1,35 +1,18 @@
|
|
1
1
|
module Effective
|
2
|
-
class PostsMailer <
|
3
|
-
|
4
|
-
|
5
|
-
layout EffectivePosts.mailer[:layout].presence || 'effective_posts_mailer_layout'
|
2
|
+
class PostsMailer < EffectivePosts.parent_mailer_class
|
3
|
+
include EffectiveMailer
|
6
4
|
|
7
|
-
|
8
|
-
@post = (post_param.kind_of?(Effective::Post) ? post_param : Effective::Post.find(post_param))
|
9
|
-
|
10
|
-
mail(
|
11
|
-
to: EffectivePosts.mailer[:admin_email],
|
12
|
-
from: EffectivePosts.mailer[:default_from],
|
13
|
-
subject: subject_for_post_submitted_to_admin(@post),
|
14
|
-
tenant: (Tenant.current if defined?(Tenant))
|
15
|
-
)
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
5
|
+
helper EffectivePostsHelper
|
19
6
|
|
20
|
-
def
|
21
|
-
|
7
|
+
def post_submitted(resource, opts = {})
|
8
|
+
raise('expected an Effective::Post') unless resource.kind_of?(Effective::Post)
|
22
9
|
|
23
|
-
|
24
|
-
|
25
|
-
|
10
|
+
@post = resource
|
11
|
+
subject = subject_for(__method__, 'Post Submitted', resource, opts)
|
12
|
+
headers = headers_for(resource, opts)
|
26
13
|
|
27
|
-
|
14
|
+
mail(to: mailer_admin, subject: subject, **headers)
|
28
15
|
end
|
29
16
|
|
30
|
-
def prefix_subject(text)
|
31
|
-
prefix = (EffectivePosts.mailer[:subject_prefix].to_s rescue '')
|
32
|
-
prefix.present? ? (prefix.chomp(' ') + ' ' + text) : text
|
33
|
-
end
|
34
17
|
end
|
35
18
|
end
|
@@ -106,9 +106,8 @@ module Effective
|
|
106
106
|
(regions.to_a.sum { |region| (region.content || '').scan(/\w+/).size } / reading_speed).seconds
|
107
107
|
end
|
108
108
|
|
109
|
-
def
|
110
|
-
|
111
|
-
Effective::PostsMailer.post_submitted_to_admin(to_param).send(deliver_method)
|
109
|
+
def send_post_submitted!
|
110
|
+
EffectivePosts.send_email(:post_submitted, self)
|
112
111
|
end
|
113
112
|
|
114
113
|
# Returns a duplicated post object, or throws an exception
|
@@ -8,7 +8,7 @@
|
|
8
8
|
- if Array(EffectivePosts.categories).length > 1
|
9
9
|
= f.select :category, EffectivePosts.categories
|
10
10
|
- else
|
11
|
-
= f.hidden_field :category, (EffectivePosts.categories.first || 'posts')
|
11
|
+
= f.hidden_field :category, value: (EffectivePosts.categories.first || 'posts')
|
12
12
|
|
13
13
|
- if EffectivePosts.use_active_storage
|
14
14
|
= f.file_field :image, hint: 'An image for your post'
|
data/app/views/effective/posts_mailer/{post_submitted_to_admin.html.haml → post_submitted.html.haml}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
%p A new post has been submitted and needs your approval before it may be displayed on the website:
|
2
2
|
|
3
|
-
%p= link_to 'Approve Post', effective_posts.
|
3
|
+
%p= link_to 'Approve Post', effective_posts.approve_admin_post_url(@post)
|
4
4
|
|
5
5
|
%hr
|
6
6
|
|
@@ -19,4 +19,4 @@
|
|
19
19
|
|
20
20
|
%hr
|
21
21
|
|
22
|
-
%p= link_to 'Approve Post', effective_posts.
|
22
|
+
%p= link_to 'Approve Post', effective_posts.approve_admin_post_url(@post)
|
data/config/effective_posts.rb
CHANGED
@@ -3,7 +3,7 @@ EffectivePosts.setup do |config|
|
|
3
3
|
|
4
4
|
# Every post must belong to one or more category.
|
5
5
|
# Don't use the category :posts
|
6
|
-
config.categories = [:news
|
6
|
+
config.categories = [:news]
|
7
7
|
|
8
8
|
# Create top level routes for each category
|
9
9
|
# Should each of the above categories have a top level route created for it
|
@@ -49,31 +49,20 @@ EffectivePosts.setup do |config|
|
|
49
49
|
config.submissions_require_approval = true
|
50
50
|
|
51
51
|
# The Thank you message when they submit a post
|
52
|
-
config.submissions_note = "
|
52
|
+
config.submissions_note = "Post submitted! A confirmation email has been sent to the website owner. When approved, your submission will appear on the website."
|
53
53
|
|
54
54
|
# Mailer Settings
|
55
|
-
#
|
56
|
-
# For all the emails, the same :subject_prefix will be prefixed. Leave as nil / empty string if you don't want any prefix
|
55
|
+
# Please see config/initializers/effective_resources.rb for default effective_* gem mailer settings
|
57
56
|
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
63
|
-
|
64
|
-
#
|
65
|
-
#
|
66
|
-
|
67
|
-
config.
|
68
|
-
|
69
|
-
subject_for_post_submitted_to_admin: '',
|
70
|
-
|
71
|
-
layout: 'effective_posts_mailer_layout',
|
72
|
-
|
73
|
-
default_from: 'info@example.com',
|
74
|
-
admin_email: 'admin@example.com',
|
75
|
-
|
76
|
-
deliver_method: :deliver_now
|
77
|
-
}
|
78
|
-
|
57
|
+
# Configure the class responsible to send e-mails.
|
58
|
+
# config.mailer = 'Effective::PostsMailer'
|
59
|
+
#
|
60
|
+
# Override effective_resource mailer defaults
|
61
|
+
#
|
62
|
+
# config.parent_mailer = nil # The parent class responsible for sending emails
|
63
|
+
# config.deliver_method = nil # The deliver method, deliver_later or deliver_now
|
64
|
+
# config.mailer_layout = nil # Default mailer layout
|
65
|
+
# config.mailer_sender = nil # Default From value
|
66
|
+
# config.mailer_admin = nil # Default To value for Admin correspondence
|
67
|
+
# config.mailer_subject = nil # Proc.new method used to customize Subject
|
79
68
|
end
|
data/lib/effective_posts.rb
CHANGED
@@ -7,17 +7,21 @@ module EffectivePosts
|
|
7
7
|
def self.config_keys
|
8
8
|
[
|
9
9
|
:posts_table_name, :layout, :categories,
|
10
|
+
:mailer, :parent_mailer, :deliver_method, :mailer_layout, :mailer_sender, :mailer_admin, :mailer_subject,
|
10
11
|
:use_category_routes, :use_blog_routes,
|
11
12
|
:use_effective_roles, :use_active_storage,
|
12
13
|
:per_page, :post_meta_author,
|
13
14
|
:submissions_enabled, :submissions_require_current_user,
|
14
|
-
:submissions_require_approval, :submissions_note
|
15
|
-
:mailer
|
15
|
+
:submissions_require_approval, :submissions_note
|
16
16
|
]
|
17
17
|
end
|
18
18
|
|
19
19
|
include EffectiveGem
|
20
20
|
|
21
|
+
def self.mailer_class
|
22
|
+
mailer&.constantize || Effective::PostsMailer
|
23
|
+
end
|
24
|
+
|
21
25
|
def self.permitted_params
|
22
26
|
@permitted_params ||= [
|
23
27
|
:title, :excerpt, :description, :draft, :category, :slug, :published_at, :body, :tags, :extra,
|
@@ -3,8 +3,8 @@
|
|
3
3
|
# to see a preview of the following 3 emails:
|
4
4
|
|
5
5
|
class EffectivePostsMailerPreview < ActionMailer::Preview
|
6
|
-
def
|
7
|
-
|
6
|
+
def post_submitted
|
7
|
+
EffectivePosts.mailer_class.post_submitted(build_preview_post)
|
8
8
|
end
|
9
9
|
|
10
10
|
protected
|
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.5
|
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: 2022-
|
11
|
+
date: 2022-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -90,6 +90,7 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- MIT-LICENSE
|
92
92
|
- README.md
|
93
|
+
- app/assets/config/effective_posts_manifest.js
|
93
94
|
- app/assets/javascripts/effective_posts.js
|
94
95
|
- app/assets/javascripts/effective_posts/additional_fields.js.coffee
|
95
96
|
- app/assets/stylesheets/effective_posts.scss
|
@@ -118,8 +119,7 @@ files:
|
|
118
119
|
- app/views/effective/posts/new.html.haml
|
119
120
|
- app/views/effective/posts/show.html.haml
|
120
121
|
- app/views/effective/posts/submitted.html.haml
|
121
|
-
- app/views/effective/posts_mailer/
|
122
|
-
- app/views/layouts/effective_posts_mailer_layout.html.haml
|
122
|
+
- app/views/effective/posts_mailer/post_submitted.html.haml
|
123
123
|
- config/effective_posts.rb
|
124
124
|
- config/routes.rb
|
125
125
|
- db/migrate/01_create_effective_posts.rb.erb
|