effective_posts 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b92998992d3bbc6241ed4b3f9069f4bb64534e7c
4
- data.tar.gz: d15314fde411d0b8629cb6f37902a839d73eeee6
3
+ metadata.gz: f796cf858658cf9c8f19f2b45339e7e7fbfa64c2
4
+ data.tar.gz: 672b79eb37607da4c40e2d51f24da5944d6ddd92
5
5
  SHA512:
6
- metadata.gz: 72f48a2d8e10798746146da15a8a3c6a6e855555969871484669c9525f37f1ec0deb52eafff337b24ae293d9085abce1657a1b6e01f945fd7eabac860dc7373f
7
- data.tar.gz: 54c499bd42808da6c0950d13cb286cff353e3696c1d71cea1c267162ee41f6fc70ea65104ea58fbc14f0b88d8e8a19e9bee5d4d5c826fb3ec181bba94238ca51
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 = (params[:page_title] || params[:category] || params[:defaults].try(:[], :category) || 'Posts').titleize
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 = @post.title
52
- @meta_description = @post.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: 200)
81
- content = effective_region(post, :body, :editable => false) { '<p>Default content</p>'.html_safe }
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
- CGI.unescapeHTML(if divider.present?
88
- truncate_html(content, Effective::Snippets::ReadMoreDivider::TOKEN, '') + read_more
89
- elsif length.present?
90
- truncate_html(description, length, omission) + read_more
91
- else
92
- description
93
- end).html_safe
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'
@@ -4,6 +4,8 @@ class CreateEffectivePosts < ActiveRecord::Migration[4.2]
4
4
  t.integer :user_id
5
5
 
6
6
  t.string :title
7
+ t.text :excerpt
8
+
7
9
  t.string :description
8
10
 
9
11
  t.string :category
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  end
@@ -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.3
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-10 00:00:00.000000000 Z
11
+ date: 2019-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails