alchemy-pg_search 2.0.0 → 2.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0f7e0df77f37c90847ca65e06e9e857b1ce34c3967a5f4ad2b49b5b628a92216
4
- data.tar.gz: f090bfccc9e38990d60047eaa41f7752ee6e96dbb9b80c7c7d0c747ab7296535
3
+ metadata.gz: b9b68ff72c39fd21b51251b0d47919016fd3d59a8e32a0358ce4c4b48170cd4d
4
+ data.tar.gz: afb71a844327fe5f9a07a2a8b91edbab57da267e514e9d3fc51a32d2369c3465
5
5
  SHA512:
6
- metadata.gz: e753341799782ba728dfffd808f0b8dfd3e4c224973858d6e04a0bcba28f234cff4f1bca64e7b74ef2f6f179523cfbc75df2824c3bab6fa2d09e31e59d836d7d
7
- data.tar.gz: 612150eac4dba1e71277a325617ae84ae138eaec33b3ae7d330065255cd7f98a05f0094c508f5650f70edb981a716e664b919f43641f9a1dedfcaef1f39d5cd8
6
+ metadata.gz: 60d7d211907766eee70dd946ac8c5dca0bc535a562feda995d441e0872e3a418337ec0060502aa32b45fbf432709e6380541b233fda1f152c3f56444a2bff6b7
7
+ data.tar.gz: e90ff5b03757e72b6ef471470ee972dc615fa54cac75803c9c6000284e19cb20ac557a1b3b2453aea0e8eaa985254086d4ad1698e10f9fe27ccb2140bf2cdce6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ ## 2.3.0 (2022-03-04)
2
+
3
+ - Add support for Alchemy 5.1 [#24](https://github.com/AlchemyCMS/alchemy-pg_search/pull/24) by [kulturbande](https://github.com/kulturbande)
4
+
5
+ ## 2.2.0 (2021-09-25)
6
+
7
+ - Alchemy 4.3 [#21](https://github.com/AlchemyCMS/alchemy-pg_search/pull/21) by [tvdeyen](https://github.com/tvdeyen)
8
+
9
+ ## 2.1.0 (2021-09-25)
10
+
11
+ - Do not allow Alchemy 4.3 and above [#22](https://github.com/AlchemyCMS/alchemy-pg_search/pull/22) by [tvdeyen](https://github.com/tvdeyen)
12
+ - Add Rails 5.1 support [#19](https://github.com/AlchemyCMS/alchemy-pg_search/pull/19) by [tvdeyen](https://github.com/tvdeyen)
13
+
1
14
  ## 2.0.0 (2021-09-23)
2
15
 
3
16
  - Move searchable attribute to contents table [#20](https://github.com/AlchemyCMS/alchemy-pg_search/pull/20) by [tvdeyen](https://github.com/tvdeyen)
data/Gemfile CHANGED
@@ -2,11 +2,14 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "rails", "~> 5.0.0"
6
- gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: "4.0-stable"
5
+ gem "rails", "~> 6.0.0"
6
+ ENV.fetch("ALCHEMY_BRANCH", "5.1-stable").tap do |branch|
7
+ gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: branch
8
+ end
7
9
  gem "sassc-rails"
8
- gem "sassc", "< 2.2.0"
9
- gem "pg", "< 1.0"
10
+ gem "sassc", "~> 2.4.0"
11
+ gem "webpacker"
12
+ gem "pg", "~> 1.0"
10
13
  gem "puma"
11
14
 
12
15
  group :test do
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
17
17
  spec.require_paths = ["lib"]
18
18
 
19
- spec.add_runtime_dependency "alchemy_cms", [">= 4.0", "< 5.0"]
19
+ spec.add_runtime_dependency "alchemy_cms", [">= 4.3", "< 5.2"]
20
20
  spec.add_runtime_dependency "pg_search", ["~> 2.1"]
21
21
  spec.add_runtime_dependency "pg"
22
22
 
@@ -1,4 +1,4 @@
1
- class AddSearchableToAlchemyEssenceTexts < ActiveRecord::Migration
1
+ class AddSearchableToAlchemyEssenceTexts < ActiveRecord::Migration[5.1]
2
2
  def change
3
3
  add_column :alchemy_essence_texts, :searchable, :boolean, default: true
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddSearchableToAlchemyEssenceRichtexts < ActiveRecord::Migration
1
+ class AddSearchableToAlchemyEssenceRichtexts < ActiveRecord::Migration[5.1]
2
2
  def change
3
3
  add_column :alchemy_essence_richtexts, :searchable, :boolean, default: true
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddSearchableToAlchemyEssencePictures < ActiveRecord::Migration
1
+ class AddSearchableToAlchemyEssencePictures < ActiveRecord::Migration[5.1]
2
2
  def change
3
3
  add_column :alchemy_essence_pictures, :searchable, :boolean, default: true
4
4
  end
@@ -1,7 +1,8 @@
1
1
  module Alchemy::PgSearch::ContentExtension
2
2
  module ClassMethods
3
- def build(element, essence_hash)
4
- definition = content_definition(element, essence_hash)
3
+ def new(attributes)
4
+ element = attributes[:element]
5
+ definition = element.content_definition_for(attributes[:name])
5
6
  super.tap do |content|
6
7
  content.searchable = definition.key?(:searchable) ? definition[:searchable] : true
7
8
  end
@@ -1,58 +1,54 @@
1
- Alchemy::Page.class_eval do
2
- include PgSearch::Model
1
+ # Enable Postgresql full text indexing.
2
+ #
3
+ module Alchemy::PgSearch::PageExtension
4
+ def self.extended(base)
5
+ base.include InstanceMethods
6
+ base.include PgSearch::Model
3
7
 
4
- # Enable Postgresql full text indexing.
5
- #
6
- pg_search_scope :full_text_search,
7
- against: {
8
- meta_description: "B",
9
- meta_keywords: "B",
10
- title: "B",
11
- name: "A",
12
- },
13
- associated_against: {
14
- searchable_essence_texts: :body,
15
- searchable_essence_richtexts: :stripped_body,
16
- searchable_essence_pictures: :caption,
17
- },
18
- using: {
19
- tsearch: { prefix: true },
20
- }
8
+ base.pg_search_scope(
9
+ :full_text_search,
10
+ against: {
11
+ meta_description: "B",
12
+ meta_keywords: "B",
13
+ title: "B",
14
+ name: "A",
15
+ },
16
+ associated_against: {
17
+ searchable_essence_texts: :body,
18
+ searchable_essence_richtexts: :stripped_body,
19
+ searchable_essence_pictures: :caption,
20
+ },
21
+ using: {
22
+ tsearch: { prefix: true },
23
+ },
24
+ )
21
25
 
22
- has_many :searchable_essence_texts,
23
- -> {
24
- includes(:element)
25
- .where(alchemy_contents: { searchable: true })
26
- .where(alchemy_elements: { public: true })
27
- },
28
- class_name: "Alchemy::EssenceText",
29
- source_type: "Alchemy::EssenceText",
30
- through: :descendent_contents,
31
- source: :essence
26
+ base.has_many(
27
+ :searchable_contents,
28
+ -> {
29
+ where(alchemy_elements: { public: true })
30
+ .where(searchable: true)
31
+ },
32
+ class_name: "Alchemy::Content",
33
+ through: :all_elements,
34
+ )
32
35
 
33
- has_many :searchable_essence_richtexts,
34
- -> {
35
- includes(:element)
36
- .where(alchemy_contents: { searchable: true })
37
- .where(alchemy_elements: { public: true })
38
- },
39
- class_name: "Alchemy::EssenceRichtext",
40
- source_type: "Alchemy::EssenceRichtext",
41
- through: :descendent_contents,
42
- source: :essence
43
-
44
- has_many :searchable_essence_pictures,
45
- -> {
46
- includes(:element)
47
- .where(alchemy_contents: { searchable: true })
48
- .where(alchemy_elements: { public: true })
49
- },
50
- class_name: "Alchemy::EssencePicture",
51
- source_type: "Alchemy::EssencePicture",
52
- through: :descendent_contents,
53
- source: :essence
36
+ Alchemy::PgSearch::SEARCHABLE_ESSENCES.each do |klass|
37
+ base.has_many(
38
+ :"searchable_#{klass.underscore.pluralize}",
39
+ class_name: "Alchemy::#{klass}",
40
+ source_type: "Alchemy::#{klass}",
41
+ through: :searchable_contents,
42
+ source: :essence,
43
+ )
44
+ end
45
+ end
54
46
 
55
- def element_search_results(query)
56
- descendent_elements.full_text_search(query)
47
+ module InstanceMethods
48
+ def element_search_results(query)
49
+ all_elements.full_text_search(query)
50
+ end
57
51
  end
52
+
53
+ Alchemy::Page.extend self
58
54
  end
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module PgSearch
3
- VERSION = "2.0.0"
3
+ VERSION = "2.3.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: 2.0.0
4
+ version: 2.3.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: 2021-09-23 00:00:00.000000000 Z
11
+ date: 2022-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '4.3'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.0'
22
+ version: '5.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '4.0'
29
+ version: '4.3'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.0'
32
+ version: '5.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pg_search
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
161
  requirements: []
162
- rubygems_version: 3.2.27
162
+ rubygems_version: 3.1.6
163
163
  signing_key:
164
164
  specification_version: 4
165
165
  summary: This gem provides PostgreSQL full text search to Alchemy 4.0