radiant-sphinx_search-extension 0.9.1 → 0.9.3
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.
- data/VERSION +1 -1
- data/config/locales/en.yml +6 -0
- data/lib/sphinx_search/page_extensions.rb +3 -2
- data/lib/sphinx_search/radius_tags.rb +18 -7
- data/radiant-sphinx_search-extension.gemspec +3 -3
- data/spec/models/page_spec.rb +10 -2
- metadata +4 -4
- data/app/views/admin/pages/_search_toggle.haml +0 -15
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.3
|
@@ -7,8 +7,9 @@ module SphinxSearch
|
|
7
7
|
base.define_index do
|
8
8
|
set_property :delta => true, :group_concat_max_len => SphinxSearch.content_length || 8.kilobytes
|
9
9
|
set_property :field_weights => { 'title' => 100 }
|
10
|
-
indexes title,
|
11
|
-
|
10
|
+
indexes title, :sortable => true
|
11
|
+
indexes parts.content
|
12
|
+
has created_at, updated_at, status_id, virtual
|
12
13
|
end
|
13
14
|
|
14
15
|
base.extend ClassMethods
|
@@ -15,18 +15,18 @@ module SphinxSearch
|
|
15
15
|
desc %{
|
16
16
|
Renders a basic search form. Takes optional @id@ and @class@ values if
|
17
17
|
you need to target the form with specific CSS or JS; also takes an optional
|
18
|
-
@
|
18
|
+
@button@ tag as the label on the input. If for some reason you don't want
|
19
19
|
to use the default search term paramater @q@, you can override this by
|
20
20
|
defining @SphinxSearch.param_name@ in @/config/initializers/sphinx_search.rb@.
|
21
21
|
|
22
22
|
*Usage:*
|
23
23
|
|
24
|
-
<pre><code><r:search:form [id="form-id"] [class="form-class"] [
|
24
|
+
<pre><code><r:search:form [id="form-id"] [class="form-class"] [button="Go"] /></code></pre>
|
25
25
|
}
|
26
26
|
tag 'search:form' do |tag|
|
27
27
|
form_id = tag.attr['id'] || 'search-form'
|
28
28
|
form_class = tag.attr['class'] || 'search-form'
|
29
|
-
form_value = tag.attr['
|
29
|
+
form_value = tag.attr['button'] || I18n.translate('search')
|
30
30
|
form_input = SphinxSearch.param_name || 'q'
|
31
31
|
return <<-HTML
|
32
32
|
<form action="#{tag.globals.page.url}" method="get" id="#{form_id}" class="#{form_class}">
|
@@ -41,9 +41,14 @@ module SphinxSearch
|
|
41
41
|
one result was found. Takes a @paginated@ attribute and all the standard
|
42
42
|
pagination attributes.
|
43
43
|
|
44
|
+
Additional Thinking Sphinx options: @order@ and @sort_mode@ are passed
|
45
|
+
directly to Sphinx. Valid orderable attributes are @created_at@,
|
46
|
+
@updated_at@, @status_id@, @virtual@, and @title@. @sort_mode@ defaults
|
47
|
+
to @asc@ (ascending); to reverse this, use @sort_mode="desc"@.
|
48
|
+
|
44
49
|
*Usage:*
|
45
50
|
|
46
|
-
<pre><code><r:search:results [paginated="false|true"] [per_page="..."] [...other pagination attributes]>...</r:search:results></code></pre>
|
51
|
+
<pre><code><r:search:results [paginated="false|true"] [per_page="..."] [order="..."] [sort_mode="ASC|DESC"] [...other pagination attributes]>...</r:search:results></code></pre>
|
47
52
|
}
|
48
53
|
tag 'search:results' do |tag|
|
49
54
|
options = thinking_sphinx_options(tag)
|
@@ -73,8 +78,12 @@ module SphinxSearch
|
|
73
78
|
<pre><code><r:search:results:count [label="..."] /></code></pre>
|
74
79
|
}
|
75
80
|
tag 'search:results:count' do |tag|
|
76
|
-
|
77
|
-
|
81
|
+
count = tag.globals.results.total_entries
|
82
|
+
if label = tag.attr['label']
|
83
|
+
pluralize count, label
|
84
|
+
else
|
85
|
+
I18n.translate('result', :count => count)
|
86
|
+
end
|
78
87
|
end
|
79
88
|
|
80
89
|
desc %{
|
@@ -159,11 +168,13 @@ module SphinxSearch
|
|
159
168
|
end
|
160
169
|
|
161
170
|
def thinking_sphinx_options(tag)
|
171
|
+
options = tag.attr.symbolize_keys.slice(:order, :sort_mode)
|
172
|
+
[:order, :sort_mode].each { |attr| options[attr] &&= options[attr].to_sym }
|
162
173
|
{
|
163
174
|
:with => { :status_id => 100, :virtual => false },
|
164
175
|
:without => { :class_crc => SphinxSearch.hidden_classes.map(&:to_crc32) },
|
165
176
|
:retry_stale => true
|
166
|
-
}
|
177
|
+
}.merge(options)
|
167
178
|
end
|
168
179
|
end
|
169
180
|
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{radiant-sphinx_search-extension}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Josh French", "Kunal Shah", "Justin Blecher"]
|
12
|
-
s.date = %q{2010-08-
|
12
|
+
s.date = %q{2010-08-14}
|
13
13
|
s.description = %q{Adds fulltext search capability to Radiant content via Thinking Sphinx.}
|
14
14
|
s.email = %q{git@digitalpulp.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
"Rakefile",
|
22
22
|
"VERSION",
|
23
23
|
"app/models/search_page.rb",
|
24
|
-
"
|
24
|
+
"config/locales/en.yml",
|
25
25
|
"db/migrate/20100808155751_add_delta_to_pages.rb",
|
26
26
|
"lib/radiant-sphinx_search-extension.rb",
|
27
27
|
"lib/sphinx_search.rb",
|
data/spec/models/page_spec.rb
CHANGED
@@ -16,10 +16,18 @@ describe Page do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "#thinking_sphinx_options" do
|
19
|
-
|
19
|
+
before do
|
20
|
+
@tag = stub(:tag, :attr => { 'order' => 'title' })
|
21
|
+
end
|
22
|
+
it "should omit hidden classes" do
|
20
23
|
SphinxSearch.hidden_classes = %w(FileNotFoundPage)
|
21
|
-
opts = SearchPage.new.send :thinking_sphinx_options,
|
24
|
+
opts = SearchPage.new.send :thinking_sphinx_options, @tag
|
22
25
|
opts[:without][:class_crc].should include('FileNotFoundPage'.to_crc32)
|
23
26
|
end
|
27
|
+
|
28
|
+
it "should convert Sphinx options to TS format" do
|
29
|
+
opts = SearchPage.new.send :thinking_sphinx_options, @tag
|
30
|
+
opts[:order].should == :title
|
31
|
+
end
|
24
32
|
end
|
25
33
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 3
|
9
|
+
version: 0.9.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Josh French
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-08-
|
19
|
+
date: 2010-08-14 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -59,7 +59,7 @@ files:
|
|
59
59
|
- Rakefile
|
60
60
|
- VERSION
|
61
61
|
- app/models/search_page.rb
|
62
|
-
-
|
62
|
+
- config/locales/en.yml
|
63
63
|
- db/migrate/20100808155751_add_delta_to_pages.rb
|
64
64
|
- lib/radiant-sphinx_search-extension.rb
|
65
65
|
- lib/sphinx_search.rb
|
@@ -1,15 +0,0 @@
|
|
1
|
-
- content_for :page_css do
|
2
|
-
:plain
|
3
|
-
#page-search-status .BoxFix { padding: 4px 0; }
|
4
|
-
|
5
|
-
%tr#page-search-status
|
6
|
-
%th.label Search
|
7
|
-
%td.field
|
8
|
-
.BoxFix
|
9
|
-
%ul.Inputs.HorizList
|
10
|
-
%li
|
11
|
-
= radio_button :page, :searchable, true, :class => 'RadioInput'
|
12
|
-
%label{:for => 'page_searchable_true' } Searchable
|
13
|
-
%li
|
14
|
-
= radio_button :page, :searchable, false, :class => 'RadioInput'
|
15
|
-
%label{:for => 'page_searchable_false' } Invisible to Search
|