hancock_cms_search 1.0.2
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 +7 -0
- data/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +1 -0
- data/app/controllers/concerns/hancock/search/decorators/search.rb +56 -0
- data/app/controllers/hancock/search/search_controller.rb +7 -0
- data/app/models/concerns/hancock/search/searchable.rb +34 -0
- data/app/views/hancock/search/search/_form.html.slim +3 -0
- data/app/views/hancock/search/search/index.html.slim +20 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/hancock_cms_search.gemspec +35 -0
- data/lib/generators/hancock/search/config/config_generator.rb +13 -0
- data/lib/generators/hancock/search/config/templates/hancock_search.erb +6 -0
- data/lib/generators/hancock/search/controllers/decorators_generator.rb +24 -0
- data/lib/generators/hancock/search/controllers/search_generator.rb +39 -0
- data/lib/generators/hancock/search/controllers/templates/search.erb +53 -0
- data/lib/hancock/search/configuration.rb +25 -0
- data/lib/hancock/search/controllers/search.rb +58 -0
- data/lib/hancock/search/engine.rb +7 -0
- data/lib/hancock/search/routes.rb +22 -0
- data/lib/hancock/search/version.rb +5 -0
- data/lib/hancock_cms_search.rb +17 -0
- data/release.sh +6 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 85156ce341dde76bb4e75d50d01bc21c7965a899
|
4
|
+
data.tar.gz: 1b8744113b922bab5bdf64494e21d13c3de4e86d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 983687ab663b572e85d3c322f5c17f105287d58b969823598985ae9e5123a8532a0bc783f54278ffc90d203c3d70b33048bfade2c67b828dcc6af12c4ef8bd76
|
7
|
+
data.tar.gz: 635062300b0e49181671f527b695aec0af8ade96fb52344d6a9231c90792bf7378e71fa6db0ed7505d4bc822974d8b4b90f711c0dc6d40d40e871bb25b0bdb5e
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
hancock_search
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Alexander Kiseliev
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# HancockCMSSearch
|
2
|
+
|
3
|
+
Search for [HancockCMS](https://github.com/red-rocks/hancock_cms).
|
4
|
+
Full text search, relevance
|
5
|
+
|
6
|
+
### Remaded from [EnjoyCMSSearch](https://github.com/enjocreative/enjoy_cms_search)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'hancock_cms_search'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install hancock_cms_search
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Add in config/routes.rb
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
hancock_cms_search_routes
|
30
|
+
```
|
31
|
+
|
32
|
+
Also you need specify model for search, search method and other. in app/controllers/concerns/hancock/search/decorators/search.rb
|
33
|
+
```ruby
|
34
|
+
module Hancock::Search::Decorators
|
35
|
+
module Search
|
36
|
+
extend ActiveSupport::Concern
|
37
|
+
|
38
|
+
def search_model_class
|
39
|
+
YourModel
|
40
|
+
end
|
41
|
+
|
42
|
+
def fts_method
|
43
|
+
:search
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
```
|
49
|
+
and add this to your_model.rb
|
50
|
+
```ruby
|
51
|
+
include Hancock::Search::Searchable
|
52
|
+
```
|
53
|
+
More [here](https://github.com/red-rocks/hancock_cms_search/blob/master/lib/hancock/search/controllers/search.rb) and [there](https://github.com/red-rocks/hancock_cms_search/blob/master/app/models/concerns/hancock/search/searchable.rb)
|
54
|
+
|
55
|
+
## Development
|
56
|
+
|
57
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
58
|
+
|
59
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/red-rocks/hancock_cms_search.
|
64
|
+
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Hancock::Search::Decorators
|
2
|
+
module Search
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
# def index
|
6
|
+
# return redirect_to url_for(params) if search_redirecter
|
7
|
+
#
|
8
|
+
# if Hancock::Search.config.breadcrumbs_on_rails_support
|
9
|
+
# add_breadcrumb "search", [:hancock_search], if: :insert_breadcrumbs
|
10
|
+
# add_breadcrumb "results", [:hancock_search, {q: params[:q]}], if: :insert_breadcrumbs
|
11
|
+
# end
|
12
|
+
#
|
13
|
+
# if params[:q].blank?
|
14
|
+
# @results = []
|
15
|
+
# else
|
16
|
+
# @results = search_scope ? search_scope.page(params[:page]).per(per_page).send(fts_method, query) : []
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# private
|
21
|
+
# def search_model_class
|
22
|
+
# Hancock::Pages::Page if Hancock::Search.config.pages_support
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# def search_scope
|
26
|
+
# search_model_class.enabled if search_model_class
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# def fts_method
|
30
|
+
# :fts
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# def search_redirecter
|
34
|
+
# if params[:utf8].present? or params[:submit].present? or params[:commit].present?
|
35
|
+
# params.delete(:utf8)
|
36
|
+
# params.delete(:submit)
|
37
|
+
# params.delete(:commit)
|
38
|
+
# return true
|
39
|
+
# end
|
40
|
+
# false
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# def insert_breadcrumbs
|
44
|
+
# true
|
45
|
+
# end
|
46
|
+
#
|
47
|
+
# def per_page
|
48
|
+
# 10
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
# def query
|
52
|
+
# params[:q].to_s.gsub(/\P{Word}+/, ' ').gsub(/ +/, ' ').strip
|
53
|
+
# end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Hancock::Search::Searchable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
module ClassMethods
|
5
|
+
def hancock_search_fts_index(*opts)
|
6
|
+
if Hancock::Search.mongoid?
|
7
|
+
opts = opts.extract_options!
|
8
|
+
index(
|
9
|
+
{
|
10
|
+
name: "text"
|
11
|
+
}.merge(opts[:fields] || {}),
|
12
|
+
{
|
13
|
+
default_language: opts[:default_language] || "russian",
|
14
|
+
weights: {
|
15
|
+
name: 100
|
16
|
+
}.merge(opts[:weights] || {}),
|
17
|
+
name: opts[:name]
|
18
|
+
}
|
19
|
+
)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
included do
|
25
|
+
scope :fts, -> (query, opts= {}) {
|
26
|
+
opts = { "$search": query.to_s}.merge(opts)
|
27
|
+
ret = where({"$text": opts})
|
28
|
+
ret.options[:fields] = {"score": { "$meta": "textScore" }}
|
29
|
+
ret.options[:sort] = {"score": { "$meta": "textScore" }}
|
30
|
+
ret
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
- _partial_path = (Hancock::Search.config.seo_support ? 'shared/obj_with_seo' : 'shared/obj')
|
2
|
+
= render _partial_path, obj: (@seo_page || @seo_parent_page)
|
3
|
+
|
4
|
+
.hancock-search-results
|
5
|
+
h1 Результаты поиска
|
6
|
+
= render partial: "hancock/search/search/form"
|
7
|
+
ol
|
8
|
+
- any = false
|
9
|
+
- @results.each do |r|
|
10
|
+
- any = true
|
11
|
+
li
|
12
|
+
.title= link_to r.name, url_for(r)
|
13
|
+
.text
|
14
|
+
= raw r.content
|
15
|
+
span.more= link_to 'открыть', url_for(r)
|
16
|
+
|
17
|
+
- unless any
|
18
|
+
.hancock-search-no-results К сожалению, ничего не найдено
|
19
|
+
|
20
|
+
= paginate @results if any
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "hancock_cms_search"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hancock/search/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "hancock_cms_search"
|
8
|
+
spec.version = Hancock::Search::VERSION
|
9
|
+
spec.authors = ["Alexander Kiseliev"]
|
10
|
+
spec.email = ["dev@redrocks.pro"]
|
11
|
+
|
12
|
+
spec.summary = %q{hancock_cms_search}
|
13
|
+
spec.description = %q{hancock_cms_search}
|
14
|
+
spec.homepage = "https://github.com/red-rocks/hancock_cms_search"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
|
33
|
+
spec.add_dependency 'hancock_cms', [">=1.0.2", "<2.1.x"]
|
34
|
+
# spec.add_dependency 'hancock_cms', ["~> 1.0.2", "~> 2.0"]
|
35
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Search
|
4
|
+
class ConfigGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
desc 'Hancock::Search Config generator'
|
8
|
+
def config
|
9
|
+
template 'hancock_search.erb', "config/initializers/hancock_search.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Search::Controllers
|
4
|
+
class DecoratorsGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../../../../../../app/controllers/concerns/hancock/search/decorators', __FILE__)
|
6
|
+
argument :controllers, type: :array, default: []
|
7
|
+
|
8
|
+
desc 'Hancock::Search Controllers generator'
|
9
|
+
def decorators
|
10
|
+
copied = false
|
11
|
+
(controllers == ['all'] ? permitted_controllers : controllers & permitted_controllers).each do |c|
|
12
|
+
copied = true
|
13
|
+
copy_file "#{c}.rb", "app/controllers/concerns/hancock/search/decorators/#{c}.rb"
|
14
|
+
end
|
15
|
+
puts "U need to set controllers`s name. One of this: #{permitted_controllers.join(", ")}." unless copied
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def permitted_controllers
|
20
|
+
['search']
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Hancock::Search::Controllers
|
4
|
+
class SearchGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :class_name_arg, type: :string, default: ""
|
7
|
+
|
8
|
+
desc 'Hancock::Search Transfer Controller generator'
|
9
|
+
def search
|
10
|
+
template 'search.erb', "app/controllers/#{file_name}.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
def class_name
|
15
|
+
class_name_arg.blank? ? "SetClassForSearchController" : class_name_arg
|
16
|
+
end
|
17
|
+
|
18
|
+
def capitalized_class_name
|
19
|
+
class_name.capitalize
|
20
|
+
end
|
21
|
+
|
22
|
+
def camelcased_class_name
|
23
|
+
class_name.camelcase
|
24
|
+
end
|
25
|
+
|
26
|
+
def file_name
|
27
|
+
underscored_class_name
|
28
|
+
end
|
29
|
+
|
30
|
+
def underscored_class_name
|
31
|
+
camelcased_class_name.underscore
|
32
|
+
end
|
33
|
+
|
34
|
+
def underscored_pluralized_class_name
|
35
|
+
underscored_class_name.pluralize
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class <%= camelcased_class_name %> < Hancock::Search::SearchController
|
2
|
+
|
3
|
+
# def index
|
4
|
+
# return redirect_to url_for(params) if search_redirecter
|
5
|
+
#
|
6
|
+
# if Hancock::Search.config.breadcrumbs_on_rails_support
|
7
|
+
# add_breadcrumb "search", [:hancock_search], if: :insert_breadcrumbs
|
8
|
+
# add_breadcrumb "results", [:hancock_search, {q: params[:q]}], if: :insert_breadcrumbs
|
9
|
+
# end
|
10
|
+
#
|
11
|
+
# if params[:q].blank?
|
12
|
+
# @results = []
|
13
|
+
# else
|
14
|
+
# @results = search_scope ? search_scope.page(params[:page]).per(per_page).send(fts_method, query) : []
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# private
|
19
|
+
# def search_model_class
|
20
|
+
# Hancock::Pages::Page if Hancock::Search.config.pages_support
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# def search_scope
|
24
|
+
# search_model_class.enabled if search_model_class
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# def fts_method
|
28
|
+
# :fts
|
29
|
+
# end
|
30
|
+
#
|
31
|
+
# def search_redirecter
|
32
|
+
# if params[:utf8].present? or params[:submit].present? or params[:commit].present?
|
33
|
+
# params.delete(:utf8)
|
34
|
+
# params.delete(:submit)
|
35
|
+
# params.delete(:commit)
|
36
|
+
# return true
|
37
|
+
# end
|
38
|
+
# false
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# def insert_breadcrumbs
|
42
|
+
# true
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# def per_page
|
46
|
+
# 10
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# def query
|
50
|
+
# params[:q].to_s.gsub(/\P{Word}+/, ' ').gsub(/ +/, ' ').strip
|
51
|
+
# end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Hancock::Search
|
2
|
+
include Hancock::PluginConfiguration
|
3
|
+
|
4
|
+
def self.config_class
|
5
|
+
Configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
class Configuration
|
9
|
+
attr_accessor :breadcrumbs_on_rails_support
|
10
|
+
|
11
|
+
attr_accessor :seo_support
|
12
|
+
attr_accessor :cache_support
|
13
|
+
|
14
|
+
attr_accessor :pages_support
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@breadcrumbs_on_rails_support = !!defined?(BreadcrumbsOnRails)
|
18
|
+
|
19
|
+
@seo_support = !!defined?(Hancock::Seo)
|
20
|
+
@cache_support = !!defined?(Hancock::Cache)
|
21
|
+
|
22
|
+
@pages_support = !!defined?(Hancock::Pages)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Hancock::Search
|
2
|
+
module Controllers
|
3
|
+
module Search
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def index
|
7
|
+
return redirect_to url_for(params) if search_redirecter
|
8
|
+
|
9
|
+
if Hancock::Search.config.breadcrumbs_on_rails_support
|
10
|
+
add_breadcrumb "search", [:hancock_search], if: :insert_breadcrumbs
|
11
|
+
add_breadcrumb "results", [:hancock_search, {q: params[:q]}], if: :insert_breadcrumbs
|
12
|
+
end
|
13
|
+
|
14
|
+
if params[:q].blank?
|
15
|
+
@results = []
|
16
|
+
else
|
17
|
+
@results = search_scope ? search_scope.page(params[:page]).per(per_page).send(fts_method, query) : []
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def search_model_class
|
23
|
+
Hancock::Pages::Page if Hancock::Search.config.pages_support
|
24
|
+
end
|
25
|
+
|
26
|
+
def search_scope
|
27
|
+
search_model_class.enabled if search_model_class
|
28
|
+
end
|
29
|
+
|
30
|
+
def fts_method
|
31
|
+
:fts
|
32
|
+
end
|
33
|
+
|
34
|
+
def search_redirecter
|
35
|
+
if params[:utf8].present? or params[:submit].present? or params[:commit].present?
|
36
|
+
params.delete(:utf8)
|
37
|
+
params.delete(:submit)
|
38
|
+
params.delete(:commit)
|
39
|
+
return true
|
40
|
+
end
|
41
|
+
false
|
42
|
+
end
|
43
|
+
|
44
|
+
def insert_breadcrumbs
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
def per_page
|
49
|
+
10
|
50
|
+
end
|
51
|
+
|
52
|
+
def query
|
53
|
+
params[:q].to_s.gsub(/\P{Word}+/, ' ').gsub(/ +/, ' ').strip
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ActionDispatch::Routing
|
2
|
+
class Mapper
|
3
|
+
|
4
|
+
def hancock_cms_search_routes(config = {})
|
5
|
+
routes_config = {
|
6
|
+
use_search_path: true
|
7
|
+
}
|
8
|
+
routes_config.merge!(config)
|
9
|
+
|
10
|
+
scope module: 'hancock' do
|
11
|
+
scope module: 'search' do
|
12
|
+
|
13
|
+
if routes_config[:use_search_path]
|
14
|
+
get 'search/(:q)(/page/:page)' => 'search#index', as: :hancock_search
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "hancock/search/version"
|
2
|
+
require "hancock/search/configuration"
|
3
|
+
require "hancock/search/engine"
|
4
|
+
require "hancock/search/routes"
|
5
|
+
|
6
|
+
if Hancock.active_record?
|
7
|
+
require 'pg_search'
|
8
|
+
end
|
9
|
+
|
10
|
+
module Hancock::Search
|
11
|
+
include Hancock::Plugin
|
12
|
+
|
13
|
+
module Controllers
|
14
|
+
autoload :Search, 'hancock/search/controllers/search'
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/release.sh
ADDED
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hancock_cms_search
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Kiseliev
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hancock_cms
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.2
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.1.x
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.0.2
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 2.1.x
|
61
|
+
description: hancock_cms_search
|
62
|
+
email:
|
63
|
+
- dev@redrocks.pro
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".gitignore"
|
69
|
+
- ".ruby-gemset"
|
70
|
+
- ".ruby-version"
|
71
|
+
- ".travis.yml"
|
72
|
+
- Gemfile
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- app/controllers/concerns/hancock/search/decorators/search.rb
|
77
|
+
- app/controllers/hancock/search/search_controller.rb
|
78
|
+
- app/models/concerns/hancock/search/searchable.rb
|
79
|
+
- app/views/hancock/search/search/_form.html.slim
|
80
|
+
- app/views/hancock/search/search/index.html.slim
|
81
|
+
- bin/console
|
82
|
+
- bin/setup
|
83
|
+
- hancock_cms_search.gemspec
|
84
|
+
- lib/generators/hancock/search/config/config_generator.rb
|
85
|
+
- lib/generators/hancock/search/config/templates/hancock_search.erb
|
86
|
+
- lib/generators/hancock/search/controllers/decorators_generator.rb
|
87
|
+
- lib/generators/hancock/search/controllers/search_generator.rb
|
88
|
+
- lib/generators/hancock/search/controllers/templates/search.erb
|
89
|
+
- lib/hancock/search/configuration.rb
|
90
|
+
- lib/hancock/search/controllers/search.rb
|
91
|
+
- lib/hancock/search/engine.rb
|
92
|
+
- lib/hancock/search/routes.rb
|
93
|
+
- lib/hancock/search/version.rb
|
94
|
+
- lib/hancock_cms_search.rb
|
95
|
+
- release.sh
|
96
|
+
homepage: https://github.com/red-rocks/hancock_cms_search
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.5.1
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: hancock_cms_search
|
120
|
+
test_files: []
|