enjoy_cms_search 0.4.0 → 0.4.0.1

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
  SHA1:
3
- metadata.gz: 9530a7757cc13ca90686bc8b1e26c5bf52eb1522
4
- data.tar.gz: cc4671bc864b9582979daeb918680a0dbe0a5d2c
3
+ metadata.gz: c1de00b50bc01603b9fb6cf5b3d5b22db61599f2
4
+ data.tar.gz: 1e21da2ff975b56d80ac0d75f2b5848f3a958b39
5
5
  SHA512:
6
- metadata.gz: 1af519388bdd0c0a7853ac5087d660d5762222268dd57c19c84f6e253b185d46a16c21b41888239170d885ba22794b0ae14d227063aed903dbc6f7fce111b947
7
- data.tar.gz: e60f028ad78f0288d318f9fdb3e875d67265743ab025627e1e660fb288d01e878fd3fa6ec5d6bacf95499bbd077ad5ca69a96632217685a274024ec701cd1e6b
6
+ metadata.gz: e2e4981ca2fe92e6e1ac6c393dcf45e86c44ffda5301cf3ebc8aefbf93c946dccf547a09eca5ce77c994ea79f25f93e9354ee108c900a93a80746d3ce6c79ef2
7
+ data.tar.gz: 23b65ee2a5307793e9cf21bfa03e5bc8255d900ec2936552465e94ea7a02788309e78ee1d250ab9ee1652e258f66626c7628559e6897d7b8215b260dc0203320
@@ -0,0 +1,24 @@
1
+ module Enjoy::Search
2
+ def self.configuration
3
+ @configuration ||= Configuration.new
4
+ end
5
+ def self.config
6
+ @configuration ||= Configuration.new
7
+ end
8
+
9
+ def self.configure
10
+ yield configuration
11
+ end
12
+
13
+ class Configuration
14
+ attr_accessor :breadcrumbs_on_rails_support
15
+
16
+ attr_accessor :pages_support
17
+
18
+ def initialize
19
+ @breadcrumbs_on_rails_support = defined?(BreadcrumbsOnRails)
20
+
21
+ @pages_support = defined?(Enjoy::Pages)
22
+ end
23
+ end
24
+ end
@@ -4,29 +4,25 @@ module Enjoy::Search
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  def index
7
- if search_redirecter
8
- return redirect_to url_for(params)
9
- end
7
+ return redirect_to url_for(params) if search_redirecter
10
8
 
11
- if defined?(BreadcrumbsOnRails)
12
- add_breadcrumb "search", [:enjoy_search]
9
+ if Enjoy::Search.config.breadcrumbs_on_rails_support
10
+ add_breadcrumb "search", [:enjoy_search], if: :insert_breadcrumbs
11
+ add_breadcrumb "results", [:enjoy_search, {q: params[:q]}], if: :insert_breadcrumbs
13
12
  end
14
13
 
15
14
  if params[:q].blank?
16
15
  @results = []
17
16
  else
18
- query = params[:q].to_s.gsub(/\P{Word}+/, ' ').gsub(/ +/, ' ').strip
19
- @results = search_model_class.page(params[:page]).per(10).send(fts_method, query)
20
- end
21
-
22
- if defined?(BreadcrumbsOnRails)
23
- add_breadcrumb "results", [:enjoy_search, {q: params[:q]}]
17
+ @results = search_model_class.page(params[:page]).per(per_page).send(fts_method, query)
24
18
  end
25
19
  end
26
20
 
27
21
  private
28
22
  def search_model_class
29
- Enjoy::Catalog::Item
23
+ if Enjoy::Search.config.pages_support
24
+ Enjoy::Pages::Page
25
+ end
30
26
  end
31
27
 
32
28
  def fts_method
@@ -43,6 +39,18 @@ module Enjoy::Search
43
39
  false
44
40
  end
45
41
 
42
+ def insert_breadcrumbs
43
+ true
44
+ end
45
+
46
+ def per_page
47
+ 10
48
+ end
49
+
50
+ def query
51
+ params[:q].to_s.gsub(/\P{Word}+/, ' ').gsub(/ +/, ' ').strip
52
+ end
53
+
46
54
  end
47
55
  end
48
56
  end
@@ -1,5 +1,5 @@
1
1
  module Enjoy
2
2
  module Search
3
- VERSION = "0.4.0"
3
+ VERSION = "0.4.0.1"
4
4
  end
5
5
  end
@@ -1,4 +1,5 @@
1
1
  require "enjoy/search/version"
2
+ require "enjoy/search/configuration"
2
3
  require "enjoy/search/engine"
3
4
  require "enjoy/search/routes"
4
5
 
@@ -6,8 +7,6 @@ if Enjoy.active_record?
6
7
  require 'pg_search'
7
8
  end
8
9
 
9
- # require 'enjoy_cms'
10
-
11
10
  module Enjoy::Search
12
11
  class << self
13
12
  def orm
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enjoy_cms_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Kiseliev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2016-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,6 +75,7 @@ files:
75
75
  - bin/console
76
76
  - bin/setup
77
77
  - enjoy_cms_search.gemspec
78
+ - lib/enjoy/search/configuration.rb
78
79
  - lib/enjoy/search/controllers/search.rb
79
80
  - lib/enjoy/search/engine.rb
80
81
  - lib/enjoy/search/routes.rb