alchemy-pg_search 2.1.0 → 2.2.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: a799a278783ba0529bff4fe80e0b2125de5b126dcd5b64791adfc0b54c6e157e
4
- data.tar.gz: 8aefcd02fb869d1d1eea9e16b0777f204a74e0c18331501374b3004edc993054
3
+ metadata.gz: 1029db6a692ffa903d9b8a7324b5cb6a8e473dcbbbf2fee8d5cc57df1ce79149
4
+ data.tar.gz: 171e050f9ca7de014c3c0089fc768c436318524d832df8175a14ba41389b2509
5
5
  SHA512:
6
- metadata.gz: 10d52b3ad7a394f7d1835087d15552cf0f280b85ef5521dc6066fce35685a2bf5cbd25b0850135852a5d2de0333a4c6ec6d63c3b46e5b0b8e97eab3a46f97cc9
7
- data.tar.gz: 6ecc6d9b7827167b43a110c39261a568002b57eaf87b1618aabb8d5272e803ed1e97a9cf2591cd71dac9a09970bbfe2b0946c9018cc2739f1cdd766f730a8cd3
6
+ metadata.gz: 47da2d377ca0a1e28fe679bef4b3322cda015e38e48a362008afeb73ddd11c16c676db8d8f046092ccefb300031b5a2efd518e570234130370ed93d0631214f5
7
+ data.tar.gz: 70e8cb496e368053f4702baa20eadc39dc3c3d318df1f458b618f32851db41b047a03833ba62b225caff08a4f99dd4aa1e58357c50214ccb8817d81036b62fe1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.2.0 (2021-09-25)
2
+
3
+ - Alchemy 4.3 [#21](https://github.com/AlchemyCMS/alchemy-pg_search/pull/21) by [tvdeyen](https://github.com/tvdeyen)
4
+
1
5
  ## 2.1.0 (2021-09-25)
2
6
 
3
7
  - Do not allow Alchemy 4.3 and above [#22](https://github.com/AlchemyCMS/alchemy-pg_search/pull/22) by [tvdeyen](https://github.com/tvdeyen)
data/Gemfile CHANGED
@@ -3,7 +3,9 @@ source "https://rubygems.org"
3
3
  gemspec
4
4
 
5
5
  gem "rails", "~> 5.1.0"
6
- gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: "4.0-stable"
6
+ ENV.fetch("ALCHEMY_BRANCH", "4.3-stable").tap do |branch|
7
+ gem "alchemy_cms", github: "AlchemyCMS/alchemy_cms", branch: branch
8
+ end
7
9
  gem "sassc-rails"
8
10
  gem "sassc", "< 2.2.0"
9
11
  gem "pg", "< 1.0"
@@ -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", "< 4.3"]
19
+ spec.add_runtime_dependency "alchemy_cms", [">= 4.3", "< 5.0"]
20
20
  spec.add_runtime_dependency "pg_search", ["~> 2.1"]
21
21
  spec.add_runtime_dependency "pg"
22
22
 
@@ -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.1.0"
3
+ VERSION = "2.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-pg_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -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: '4.3'
22
+ version: '5.0'
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: '4.3'
32
+ version: '5.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pg_search
35
35
  requirement: !ruby/object:Gem::Requirement