searchify 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +9 -3
- data/app/helpers/searchify/searchify_helper.rb +14 -13
- data/config/routes.rb +0 -1
- data/lib/searchify/version.rb +1 -1
- metadata +46 -48
- data/test/dummy/log/development.log +0 -0
data/README.md
CHANGED
@@ -106,8 +106,8 @@ You can always override the defaults with an initializer. Options are as follow:
|
|
106
106
|
|
107
107
|
### Search stategies
|
108
108
|
|
109
|
-
By default, Searchify does a case insensitive search on `name`, `title` and `abbreviation` fields of your models, if they exist.
|
110
|
-
|
109
|
+
By default, Searchify does a case insensitive search on `name`, `title` and `abbreviation` fields of your models, if they exist.
|
110
|
+
To override the default search strategy, just define a class method named `search_strategy` in your model. It should accepts two arguments and returns an array of hash.
|
111
111
|
|
112
112
|
class User < ActiveRecord::Base
|
113
113
|
def self.search_strategy(term, scopes)
|
@@ -123,4 +123,10 @@ a custom search strategy by defining a class method named `search_strategy` in y
|
|
123
123
|
{:label => user.username, :id => resource.id}
|
124
124
|
end
|
125
125
|
end
|
126
|
-
end
|
126
|
+
end
|
127
|
+
|
128
|
+
You may also want to use a per-search search strategy, without affecting the default one. The `search_strategy` option is for you.
|
129
|
+
|
130
|
+
<%= searchify :users, :search_strategy => :my_custom_method %>
|
131
|
+
|
132
|
+
Searchify will then try to call your `User.my_custom_method`. It must accepts two arguments, and still return a hash.
|
@@ -25,16 +25,16 @@ module Searchify
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def extract_search_url(collection,
|
29
|
-
|
28
|
+
def extract_search_url(collection, params=nil, search_strategy=nil)
|
29
|
+
params ||= {}
|
30
30
|
|
31
|
-
url
|
32
|
-
url << "/#{search_strategy}" if search_strategy
|
33
|
-
url << ".json?"
|
31
|
+
url = "#{searchify_path}/search/#{collection}.json?"
|
34
32
|
|
35
|
-
|
33
|
+
params = searchify_scopes.merge(params) if Searchify::Config.scope_awareness
|
36
34
|
|
37
|
-
|
35
|
+
params[:search_strategy] = search_strategy if search_strategy
|
36
|
+
|
37
|
+
url << params.map{ |k,v| "#{k}=#{v}" }.join('&')
|
38
38
|
end
|
39
39
|
|
40
40
|
def extract_select_url(action)
|
@@ -88,13 +88,14 @@ class ActionView::Helpers::FormBuilder
|
|
88
88
|
model_name.to_s.tableize
|
89
89
|
end
|
90
90
|
|
91
|
-
def extract_search_url(collection,
|
92
|
-
|
91
|
+
def extract_search_url(collection, params=nil, search_strategy=nil)
|
92
|
+
params ||= {}
|
93
|
+
|
94
|
+
|
95
|
+
url = "#{@template.searchify_path}/search/#{collection}.json?"
|
96
|
+
params[:search_strategy] = search_strategy if search_strategy
|
93
97
|
|
94
|
-
url
|
95
|
-
url << "/#{search_strategy}" if search_strategy
|
96
|
-
url << ".json?"
|
97
|
-
url << scopes.map{ |k,v| "#{k}=#{v}" }.join('&')
|
98
|
+
url << params.map{ |k,v| "#{k}=#{v}" }.join('&')
|
98
99
|
end
|
99
100
|
|
100
101
|
def extract_model_name(field)
|
data/config/routes.rb
CHANGED
data/lib/searchify/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &20828500 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *20828500
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: jquery-rails
|
27
|
-
requirement: &
|
27
|
+
requirement: &20828040 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *20828040
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: sqlite3
|
38
|
-
requirement: &
|
38
|
+
requirement: &20827600 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *20827600
|
47
47
|
description: Searchify provides a quick way to search your collections.
|
48
48
|
email:
|
49
49
|
- christ.blais@gmail.com
|
@@ -52,51 +52,50 @@ extensions: []
|
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
54
|
- app/helpers/searchify/searchify_helper.rb
|
55
|
-
- app/controllers/searchify/searchify_controller.rb
|
56
55
|
- app/assets/javascripts/searchify/searchify.js
|
56
|
+
- app/controllers/searchify/searchify_controller.rb
|
57
57
|
- config/routes.rb
|
58
|
-
- lib/
|
58
|
+
- lib/tasks/searchify_tasks.rake
|
59
|
+
- lib/searchify.rb
|
59
60
|
- lib/searchify/engine.rb
|
60
61
|
- lib/searchify/controller.rb
|
62
|
+
- lib/searchify/version.rb
|
61
63
|
- lib/searchify/config.rb
|
62
|
-
- lib/searchify.rb
|
63
|
-
- lib/tasks/searchify_tasks.rake
|
64
64
|
- MIT-LICENSE
|
65
65
|
- Rakefile
|
66
66
|
- README.md
|
67
|
-
- test/
|
68
|
-
- test/unit/helpers/searchify/searchify_helper_test.rb
|
67
|
+
- test/test_helper.rb
|
69
68
|
- test/searchify_test.rb
|
69
|
+
- test/integration/navigation_test.rb
|
70
|
+
- test/functional/searchify/searchify_controller_test.rb
|
71
|
+
- test/dummy/script/rails
|
70
72
|
- test/dummy/config/database.yml
|
71
|
-
- test/dummy/config/application.rb
|
72
|
-
- test/dummy/config/environment.rb
|
73
|
-
- test/dummy/config/initializers/session_store.rb
|
74
73
|
- test/dummy/config/initializers/secret_token.rb
|
74
|
+
- test/dummy/config/initializers/inflections.rb
|
75
|
+
- test/dummy/config/initializers/session_store.rb
|
75
76
|
- test/dummy/config/initializers/mime_types.rb
|
76
77
|
- test/dummy/config/initializers/wrap_parameters.rb
|
77
|
-
- test/dummy/config/initializers/inflections.rb
|
78
78
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
79
|
+
- test/dummy/config/application.rb
|
79
80
|
- test/dummy/config/routes.rb
|
80
|
-
- test/dummy/config/
|
81
|
+
- test/dummy/config/environment.rb
|
82
|
+
- test/dummy/config/environments/production.rb
|
81
83
|
- test/dummy/config/environments/development.rb
|
82
84
|
- test/dummy/config/environments/test.rb
|
83
|
-
- test/dummy/config/
|
85
|
+
- test/dummy/config/locales/en.yml
|
84
86
|
- test/dummy/config/boot.rb
|
85
|
-
- test/dummy/Rakefile
|
86
|
-
- test/dummy/config.ru
|
87
87
|
- test/dummy/app/helpers/application_helper.rb
|
88
|
-
- test/dummy/app/controllers/application_controller.rb
|
89
88
|
- test/dummy/app/views/layouts/application.html.erb
|
90
89
|
- test/dummy/app/assets/stylesheets/application.css
|
91
90
|
- test/dummy/app/assets/javascripts/application.js
|
92
|
-
- test/dummy/
|
93
|
-
- test/dummy/
|
91
|
+
- test/dummy/app/controllers/application_controller.rb
|
92
|
+
- test/dummy/Rakefile
|
93
|
+
- test/dummy/config.ru
|
94
94
|
- test/dummy/public/favicon.ico
|
95
|
-
- test/dummy/public/422.html
|
96
95
|
- test/dummy/public/500.html
|
97
|
-
- test/dummy/
|
98
|
-
- test/
|
99
|
-
- test/
|
96
|
+
- test/dummy/public/404.html
|
97
|
+
- test/dummy/public/422.html
|
98
|
+
- test/unit/helpers/searchify/searchify_helper_test.rb
|
100
99
|
homepage: http://github.com/christianblais/searchify
|
101
100
|
licenses: []
|
102
101
|
post_install_message:
|
@@ -122,36 +121,35 @@ signing_key:
|
|
122
121
|
specification_version: 3
|
123
122
|
summary: Search with ease!
|
124
123
|
test_files:
|
125
|
-
- test/
|
126
|
-
- test/unit/helpers/searchify/searchify_helper_test.rb
|
124
|
+
- test/test_helper.rb
|
127
125
|
- test/searchify_test.rb
|
126
|
+
- test/integration/navigation_test.rb
|
127
|
+
- test/functional/searchify/searchify_controller_test.rb
|
128
|
+
- test/dummy/script/rails
|
128
129
|
- test/dummy/config/database.yml
|
129
|
-
- test/dummy/config/application.rb
|
130
|
-
- test/dummy/config/environment.rb
|
131
|
-
- test/dummy/config/initializers/session_store.rb
|
132
130
|
- test/dummy/config/initializers/secret_token.rb
|
131
|
+
- test/dummy/config/initializers/inflections.rb
|
132
|
+
- test/dummy/config/initializers/session_store.rb
|
133
133
|
- test/dummy/config/initializers/mime_types.rb
|
134
134
|
- test/dummy/config/initializers/wrap_parameters.rb
|
135
|
-
- test/dummy/config/initializers/inflections.rb
|
136
135
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
136
|
+
- test/dummy/config/application.rb
|
137
137
|
- test/dummy/config/routes.rb
|
138
|
-
- test/dummy/config/
|
138
|
+
- test/dummy/config/environment.rb
|
139
|
+
- test/dummy/config/environments/production.rb
|
139
140
|
- test/dummy/config/environments/development.rb
|
140
141
|
- test/dummy/config/environments/test.rb
|
141
|
-
- test/dummy/config/
|
142
|
+
- test/dummy/config/locales/en.yml
|
142
143
|
- test/dummy/config/boot.rb
|
143
|
-
- test/dummy/Rakefile
|
144
|
-
- test/dummy/config.ru
|
145
144
|
- test/dummy/app/helpers/application_helper.rb
|
146
|
-
- test/dummy/app/controllers/application_controller.rb
|
147
145
|
- test/dummy/app/views/layouts/application.html.erb
|
148
146
|
- test/dummy/app/assets/stylesheets/application.css
|
149
147
|
- test/dummy/app/assets/javascripts/application.js
|
150
|
-
- test/dummy/
|
151
|
-
- test/dummy/
|
148
|
+
- test/dummy/app/controllers/application_controller.rb
|
149
|
+
- test/dummy/Rakefile
|
150
|
+
- test/dummy/config.ru
|
152
151
|
- test/dummy/public/favicon.ico
|
153
|
-
- test/dummy/public/422.html
|
154
152
|
- test/dummy/public/500.html
|
155
|
-
- test/dummy/
|
156
|
-
- test/
|
157
|
-
- test/
|
153
|
+
- test/dummy/public/404.html
|
154
|
+
- test/dummy/public/422.html
|
155
|
+
- test/unit/helpers/searchify/searchify_helper_test.rb
|
File without changes
|