effective_posts 1.1.2 → 1.1.3

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
  SHA256:
3
- metadata.gz: 7ecb4b57c498f35d22abd5e74e340a831a8e8a94087bf4e76add868e3303563a
4
- data.tar.gz: b80111cb9a61dbe0fc84d2c38bb2650aff3a9c375cec6b15f7a21570d8da8570
3
+ metadata.gz: 9d8ad99d213f6946178f6ee95f35d5e457cfb2adce548ae2e33d513087e72c34
4
+ data.tar.gz: c2be01f6e4b03b42a45203f90c5f796e61dc25587bb9fe98647e27a64c0b2031
5
5
  SHA512:
6
- metadata.gz: 8a0159505c082df7520b35d20bd096d2cbd6ad07e781bbf2a65f3ef8c87b16bf2f2227f89af7b7855e01f974d2ca63e8784b6a00e1bcb24709bdc948ee9b637b
7
- data.tar.gz: e07f7a9e80b4b1cd31577cfa02624086d40808590ceca6298755d534d95162d10ace9a2f3269c8875cfcce39b3de3ec2348fbdf06f06727231af1c27b1aa9711
6
+ metadata.gz: 4bbe96be0a51878183fa877150b83067da2ffad8bdbb7830807f80a7176e0deb91e35587f1ca24cd6a551b141d449acc13f7a68186ab57b0bd5811d4e67de8ba
7
+ data.tar.gz: 58cff47c9439c69cd2105465a37bd9c26951f31374fcb84c19ffe89ef9f3fc3d47d2db53e6bd91afe8cad20abce9f568e73290f242789687847fe64d61a2a458
data/README.md CHANGED
@@ -148,7 +148,7 @@ can [:index, :show], Effective::Post
148
148
 
149
149
  if user.admin?
150
150
  can :manage, Effective::Post
151
- can :admin, :effective_pages
151
+ can :admin, :effective_posts
152
152
  end
153
153
  ```
154
154
 
@@ -1 +1 @@
1
- //= require effective_pages/additional_fields
1
+ //= require effective_posts/additional_fields
@@ -6,6 +6,7 @@ class EffectivePostsDatatable < Effective::Datatable
6
6
  col :id, visible: false
7
7
 
8
8
  col :title
9
+ col :slug, visible: false
9
10
  col :category, search: { collection: EffectivePosts.categories }
10
11
 
11
12
  if EffectivePosts.submissions_enabled
@@ -9,6 +9,7 @@ if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
9
9
  table_column :id, visible: false
10
10
 
11
11
  table_column :title
12
+ table_column :slug
12
13
  table_column :category, filter: { type: :select, values: EffectivePosts.categories }
13
14
 
14
15
  if EffectivePosts.submissions_enabled
@@ -2,6 +2,7 @@ module Effective
2
2
  class Post < ActiveRecord::Base
3
3
  acts_as_role_restricted if defined?(EffectiveRoles) && EffectivePosts.use_effective_roles
4
4
  acts_as_regionable
5
+ acts_as_slugged
5
6
 
6
7
  self.table_name = EffectivePosts.posts_table_name.to_s
7
8
 
@@ -11,12 +12,14 @@ module Effective
11
12
  # title :string
12
13
  # description :string
13
14
 
15
+ # slug :string
16
+
14
17
  # category :string
15
18
 
16
19
  # draft :boolean
17
20
  # published_at :datetime
18
21
  # tags :text
19
-
22
+
20
23
  # roles_mask :integer
21
24
 
22
25
  # Event Fields
@@ -67,6 +70,10 @@ module Effective
67
70
  scope
68
71
  }
69
72
 
73
+ def to_param
74
+ slug.presence || "#{id}-#{title.parameterize}"
75
+ end
76
+
70
77
  def to_s
71
78
  title.presence || 'New Post'
72
79
  end
@@ -91,10 +98,6 @@ module Effective
91
98
  region(:body).content = input
92
99
  end
93
100
 
94
- def to_param
95
- "#{id}-#{title.parameterize}"
96
- end
97
-
98
101
  # 3.333 words/second is the default reading speed.
99
102
  def time_to_read_in_seconds(reading_speed = 3.333)
100
103
  (regions.to_a.sum { |region| (region.content || '').scan(/\w+/).size } / reading_speed).seconds
@@ -1,5 +1,8 @@
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
+ - if f.object.persisted? || f.object.errors.include?(:slug)
4
+ - current_url = (effective_posts.post_url(f.object) rescue nil)
5
+ = 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 }".html_safe
3
6
 
4
7
  - if Array(EffectivePosts.categories).length > 1
5
8
  = f.select :category, EffectivePosts.categories
@@ -5,10 +5,11 @@ class CreateEffectivePosts < ActiveRecord::Migration[4.2]
5
5
 
6
6
  t.string :title
7
7
  t.text :excerpt
8
-
8
+
9
9
  t.string :description
10
-
10
+
11
11
  t.string :category
12
+ t.string :slug
12
13
 
13
14
  t.boolean :draft, :default => false
14
15
  t.datetime :published_at
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = '1.1.2'.freeze
2
+ VERSION = '1.1.3'.freeze
3
3
  end
@@ -55,7 +55,7 @@ module EffectivePosts
55
55
 
56
56
  def self.permitted_params
57
57
  @@permitted_params ||= [
58
- :title, :excerpt, :description, :draft, :category, :published_at, :body, :tags, :extra,
58
+ :title, :excerpt, :description, :draft, :category, :slug, :published_at, :body, :tags, :extra,
59
59
  :start_at, :end_at, :location, :website_name, :website_href, roles: []
60
60
  ].compact
61
61
  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.2
4
+ version: 1.1.3
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-06-07 00:00:00.000000000 Z
11
+ date: 2019-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: effective_resources
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: A blog implementation with WYSIWYG content editing, post scheduling,
112
126
  pagination and optional top level routes for each post category.
113
127
  email:
@@ -119,8 +133,8 @@ files:
119
133
  - MIT-LICENSE
120
134
  - README.md
121
135
  - app/assets/javascripts/effective/snippets/read_more_divider.js.coffee
122
- - app/assets/javascripts/effective_pages/additional_fields.js.coffee
123
136
  - app/assets/javascripts/effective_posts.js
137
+ - app/assets/javascripts/effective_posts/additional_fields.js.coffee
124
138
  - app/assets/stylesheets/effective_posts.scss
125
139
  - app/controllers/admin/posts_controller.rb
126
140
  - app/controllers/effective/posts_controller.rb