effective_posts 1.0.3 → 1.0.4
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/controllers/effective/posts_controller.rb +3 -3
- data/app/helpers/effective_posts_helper.rb +15 -13
- data/app/views/admin/posts/_form.html.haml +4 -2
- data/app/views/effective/posts/_form.html.haml +4 -1
- data/db/migrate/01_create_effective_posts.rb.erb +2 -0
- data/lib/effective_posts/version.rb +1 -1
- data/lib/effective_posts.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f796cf858658cf9c8f19f2b45339e7e7fbfa64c2
|
4
|
+
data.tar.gz: 672b79eb37607da4c40e2d51f24da5944d6ddd92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a979a1ca93aa4d29bbab5b789493d1cf1ba0f298cb31abd44fb06f4d00aa7bbdfb4817e5f38ead8181c19e4783c5352365d009fbfa12183b575adf450a530163
|
7
|
+
data.tar.gz: 9226681df68199551ae11afffae3103f7ce0e271bf2f3e84a677a52c38826f4731c0b525f28a28c5c68c9a9df2adb2e02b905e9a1ed6e49204748b205233d1e9
|
@@ -25,7 +25,7 @@ module Effective
|
|
25
25
|
|
26
26
|
EffectivePosts.authorize!(self, :index, Effective::Post)
|
27
27
|
|
28
|
-
@page_title
|
28
|
+
@page_title ||= (params[:category].present? ? params[:category] : 'Blog').titleize
|
29
29
|
end
|
30
30
|
|
31
31
|
def show
|
@@ -48,8 +48,8 @@ module Effective
|
|
48
48
|
].compact.join(' ')
|
49
49
|
end
|
50
50
|
|
51
|
-
@page_title
|
52
|
-
@meta_description
|
51
|
+
@page_title ||= @post.title
|
52
|
+
@meta_description ||= @post.description
|
53
53
|
end
|
54
54
|
|
55
55
|
# Public user submit a post functionality
|
@@ -77,20 +77,24 @@ module EffectivePostsHelper
|
|
77
77
|
# :omission => '...' passed to the final text node's truncate
|
78
78
|
# :length => 200 to set the max inner_text length of the content
|
79
79
|
# All other options are passed to the link_to 'Read more'
|
80
|
-
def post_excerpt(post, read_more_link: true, label: 'Continue reading', omission: '...', length:
|
81
|
-
content = effective_region(post, :body, :
|
82
|
-
description = content_tag(:p, post.description)
|
83
|
-
|
80
|
+
def post_excerpt(post, read_more_link: true, label: 'Continue reading', omission: '...', length: nil)
|
81
|
+
content = effective_region(post, :body, editable: false) { '<p>Default content</p>'.html_safe }
|
84
82
|
divider = content.index(Effective::Snippets::ReadMoreDivider::TOKEN)
|
83
|
+
excerpt = post.excerpt.to_s
|
84
|
+
|
85
85
|
read_more = (read_more_link && label.present?) ? readmore_link(post, label: label) : ''
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
87
|
+
html = (
|
88
|
+
if divider.present?
|
89
|
+
truncate_html(content, Effective::Snippets::ReadMoreDivider::TOKEN, '')
|
90
|
+
elsif length.present?
|
91
|
+
truncate_html(excerpt, length, omission)
|
92
|
+
else
|
93
|
+
excerpt
|
94
|
+
end
|
95
|
+
).html_safe
|
96
|
+
|
97
|
+
(html + read_more).html_safe
|
94
98
|
end
|
95
99
|
|
96
100
|
def read_more_link(post, options = {})
|
@@ -110,8 +114,6 @@ module EffectivePostsHelper
|
|
110
114
|
render(partial: '/effective/posts/categories', locals: { categories: (reverse ? post_categories.reverse : post_categories) })
|
111
115
|
end
|
112
116
|
|
113
|
-
|
114
|
-
|
115
117
|
### Recent Posts
|
116
118
|
|
117
119
|
def recent_posts(user: current_user, category: nil, limit: EffectivePosts.per_page)
|
@@ -1,12 +1,14 @@
|
|
1
1
|
= effective_form_with(model: post, url: post.persisted? ? effective_posts.admin_post_path(post.id) : effective_posts.admin_posts_path) do |f|
|
2
2
|
= f.text_field :title, hint: 'The title of your post.'
|
3
|
-
= f.text_field :description, hint: 'Will be used for the post excerpt and meta tags.', maxlength: 150
|
4
3
|
|
5
4
|
- if Array(EffectivePosts.categories).length > 1
|
6
5
|
= f.select :category, EffectivePosts.categories
|
7
6
|
- else
|
8
7
|
= f.hidden_field :category, (EffectivePosts.categories.first || 'posts')
|
9
8
|
|
9
|
+
= f.ck_editor :excerpt, hint: 'Will be used for the post excerpt on index pages.'
|
10
|
+
= f.text_field :description, hint: 'The content of the post meta tags.', maxlength: 150
|
11
|
+
|
10
12
|
= render partial: '/effective/posts/additional_fields', locals: { post: post, form: f, f: f }
|
11
13
|
|
12
14
|
= f.datetime_field :published_at, label: 'Publish date', hint: 'When should this be displayed on the website.'
|
@@ -14,7 +16,7 @@
|
|
14
16
|
= f.check_box :draft, hint: 'Save this post as a draft. It will not be accessible on the website.'
|
15
17
|
|
16
18
|
- unless EffectivePosts.use_fullscreen_editor
|
17
|
-
= f.ck_editor :body
|
19
|
+
= f.ck_editor :body, hint: 'The content of your post.'
|
18
20
|
|
19
21
|
- if defined?(EffectiveRoles) and f.object.respond_to?(:roles) && EffectivePosts.use_effective_roles
|
20
22
|
= f.checks :roles, EffectiveRoles.roles_collection(f.object), hint: '* leave blank for a regular public post that anyone can view'
|
@@ -6,6 +6,9 @@
|
|
6
6
|
- else
|
7
7
|
= f.hidden_field :category, (EffectivePosts.categories.first || 'posts')
|
8
8
|
|
9
|
+
= f.ck_editor :excerpt, hint: 'Will be used for the post excerpt on index pages.'
|
10
|
+
= f.text_field :description, hint: 'The content of the post meta tags.', maxlength: 150
|
11
|
+
|
9
12
|
= render partial: '/effective/posts/additional_fields', locals: { post: post, form: f, f: f }
|
10
13
|
|
11
14
|
= f.datetime_field :published_at, label: 'Publish date', hint: 'When should this be displayed on the website.'
|
@@ -13,6 +16,6 @@
|
|
13
16
|
= f.check_box :draft, hint: 'Save this post as a draft. It will not be accessible on the website.'
|
14
17
|
|
15
18
|
- unless EffectivePosts.use_fullscreen_editor
|
16
|
-
= f.ck_editor :body
|
19
|
+
= f.ck_editor :body, hint: 'The content of your post.'
|
17
20
|
|
18
21
|
= f.submit 'Save'
|
data/lib/effective_posts.rb
CHANGED
@@ -56,7 +56,7 @@ module EffectivePosts
|
|
56
56
|
|
57
57
|
def self.permitted_params
|
58
58
|
@@permitted_params ||= [
|
59
|
-
:title, :description, :draft, :category, :published_at, :body, :tags, :extra,
|
59
|
+
:title, :excerpt, :description, :draft, :category, :published_at, :body, :tags, :extra,
|
60
60
|
:start_at, :end_at, :location, :website_name, :website_href, roles: []
|
61
61
|
].compact
|
62
62
|
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.0.
|
4
|
+
version: 1.0.4
|
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: 2019-04-
|
11
|
+
date: 2019-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|