effective_posts 2.1.1 → 2.2.1

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: 12ea7820a86ad8ac8417081593ab7be3b5887ec9f2be2cb05cef6e0ef246b5bf
4
- data.tar.gz: c6bdbb6c8da4f3f3e34ff084690263781fbcb0f9848f0939976d3bbbebcffedb
3
+ metadata.gz: deca7722283a5968f6e2335d46467a806c8a23bf23dca4db28b45f160b8b36eb
4
+ data.tar.gz: 4b9a3c509055d9f59e2d6bbb87a577b2b5b0d4327fc8bef47389c2b5e0ee835e
5
5
  SHA512:
6
- metadata.gz: 9e1a78f1835c434b949f80c9e3ce7f38e6da27df95b19f36583d66b46d02578daeee2fe200269e929272b349ddd63bfb60589561c042fdc81cf8aa29b575e890
7
- data.tar.gz: 5c3cbf2d87a4fc98db48f0584f2b123ad1eaee46b77dff1bc5fb65e443260b5a0d1782633e94d4a65b4a1ec702cb0bbeae0899908b0533c9581655cbf5b87c4b
6
+ metadata.gz: 93964e6a3bc1ccc3832ca9a0e1f4976d6517c75c84430fecd7b115503b09d8891964cec2f2569abf400c3618e64f87839b58699455a6ff5eb0518d75bcb10b16
7
+ data.tar.gz: 339ffe60e451f0aa3829716524127864e5e32debbce769c4bc85506bc6395c42e3faa861e84cba47c37ece8135cb6cad0d47d007b5af5cb18f82cb35ba1ec349
data/README.md CHANGED
@@ -100,6 +100,10 @@ if user.admin?
100
100
  end
101
101
  ```
102
102
 
103
+ ## Search
104
+
105
+ If you use `pg_search` then `Effective::Posts` will be also included on its `multisearch` by default, allowing you to search across all posts.
106
+
103
107
  ## Future Plans
104
108
 
105
109
  There are some obvious additional features that have yet to be implemented:
@@ -1,10 +1,33 @@
1
1
  module Effective
2
2
  class Post < ActiveRecord::Base
3
+ if defined?(PgSearch)
4
+ include PgSearch::Model
5
+
6
+ multisearchable against: [
7
+ :title,
8
+ :menu_title,
9
+ :meta_description,
10
+ :slug,
11
+ ],
12
+ associated_against: {
13
+ rich_text_body: [:body],
14
+ rich_text_excerpt: [:body],
15
+ },
16
+ using: {
17
+ trigram: {},
18
+ tsearch: {
19
+ highlight: true,
20
+ }
21
+ },
22
+ ranked_by: ":trigram" # Could rank by any column/expression, e.g.: (books.num_pages * :trigram) + (:tsearch / 2.0)
23
+ end
24
+
3
25
  attr_accessor :current_user
4
26
 
5
27
  acts_as_slugged
6
28
 
7
29
  log_changes if respond_to?(:log_changes)
30
+ acts_as_tagged if respond_to?(:acts_as_tagged)
8
31
  acts_as_role_restricted if respond_to?(:acts_as_role_restricted)
9
32
 
10
33
  has_one_attached :image
@@ -1,40 +1,46 @@
1
1
  = effective_form_with(model: [:admin, post], engine: true) do |f|
2
- = f.text_field :title, hint: 'The title of your post.'
2
+ = tabs do
3
+ = tab "Post" do
4
+ = f.text_field :title, hint: 'The title of your post.'
3
5
 
4
- - if f.object.persisted? || f.object.errors.include?(:slug)
5
- - current_url = effective_posts.post_path(f.object)
6
+ - if f.object.persisted? || f.object.errors.include?(:slug)
7
+ - current_url = effective_posts.post_path(f.object)
6
8
 
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
+ = f.text_field :slug, required: f.object.persisted?,
10
+ 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
11
 
10
- - if defined?(EffectiveArticleEditor)
11
- = f.article_editor :excerpt, hint: 'Will be used for the post excerpt on index pages.'
12
- - else
13
- = f.rich_text_area :excerpt, hint: 'Will be used for the post excerpt on index pages.'
12
+ - if defined?(EffectiveArticleEditor)
13
+ = f.article_editor :excerpt, hint: 'Will be used for the post excerpt on index pages.'
14
+ - else
15
+ = f.rich_text_area :excerpt, hint: 'Will be used for the post excerpt on index pages.'
14
16
 
15
- = f.text_field :description, hint: 'The content of the post meta tags.', maxlength: 150
17
+ = f.text_field :description, hint: 'The content of the post meta tags.', maxlength: 150
16
18
 
17
- - if Array(EffectivePosts.categories).length > 1
18
- = f.select :category, EffectivePosts.categories
19
- - else
20
- = f.hidden_field :category, value: (EffectivePosts.categories.first || 'posts')
19
+ - if Array(EffectivePosts.categories).length > 1
20
+ = f.select :category, EffectivePosts.categories
21
+ - else
22
+ = f.hidden_field :category, value: (EffectivePosts.categories.first || 'posts')
21
23
 
22
- - if EffectivePosts.use_active_storage
23
- = f.file_field :image, hint: 'An image for your post'
24
+ - if EffectivePosts.use_active_storage
25
+ = f.file_field :image, hint: 'An image for your post'
24
26
 
25
- - if defined?(EffectiveArticleEditor)
26
- = f.article_editor :body, hint: 'The main body of your post'
27
- - else
28
- = f.rich_text_area :body, hint: 'The main body of your post'
27
+ - if defined?(EffectiveArticleEditor)
28
+ = f.article_editor :body, hint: 'The main body of your post'
29
+ - else
30
+ = f.rich_text_area :body, hint: 'The main body of your post'
29
31
 
30
- = render partial: '/effective/posts/additional_fields', locals: { post: post, form: f, f: f }
32
+ = render partial: '/effective/posts/additional_fields', locals: { post: post, form: f, f: f }
31
33
 
32
- = f.datetime_field :published_at, label: 'Publish date', hint: 'When should this be displayed on the website.'
34
+ = f.datetime_field :published_at, label: 'Publish date', hint: 'When should this be displayed on the website.'
33
35
 
34
- = f.check_box :draft, hint: 'Save this post as a draft. It will not be accessible on the website.'
36
+ = f.check_box :draft, hint: 'Save this post as a draft. It will not be accessible on the website.'
35
37
 
36
- - if defined?(EffectiveRoles) && f.object.respond_to?(:roles) && EffectivePosts.use_effective_roles
37
- = render partial: '/admin/posts/roles', locals: { post: post, form: f, f: f }
38
+ - if defined?(EffectiveRoles) && f.object.respond_to?(:roles) && EffectivePosts.use_effective_roles
39
+ = render partial: '/admin/posts/roles', locals: { post: post, form: f, f: f }
40
+
41
+ - if f.object.class.respond_to?(:acts_as_tagged?)
42
+ = tab "Tags" do
43
+ = render 'effective/tags/fields', f: f
38
44
 
39
45
  = f.submit do
40
46
  = f.save 'Save'
@@ -1,3 +1,3 @@
1
1
  module EffectivePosts
2
- VERSION = '2.1.1'.freeze
2
+ VERSION = '2.2.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: 2.1.1
4
+ version: 2.2.1
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-29 00:00:00.000000000 Z
11
+ date: 2023-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails