alchemy-pg_search 5.1.0 → 5.2.0

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: efbd69f49a2b6dd894da769c73bf8336f257d14f1c59b5a6ec3e45cc1f01ba45
4
- data.tar.gz: 30712617a4a1142d232da68753c74a71b86c6c9fa8904bca03b461ff980c1fd4
3
+ metadata.gz: bd79aeea752492e2162f8338e15726c51af184f2ee0025cffd6f7eb98914eb8c
4
+ data.tar.gz: 5b8bd8894f18350baffdb0537bcbdebc9e781f8aa86251919972b6a076c3171f
5
5
  SHA512:
6
- metadata.gz: 52d1d223c67ce3edea17aa2c9ab81858102abe50d0e61b8bdf58b48bf208e6ff46914e76dd766bf5b506f1b0e9a374eb341a8638680f972eaf0bbf5022f5531b
7
- data.tar.gz: 36b0f2f6fe63cd2a77d2a719d62f80e5f1e09944ed67944304c0017e157f5789ca6bf24803f0891f9a81d6dee332a0d10af9784a195b334ac0b5b6fbf643943b
6
+ metadata.gz: c0333bfcb6a05dc82aa69c7147429bbe337315d90c61bcbbf3ae6d4ef3d11b28137e934dde2d38f98ce02288dcfb4d08cadc099b6d2d998da0c69abe044d3089
7
+ data.tar.gz: f1b6ac52bdfc1cb2199344eca5f691c03063b1d9d1a56d28236512621650640390adf093842c8111998992a26bfed2b2927360f2bddcbc286e9bc0910226ec5e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [v5.2.0](https://github.com/AlchemyCMS/alchemy-pg_search/tree/v5.2.0) (2024-02-05)
4
+
5
+ [Full Changelog](https://github.com/AlchemyCMS/alchemy-pg_search/compare/v5.1.0...v5.2.0)
6
+
7
+ **Merged pull requests:**
8
+
9
+ - Allow different search strings in preview [\#46](https://github.com/AlchemyCMS/alchemy-pg_search/pull/46) ([sascha-karnatz](https://github.com/sascha-karnatz))
10
+ - Add support for Rails 7.1 [\#45](https://github.com/AlchemyCMS/alchemy-pg_search/pull/45) ([sascha-karnatz](https://github.com/sascha-karnatz))
11
+ - Update configuration section in README [\#44](https://github.com/AlchemyCMS/alchemy-pg_search/pull/44) ([sascha-karnatz](https://github.com/sascha-karnatz))
12
+ - Avoid duplicating Alchemy.publish\_targets in development environment [\#40](https://github.com/AlchemyCMS/alchemy-pg_search/pull/40) ([dbwinger](https://github.com/dbwinger))
13
+
3
14
  ## [v5.1.0](https://github.com/AlchemyCMS/alchemy-pg_search/tree/v5.1.0) (2023-12-20)
4
15
 
5
16
  [Full Changelog](https://github.com/AlchemyCMS/alchemy-pg_search/compare/v5.0.0...v5.1.0)
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "~> 7.0.0"
5
+ gem "rails", "~> 7.1.0"
6
6
  gem "alchemy_cms", "~> 7.0.0"
7
7
 
8
8
  gem "sassc-rails"
data/README.md CHANGED
@@ -99,12 +99,18 @@ The same works for `ingredients` as well
99
99
  Configure the gem in an initializer. The default configurations are:
100
100
 
101
101
  ```ruby
102
- Alchemy::PgSearch.config = {
103
- dictionary: 'simple',
104
- paginate_per: 10
105
- }
102
+ Rails.application.config.before_initialize do
103
+ Alchemy::PgSearch.config = {
104
+ dictionary: 'simple',
105
+ paginate_per: 10
106
+ }
107
+ end
106
108
  ```
107
109
 
110
+ > [!NOTE]
111
+ > Be aware that `before_initialize` is used. Otherwise the configuration will not have an effect, because of the load
112
+ > order in Rails.
113
+
108
114
  Configuration Name | Default Value | Description
109
115
  --------------------|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
110
116
  dictionary | simple | Dictionary for the multisearch tsearch - config, which is used to find the content. The dictionary can impact the amout found documents, because it removes language specific stop words. See more in the [PostgreSQL documentation](https://www.postgresql.org/docs/current/textsearch-dictionaries.html).
@@ -153,6 +159,11 @@ place additional elements (maybe a header image or additional text blocks) on th
153
159
  # elements.yml
154
160
  - name: searchresults
155
161
  unique: true
162
+ ingredients:
163
+ - role: search_string
164
+ hint: The is only for presentational purposes in the Alchemy preview
165
+ default: lorem
166
+ type: Text
156
167
  ```
157
168
 
158
169
  and then use the view helpers to render the search form on the page layout partial and the search results on the element
@@ -34,9 +34,7 @@ module Alchemy
34
34
  # @see Alchemy::PagesHelper#render_search_form
35
35
  #
36
36
  def perform_search
37
- if self.class == Alchemy::Admin::PagesController && params[:query].blank?
38
- params[:query] = "lorem"
39
- end
37
+ set_preview_query
40
38
  return if params[:query].blank?
41
39
  @search_results = search_results
42
40
  if paginate_per
@@ -83,6 +81,16 @@ module Alchemy
83
81
  def paginate_per
84
82
  Alchemy::PgSearch.config[:paginate_per]
85
83
  end
84
+
85
+ private
86
+
87
+ def set_preview_query
88
+ if self.class == Alchemy::Admin::PagesController && params[:query].blank?
89
+ element = search_result_page.draft_version.elements.named(:searchresults).first
90
+
91
+ params[:query] = element&.value_for("search_string") || "lorem"
92
+ end
93
+ end
86
94
  end
87
95
  end
88
96
  end
@@ -12,11 +12,14 @@ module Alchemy
12
12
  end
13
13
 
14
14
  # We need to have the search methods present in all Alchemy controllers
15
- Alchemy::BaseController.send(:include, Alchemy::PgSearch::ControllerMethods)
16
-
17
- # reindex the page after it was published
18
- Alchemy.publish_targets << Alchemy::PgSearch::IndexPageJob
15
+ Alchemy::PagesController.send(:include, Alchemy::PgSearch::ControllerMethods)
16
+ Alchemy::Admin::PagesController.send(:include, Alchemy::PgSearch::ControllerMethods)
19
17
 
18
+ # In development environment, this runs on every code reload, so avoid multiple reindexing jobs
19
+ unless Alchemy.publish_targets.map(&:name).include? 'Alchemy::PgSearch::IndexPageJob'
20
+ # reindex the page after it was published
21
+ Alchemy.publish_targets << Alchemy::PgSearch::IndexPageJob
22
+ end
20
23
  # enable searchable flag in page form
21
24
  Alchemy.enable_searchable = true
22
25
 
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module PgSearch
3
- VERSION = "5.1.0"
3
+ VERSION = "5.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-pg_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-20 00:00:00.000000000 Z
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  requirements:
165
165
  - PostgreSQL >= 12.x
166
- rubygems_version: 3.4.17
166
+ rubygems_version: 3.5.5
167
167
  signing_key:
168
168
  specification_version: 4
169
169
  summary: This gem provides PostgreSQL full text search to Alchemy