Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding internal search engine....

  • Loading branch information...
commit 34ccf18d8058e79dbe7c647fdb9d0d831f1a84d9 1 parent 4861968
erik authored
Showing with 18,627 additions and 8 deletions.
  1. +2 −0  Rakefile
  2. +39 −0 app/controllers/search_controller.rb
  3. +2 −0  app/helpers/search_helper.rb
  4. +11 −1 app/models/news_item.rb
  5. +0 −1  app/models/pitch.rb
  6. +10 −0 app/models/post.rb
  7. +12 −0 app/models/user.rb
  8. +1 −1  app/views/homes/show.html.erb
  9. +3 −1 app/views/layouts/_header.html.erb
  10. +9 −0 app/views/search/_header.html.erb
  11. +9 −0 app/views/search/index.html.erb
  12. +1 −1  app/views/shared/_lists.html.erb
  13. +121 −0 config/development.sphinx.conf
  14. +4 −0 config/routes.rb
  15. +3 −0  deploy/after_restart.rb
  16. +1 −3 deploy/before_restart.rb
  17. +8 −0 test/functional/search_controller_test.rb
  18. +4 −0 test/unit/helpers/search_helper_test.rb
  19. +21 −0 vendor/plugins/thinking-sphinx/Gemfile
  20. +20 −0 vendor/plugins/thinking-sphinx/LICENCE
  21. +184 −0 vendor/plugins/thinking-sphinx/README.textile
  22. +7 −0 vendor/plugins/thinking-sphinx/Rakefile
  23. +1 −0  vendor/plugins/thinking-sphinx/VERSION
  24. +385 −0 vendor/plugins/thinking-sphinx/contribute.rb
  25. +1 −0  vendor/plugins/thinking-sphinx/cucumber.yml
  26. +10 −0 vendor/plugins/thinking-sphinx/features/abstract_inheritance.feature
  27. +27 −0 vendor/plugins/thinking-sphinx/features/alternate_primary_key.feature
  28. +22 −0 vendor/plugins/thinking-sphinx/features/attribute_transformation.feature
  29. +77 −0 vendor/plugins/thinking-sphinx/features/attribute_updates.feature
  30. +67 −0 vendor/plugins/thinking-sphinx/features/deleting_instances.feature
  31. +11 −0 vendor/plugins/thinking-sphinx/features/direct_attributes.feature
  32. +21 −0 vendor/plugins/thinking-sphinx/features/excerpts.feature
  33. +9 −0 vendor/plugins/thinking-sphinx/features/extensible_delta_indexing.feature
  34. +88 −0 vendor/plugins/thinking-sphinx/features/facets.feature
  35. +29 −0 vendor/plugins/thinking-sphinx/features/facets_across_model.feature
  36. +18 −0 vendor/plugins/thinking-sphinx/features/field_sorting.feature
  37. +92 −0 vendor/plugins/thinking-sphinx/features/handling_edits.feature
  38. +24 −0 vendor/plugins/thinking-sphinx/features/retry_stale_indexes.feature
  39. +20 −0 vendor/plugins/thinking-sphinx/features/searching_across_models.feature
  40. +40 −0 vendor/plugins/thinking-sphinx/features/searching_by_index.feature
  41. +168 −0 vendor/plugins/thinking-sphinx/features/searching_by_model.feature
  42. +56 −0 vendor/plugins/thinking-sphinx/features/searching_with_find_arguments.feature
  43. +25 −0 vendor/plugins/thinking-sphinx/features/sphinx_detection.feature
  44. +68 −0 vendor/plugins/thinking-sphinx/features/sphinx_scopes.feature
  45. +16 −0 vendor/plugins/thinking-sphinx/features/step_definitions/alpha_steps.rb
  46. +7 −0 vendor/plugins/thinking-sphinx/features/step_definitions/beta_steps.rb
  47. +197 −0 vendor/plugins/thinking-sphinx/features/step_definitions/common_steps.rb
  48. +7 −0 vendor/plugins/thinking-sphinx/features/step_definitions/extensible_delta_indexing_steps.rb
  49. +96 −0 vendor/plugins/thinking-sphinx/features/step_definitions/facet_steps.rb
  50. +36 −0 vendor/plugins/thinking-sphinx/features/step_definitions/find_arguments_steps.rb
  51. +15 −0 vendor/plugins/thinking-sphinx/features/step_definitions/gamma_steps.rb
  52. +19 −0 vendor/plugins/thinking-sphinx/features/step_definitions/scope_steps.rb
  53. +94 −0 vendor/plugins/thinking-sphinx/features/step_definitions/search_steps.rb
  54. +35 −0 vendor/plugins/thinking-sphinx/features/step_definitions/sphinx_steps.rb
  55. +19 −0 vendor/plugins/thinking-sphinx/features/sti_searching.feature
  56. +19 −0 vendor/plugins/thinking-sphinx/features/support/env.rb
  57. +8 −0 vendor/plugins/thinking-sphinx/features/support/lib/generic_delta_handler.rb
  58. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/database.example.yml
  59. +1 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/.gitignore
  60. +10 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/alphas.rb
  61. +1 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/authors.rb
  62. +11 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/betas.rb
  63. +9 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/boxes.rb
  64. +1 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/categories.rb
  65. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/cats.rb
  66. +24 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/comments.rb
  67. +31 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/developers.rb
  68. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/dogs.rb
  69. +10 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/extensible_betas.rb
  70. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/foxes.rb
  71. +10 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/gammas.rb
  72. +4 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/music.rb
  73. +1,001 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/people.rb
  74. +6 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/posts.rb
  75. +14 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/robots.rb
  76. +27 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/fixtures/tags.rb
  77. +8 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_alphas.rb
  78. +5 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_animals.rb
  79. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_authors.rb
  80. +6 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_authors_posts.rb
  81. +5 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_betas.rb
  82. +5 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_boxes.rb
  83. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_categories.rb
  84. +10 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_comments.rb
  85. +7 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_developers.rb
  86. +5 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_extensible_betas.rb
  87. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_gammas.rb
  88. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_genres.rb
  89. +6 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_music.rb
  90. +13 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_people.rb
  91. +5 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_posts.rb
  92. +4 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_robots.rb
  93. +5 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_taggings.rb
  94. +4 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/db/migrations/create_tags.rb
  95. +23 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/alpha.rb
  96. +17 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/andrew.rb
  97. +5 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/animal.rb
  98. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/author.rb
  99. +8 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/beta.rb
  100. +8 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/box.rb
  101. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/cat.rb
  102. +4 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/category.rb
  103. +10 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/comment.rb
  104. +20 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/developer.rb
  105. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/dog.rb
  106. +9 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/extensible_beta.rb
  107. +5 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/fox.rb
  108. +5 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/gamma.rb
  109. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/genre.rb
  110. +5 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/medium.rb
  111. +8 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/music.rb
  112. +24 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/person.rb
  113. +21 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/post.rb
  114. +12 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/robot.rb
  115. +3 −0  vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/tag.rb
  116. +4 −0 vendor/plugins/thinking-sphinx/features/thinking_sphinx/models/tagging.rb
  117. +28 −0 vendor/plugins/thinking-sphinx/ginger_scenarios.rb
  118. +5 −0 vendor/plugins/thinking-sphinx/init.rb
  119. +5 −0 vendor/plugins/thinking-sphinx/install.rb
  120. +12 −0 vendor/plugins/thinking-sphinx/lib/cucumber/thinking_sphinx/external_world.rb
  121. +127 −0 vendor/plugins/thinking-sphinx/lib/cucumber/thinking_sphinx/internal_world.rb
  122. +20 −0 vendor/plugins/thinking-sphinx/lib/cucumber/thinking_sphinx/sql_logger.rb
  123. +1 −0  vendor/plugins/thinking-sphinx/lib/thinking-sphinx.rb
  124. +255 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx.rb
  125. +386 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/active_record.rb
  126. +52 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/active_record/attribute_updates.rb
  127. +61 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/active_record/delta.rb
  128. +36 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/active_record/has_many_association.rb
  129. +21 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/active_record/has_many_association_with_scopes.rb
  130. +93 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/active_record/scopes.rb
  131. +87 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/adapters/abstract_adapter.rb
  132. +58 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/adapters/mysql_adapter.rb
  133. +153 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/adapters/postgresql_adapter.rb
  134. +164 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/association.rb
  135. +385 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/attribute.rb
  136. +24 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/auto_version.rb
  137. +44 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/bundled_search.rb
  138. +16 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/class_facet.rb
  139. +323 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/configuration.rb
  140. +76 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/context.rb
  141. +7 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/core/array.rb
  142. +15 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/core/string.rb
  143. +28 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/deltas.rb
  144. +62 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/deltas/default_delta.rb
  145. +101 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/deploy/capistrano.rb
  146. +22 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/excerpter.rb
  147. +128 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/facet.rb
  148. +166 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/facet_search.rb
  149. +82 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/field.rb
  150. +157 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/index.rb
  151. +302 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/index/builder.rb
  152. +118 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/index/faux_column.rb
  153. +37 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/join.rb
  154. +186 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/property.rb
  155. +150 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/rails_additions.rb
  156. +933 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search.rb
  157. +439 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/search_methods.rb
  158. +163 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/source.rb
  159. +46 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/source/internal_properties.rb
  160. +146 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/source/sql.rb
  161. +133 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/tasks.rb
  162. +55 −0 vendor/plugins/thinking-sphinx/lib/thinking_sphinx/test.rb
  163. +16 −0 vendor/plugins/thinking-sphinx/rails/init.rb
  164. +3 −0  vendor/plugins/thinking-sphinx/recipes/thinking_sphinx.rb
  165. +3 −0  vendor/plugins/thinking-sphinx/spec/fixtures/database.yml.default
  166. +157 −0 vendor/plugins/thinking-sphinx/spec/fixtures/models.rb
  167. +58 −0 vendor/plugins/thinking-sphinx/spec/spec_helper.rb
  168. +81 −0 vendor/plugins/thinking-sphinx/spec/sphinx_helper.rb
  169. +128 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/active_record/delta_spec.rb
  170. +72 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/active_record/has_many_association_spec.rb
  171. +176 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/active_record/scopes_spec.rb
  172. +618 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/active_record_spec.rb
  173. +145 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/adapters/abstract_adapter_spec.rb
  174. +239 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/association_spec.rb
  175. +557 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/attribute_spec.rb
  176. +55 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/auto_version_spec.rb
  177. +295 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/configuration_spec.rb
  178. +127 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/context_spec.rb
  179. +9 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/core/array_spec.rb
  180. +9 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/core/string_spec.rb
  181. +49 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/excerpter_spec.rb
  182. +170 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/facet_search_spec.rb
  183. +347 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/facet_spec.rb
  184. +124 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/field_spec.rb
  185. +495 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/index/builder_spec.rb
  186. +36 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/index/faux_column_spec.rb
  187. +183 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/index_spec.rb
  188. +203 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/rails_additions_spec.rb
  189. +156 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/search_methods_spec.rb
  190. +1,376 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/search_spec.rb
  191. +253 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/source_spec.rb
  192. +20 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx/test_spec.rb
  193. +204 −0 vendor/plugins/thinking-sphinx/spec/thinking_sphinx_spec.rb
  194. +34 −0 vendor/plugins/thinking-sphinx/tasks/distribution.rb
  195. +1 −0  vendor/plugins/thinking-sphinx/tasks/rails.rake
  196. +80 −0 vendor/plugins/thinking-sphinx/tasks/testing.rb
  197. +254 −0 vendor/plugins/thinking-sphinx/thinking-sphinx.gemspec
  198. +1 −0  vendor/plugins/thinking-sphinx/vendor/after_commit/.gitignore
  199. +70 −0 vendor/plugins/thinking-sphinx/vendor/after_commit/lib/after_commit.rb
  200. +123 −0 vendor/plugins/thinking-sphinx/vendor/after_commit/lib/after_commit/active_record.rb
  201. +172 −0 vendor/plugins/thinking-sphinx/vendor/after_commit/lib/after_commit/connection_adapters.rb
  202. +30 −0 vendor/plugins/thinking-sphinx/vendor/after_commit/lib/after_commit/test_bypass.rb
  203. +53 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle.rb
  204. +1 −0  vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/0.9.8.rb
  205. +7 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/0.9.9.rb
  206. +49 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/0.9.9/client.rb
  207. +22 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/0.9.9/client/filter.rb
  208. +28 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/0.9.9/configuration/searchd.rb
  209. +5 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/1.10.rb
  210. +28 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/1.10/client.rb
  211. +13 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/auto_version.rb
  212. +801 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/client.rb
  213. +62 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/client/filter.rb
  214. +70 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/client/message.rb
  215. +94 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/client/response.rb
  216. +34 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration.rb
  217. +49 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration/distributed_index.rb
  218. +150 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration/index.rb
  219. +20 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration/indexer.rb
  220. +39 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration/realtime_index.rb
  221. +17 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration/remote_index.rb
  222. +30 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration/searchd.rb
  223. +57 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration/section.rb
  224. +23 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration/source.rb
  225. +48 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration/sql_source.rb
  226. +29 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/configuration/xml_source.rb
  227. +87 −0 vendor/plugins/thinking-sphinx/vendor/riddle/lib/riddle/controller.rb
View
2  Rakefile
@@ -8,6 +8,7 @@ require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
+require 'thinking_sphinx/tasks'
desc "Copy application sample config for dev/test purposes"
task :copy_sample_config do
@@ -23,3 +24,4 @@ task :copy_sample_config do
end
task :environment => :copy_sample_config
+
View
39 app/controllers/search_controller.rb
@@ -0,0 +1,39 @@
+class SearchController < ApplicationController
+
+ def index
+
+ if params[:q]
+ redirect_to "/search/#{URI.encode(params[:q])}"
+ return
+ end
+
+ @tab = params[:tab] ? params[:tab] : "unfunded"
+ @search_term = URI.encode(params[:search_term] || params[:q] || "")
+ @page = params[:page] ? params[:page] : 1
+
+ conditions = {}
+
+ if @tab == "unfunded"
+ Pitch.per_page = 9
+ @items = Pitch.search @search_term, :order => :created_at, :sort_mode => :desc, :conditions => conditions, :page => @page, :per_page=>9, :retry_stale => true
+ @template_name = 'pitches/pitch'
+ elsif @tab == "published"
+ Story.per_page = 9
+ @items = Story.search @search_term, :order => :created_at, :sort_mode => :desc, :conditions => conditions, :page => @page, :per_page=>9, :retry_stale => true
+ @template_name = 'stories/story'
+ elsif @tab == "updates"
+ Post.per_page = 9
+ @items = Post.search @search_term, :order => :created_at, :sort_mode => :desc, :conditions => conditions, :page => @page, :per_page=>9, :retry_stale => true
+ @template_name = 'posts/post'
+ elsif @tab == "community"
+ User.per_page = 9
+ @items = User.search @search_term, :order => :created_at, :sort_mode => :desc, :conditions => conditions, :page => @page, :per_page=>9, :retry_stale => true
+ @template_name = 'users/user'
+ else
+ Pitch.per_page = 9
+ @items = Pitch.search @search_term, :order => :created_at, :sort_mode => :desc, :conditions => conditions, :page => @page, :per_page=>9, :retry_stale => true
+ @template_name = 'pitches/pitch'
+ end
+ end
+
+end
View
2  app/helpers/search_helper.rb
@@ -0,0 +1,2 @@
+module SearchHelper
+end
View
12 app/models/news_item.rb
@@ -102,7 +102,17 @@ class NewsItem < ActiveRecord::Base
validates_attachment_size :featured_image, :in => 1..5.megabytes, :unless => :featured_image_name
end
-
+
+ define_index do
+ indexes headline, :sortable => true
+ indexes slug, :sortable => true
+ indexes excerpt, :sortable => true
+ indexes short_description, :sortable => true
+ indexes extended_description, :sortable => true
+
+ has user_id, created_at, updated_at
+ end
+
named_scope :newest, :include => :user, :order => 'news_items.created_at DESC'
named_scope :featured, :conditions => {:feature => true}, :order => "news_items.created_at desc"
View
1  app/models/pitch.rb
@@ -132,7 +132,6 @@ def unapproved
after_create :send_admin_notification, :create_peer_editor_assignment
after_save :check_if_funded_state, :dispatch_fact_checker
-
named_scope :most_funded, :order => 'news_items.current_funding DESC'
named_scope :sorted, lambda {|direction| { :order => "news_items.created_at #{direction}" } }
View
10 app/models/post.rb
@@ -5,6 +5,9 @@ class Post < ActiveRecord::Base
include ActionController::UrlWriter
include Utils
+ cattr_accessor :per_page
+ @@per_page = 10
+
belongs_to :pitch
belongs_to :user
@@ -37,6 +40,13 @@ class Post < ActiveRecord::Base
#end
validates_presence_of :title, :body, :user, :pitch
+ define_index do
+ indexes title, :sortable => true
+ indexes body, :sortable => true
+
+ has user_id, created_at, updated_at
+ end
+
def blog_image_name
blog_image_file_name.blank?
end
View
12 app/models/user.rb
@@ -50,6 +50,9 @@ class User < ActiveRecord::Base
TYPES = ["Citizen", "Reporter", "Organization", "Admin", "Sponsor"]
CREATABLE_TYPES = TYPES - ["Admin"]
+ cattr_accessor :per_page
+ @@per_page = 10
+
aasm_column :status
aasm_state :inactive
aasm_state :active
@@ -164,6 +167,15 @@ def tip_sum(tip)
named_scope :unapproved_news_orgs, :conditions => {:status => 'needs_approval'}
named_scope :sponsors_and_admins, :conditions => 'type="Admin" OR type="Sponsor"'
+ define_index do
+ indexes about_you, :sortable => true
+ indexes first_name, :sortable => true
+ indexes last_name, :sortable => true
+ indexes organization_name, :sortable => true
+
+ has created_at, updated_at
+ end
+
def self.opt_in_defaults
{ :notify_blog_posts => true,
:notify_comments => true,
View
2  app/views/homes/show.html.erb
@@ -5,4 +5,4 @@
<li <%if @filter=='published'%>class="current"<%end%>><a href="/published">Published</a></li>
<li <%if @filter=='updates'%>class="current"<%end%>><a href="/updates">Updates</a></li>
</ul>
-<%= render :partial => "shared/lists", :locals => {:items => @items} %>
+<%= render :partial => "shared/lists", :locals => {:items => @items, :no_items_message => "No stories found for this selection.", :show_pagination => false} %>
View
4 app/views/layouts/_header.html.erb
@@ -10,7 +10,9 @@
<ul class="rightHeaderContainer">
<li>
<div class="searchBox">
- <input type="text" />
+ <% form_tag(search_path, :method => "post") do %>
+ <%= text_field_tag(:q) %>
+ <% end %>
</div>
</li><!--end searchBox-->
<li>
View
9 app/views/search/_header.html.erb
@@ -0,0 +1,9 @@
+<div class="headerTitle">
+ <h1>You searched for<%if @search_term%>: <%= @search_term %><%end%></h1>
+ <%unless @items.empty?%>
+ <p>Your search return <%=@items.total_entries%> entries.</p>
+ <%end%>
+</div>
+<div class="joinContainer">
+ <a href="/stories/unfunded" title='About Sponsorships' id='help_about-questionnaires'>About Sponsorships</a>
+</div>
View
9 app/views/search/index.html.erb
@@ -0,0 +1,9 @@
+<% @title = "Spot.us - Search" %>
+
+<ul class="tabs">
+ <li <%if @tab=='unfunded'%>class="current"<%end%>><a href="/search/<%=@search_term%>/unfunded">Unfunded</a></li>
+ <li <%if @tab=='published'%>class="current"<%end%>><a href="/search/<%=@search_term%>/published">Published</a></li>
+ <li <%if @tab=='updates'%>class="current"<%end%>><a href="/search/<%=@search_term%>/updates">Updates</a></li>
+ <li <%if @tab=='community'%>class="current"<%end%>><a href="/search/<%=@search_term%>/updates">Community</a></li>
+</ul>
+<%= render :partial => "shared/lists", :locals => {:items => @items, :template_name => @template_name, :no_items_message => "No stories found for your search."} %>
View
2  app/views/shared/_lists.html.erb
@@ -10,5 +10,5 @@
<%= render :collection => items, :partial => template_name %>
<% end %>
</ul>
- <%= will_paginate items if defined?(show_pagination) && show_pagination%>
+ <%= will_paginate items if !defined?(show_pagination) || show_pagination%>
<%end%>
View
121 config/development.sphinx.conf
@@ -0,0 +1,121 @@
+indexer
+{
+}
+
+searchd
+{
+ address = 127.0.0.1
+ port = 9312
+ log = /Users/eriks/spotus/code/spot-us/log/searchd.log
+ query_log = /Users/eriks/spotus/code/spot-us/log/searchd.query.log
+ pid_file = /Users/eriks/spotus/code/spot-us/log/searchd.development.pid
+}
+
+source news_item_core_0
+{
+ type = mysql
+ sql_host = localhost
+ sql_user = root
+ sql_pass =
+ sql_db = spotus_development
+ sql_query_pre = SET NAMES utf8
+ sql_query_pre = SET TIME_ZONE = '+0:00'
+ sql_query = SELECT SQL_NO_CACHE `news_items`.`id` * 3 + 0 AS `id` , `news_items`.`headline` AS `headline`, `news_items`.`slug` AS `slug`, `news_items`.`excerpt` AS `excerpt`, `news_items`.`short_description` AS `short_description`, `news_items`.`extended_description` AS `extended_description`, `news_items`.`id` AS `sphinx_internal_id`, CASE IFNULL(`news_items`.`type`, '') WHEN 'Story' THEN 714550076 WHEN 'Pitch' THEN 3864957405 WHEN 'Tip' THEN 1892613804 ELSE 3062079150 END AS `class_crc`, 0 AS `sphinx_deleted`, IFNULL(`news_items`.`headline`, '') AS `headline_sort`, IFNULL(`news_items`.`slug`, '') AS `slug_sort`, IFNULL(`news_items`.`excerpt`, '') AS `excerpt_sort`, IFNULL(`news_items`.`short_description`, '') AS `short_description_sort`, IFNULL(`news_items`.`extended_description`, '') AS `extended_description_sort`, `news_items`.`user_id` AS `user_id`, UNIX_TIMESTAMP(`news_items`.`created_at`) AS `created_at`, UNIX_TIMESTAMP(`news_items`.`updated_at`) AS `updated_at` FROM `news_items` WHERE `news_items`.`id` >= $start AND `news_items`.`id` <= $end GROUP BY `news_items`.`id`, `news_items`.`type` ORDER BY NULL
+ sql_query_range = SELECT IFNULL(MIN(`id`), 1), IFNULL(MAX(`id`), 1) FROM `news_items`
+ sql_attr_uint = sphinx_internal_id
+ sql_attr_uint = class_crc
+ sql_attr_uint = sphinx_deleted
+ sql_attr_uint = user_id
+ sql_attr_timestamp = created_at
+ sql_attr_timestamp = updated_at
+ sql_attr_str2ordinal = headline_sort
+ sql_attr_str2ordinal = slug_sort
+ sql_attr_str2ordinal = excerpt_sort
+ sql_attr_str2ordinal = short_description_sort
+ sql_attr_str2ordinal = extended_description_sort
+ sql_query_info = SELECT * FROM `news_items` WHERE `id` = (($id - 0) / 3)
+}
+
+index news_item_core
+{
+ source = news_item_core_0
+ path = /Users/eriks/spotus/code/spot-us/db/sphinx/development/news_item_core
+ charset_type = utf-8
+}
+
+index news_item
+{
+ type = distributed
+ local = news_item_core
+}
+
+source post_core_0
+{
+ type = mysql
+ sql_host = localhost
+ sql_user = root
+ sql_pass =
+ sql_db = spotus_development
+ sql_query_pre = SET NAMES utf8
+ sql_query_pre = SET TIME_ZONE = '+0:00'
+ sql_query = SELECT SQL_NO_CACHE `posts`.`id` * 3 + 1 AS `id` , `posts`.`title` AS `title`, `posts`.`body` AS `body`, `posts`.`id` AS `sphinx_internal_id`, 4206412723 AS `class_crc`, 0 AS `sphinx_deleted`, IFNULL(`posts`.`title`, '') AS `title_sort`, IFNULL(`posts`.`body`, '') AS `body_sort`, `posts`.`user_id` AS `user_id`, UNIX_TIMESTAMP(`posts`.`created_at`) AS `created_at`, UNIX_TIMESTAMP(`posts`.`updated_at`) AS `updated_at` FROM `posts` WHERE `posts`.`id` >= $start AND `posts`.`id` <= $end GROUP BY `posts`.`id` ORDER BY NULL
+ sql_query_range = SELECT IFNULL(MIN(`id`), 1), IFNULL(MAX(`id`), 1) FROM `posts`
+ sql_attr_uint = sphinx_internal_id
+ sql_attr_uint = class_crc
+ sql_attr_uint = sphinx_deleted
+ sql_attr_uint = user_id
+ sql_attr_timestamp = created_at
+ sql_attr_timestamp = updated_at
+ sql_attr_str2ordinal = title_sort
+ sql_attr_str2ordinal = body_sort
+ sql_query_info = SELECT * FROM `posts` WHERE `id` = (($id - 1) / 3)
+}
+
+index post_core
+{
+ source = post_core_0
+ path = /Users/eriks/spotus/code/spot-us/db/sphinx/development/post_core
+ charset_type = utf-8
+}
+
+index post
+{
+ type = distributed
+ local = post_core
+}
+
+source user_core_0
+{
+ type = mysql
+ sql_host = localhost
+ sql_user = root
+ sql_pass =
+ sql_db = spotus_development
+ sql_query_pre = SET NAMES utf8
+ sql_query_pre = SET TIME_ZONE = '+0:00'
+ sql_query = SELECT SQL_NO_CACHE `users`.`id` * 3 + 2 AS `id` , `users`.`about_you` AS `about_you`, `users`.`first_name` AS `first_name`, `users`.`last_name` AS `last_name`, `users`.`organization_name` AS `organization_name`, `users`.`id` AS `sphinx_internal_id`, CASE IFNULL(`users`.`type`, '') WHEN 'Reporter' THEN 2409661092 WHEN 'Admin' THEN 1238311538 WHEN 'Sponsor' THEN 1311895624 WHEN 'Organization' THEN 3655317636 WHEN 'Citizen' THEN 1726885557 ELSE 765557111 END AS `class_crc`, 0 AS `sphinx_deleted`, IFNULL(`users`.`about_you`, '') AS `about_you_sort`, IFNULL(`users`.`first_name`, '') AS `first_name_sort`, IFNULL(`users`.`last_name`, '') AS `last_name_sort`, IFNULL(`users`.`organization_name`, '') AS `organization_name_sort`, UNIX_TIMESTAMP(`users`.`created_at`) AS `created_at`, UNIX_TIMESTAMP(`users`.`updated_at`) AS `updated_at` FROM `users` WHERE `users`.`id` >= $start AND `users`.`id` <= $end GROUP BY `users`.`id`, `users`.`type` ORDER BY NULL
+ sql_query_range = SELECT IFNULL(MIN(`id`), 1), IFNULL(MAX(`id`), 1) FROM `users`
+ sql_attr_uint = sphinx_internal_id
+ sql_attr_uint = class_crc
+ sql_attr_uint = sphinx_deleted
+ sql_attr_timestamp = created_at
+ sql_attr_timestamp = updated_at
+ sql_attr_str2ordinal = about_you_sort
+ sql_attr_str2ordinal = first_name_sort
+ sql_attr_str2ordinal = last_name_sort
+ sql_attr_str2ordinal = organization_name_sort
+ sql_query_info = SELECT * FROM `users` WHERE `id` = (($id - 2) / 3)
+}
+
+index user_core
+{
+ source = user_core_0
+ path = /Users/eriks/spotus/code/spot-us/db/sphinx/development/user_core
+ charset_type = utf-8
+}
+
+index user
+{
+ type = distributed
+ local = user_core
+}
View
4 config/routes.rb
@@ -1,5 +1,9 @@
ActionController::Routing::Routes.draw do |map|
map.root :controller => 'homes', :action => 'show'
+
+ map.search '/search', :controller => 'search', :action => "index"
+ map.connect "/search/:search_term/:tab", :controller=>"search", :action => "index", :tab=>nil
+
map.connect ":filter.:format", :controller => "homes", :action => "show", :requirements => {:filter=>/#{FILTERS_STORIES_STRING}/}
map.start_story 'start_story', :controller => 'homes', :action => "start_story"
map.categories 'networks/:id/categories', :controller => 'networks', :action => 'categories'
View
3  deploy/after_restart.rb
@@ -0,0 +1,3 @@
+sudo "cd #{current_path} && rake ts:stop"
+sudo "cd #{current_path} && rake ts:index"
+sudo "cd #{current_path} && rake ts:start"
View
4 deploy/before_restart.rb
@@ -2,6 +2,4 @@
run "ln -nfs #{shared_path}/config/newrelic.yml #{release_path}/config/newrelic.yml"
run "ln -nfs #{shared_path}/config/s3.yml #{release_path}/config/s3.yml"
run "ln -nfs #{shared_path}/config/facebooker.yml #{release_path}/config/facebooker.yml"
-#run "sudo /etc/init.d/memcached restart"
-
-
+#run "sudo /etc/init.d/memcached restart"
View
8 test/functional/search_controller_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class SearchControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
View
4 test/unit/helpers/search_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class SearchHelperTest < ActionView::TestCase
+end
View
21 vendor/plugins/thinking-sphinx/Gemfile
@@ -0,0 +1,21 @@
+source 'http://rubygems.org'
+
+gem 'activerecord', '>= 1.15.6', '< 3.0.0'
+gem 'riddle', '>= 1.2.2'
+gem 'after_commit', '>= 1.0.7'
+
+group :development do
+ gem 'mysql', '2.8.1'
+ gem 'pg', '0.9.0'
+ gem 'jeweler', '1.5.1'
+ gem 'yard', '0.6.1'
+ gem 'rspec', '2.0.1'
+ gem 'rspec-core', '2.0.1'
+ gem 'rspec-expectations', '2.0.1'
+ gem 'rspec-mocks', '2.0.1'
+ gem 'rcov', '0.9.8'
+ gem 'cucumber', '0.9.4'
+ gem 'will_paginate', '2.3.15'
+ gem 'ginger', '1.2.0'
+ gem 'faker', '0.3.1'
+end
View
20 vendor/plugins/thinking-sphinx/LICENCE
@@ -0,0 +1,20 @@
+Copyright (c) 2008 Pat Allan
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
184 vendor/plugins/thinking-sphinx/README.textile
@@ -0,0 +1,184 @@
+h1. Thinking Sphinx
+
+h2. Usage
+
+First, if you haven't done so already, check out the main "usage":http://ts.freelancing-gods.com/usage.html page. Once you've done that, the next place to look for information is the specific method docs - ThinkingSphinx::Search and ThinkingSphinx::Index::Builder in particular.
+
+Keep in mind that while Thinking Sphinx works for ActiveRecord with Merb, it doesn't yet support DataMapper (although that is planned).
+
+h2. Contributing
+
+Fork on GitHub and after you've committed tested patches, send a pull request.
+
+To quickly see if your system is ready to run the thinking sphinx specs, run the contribute.rb script found in the project root directory. Use the following instructions to install any missing requirements.
+
+To get the spec suite running, you will need to install the ginger gem:
+
+<pre><code>sudo gem install ginger --source http://gemcutter.org</code></pre>
+
+Then install the cucumber, yard, jeweler and rspec gems. Make sure you have a git install version 1.6.0.0 or higher, otherwise the jeweler gem won't install. Bluecloth is required for some of the yard documentation.
+
+<pre>
+ sudo gem install bluecloth cucumber yard jeweler rspec
+</pre>
+
+Then set up your database:
+
+<pre>
+ cp spec/fixtures/database.yml.default spec/fixtures/database.yml &&
+ mysqladmin -u root create thinking_sphinx
+</pre>
+
+This last step can be done automatically by the contribute.rb script if all dependencies are met.
+
+Make sure you don't have another Sphinx daemon (searchd) running. If you do, quit it with "rake ts:stop"
+in the app root.
+
+You should now have a passing test suite from which to build your patch on.
+
+<pre>
+ rake spec
+</pre>
+
+If you get the message "Failed to start searchd daemon", run the spec with sudo:
+
+<pre>
+ sudo rake spec
+</pre>
+
+If you quit the spec suite before it's completed, you may be left with data in the test
+database, causing the next run to have failures. Let that run complete and then try again.
+
+h2. Contributors
+
+Since I first released this library, there's been quite a few people who have submitted patches, to my immense gratitude. Others have suggested syntax changes and general improvements. So my thanks to the following people:
+
+* Joost Hietbrink
+* Jonathan Conway
+* Gregory Mirzayantz
+* Tung Nguyen
+* Sean Cribbs
+* Benoit Caccinolo
+* John Barton
+* Oliver Beddows
+* Arthur Zapparoli
+* Dusty Doris
+* Marcus Crafter
+* Patrick Lenz
+* Björn Andreasson
+* James Healy
+* Jae-Jun Hwang
+* Xavier Shay
+* Jason Rust
+* Gopal Patel
+* Chris Heald
+* Peter Vandenberk
+* Josh French
+* Andrew Bennett
+* Jordan Fowler
+* Seth Walker
+* Joe Noon
+* Wolfgang Postler
+* Rick Olson
+* Killian Murphy
+* Morten Primdahl
+* Ryan Bates
+* David Eisinger
+* Shay Arnett
+* Minh Tran
+* Jeremy Durham
+* Piotr Sarnacki
+* Matt Johnson
+* Nicolas Blanco
+* Max Lapshin
+* Josh Natanson
+* Philip Hallstrom
+* Christian Rishøj
+* Mike Flester
+* Jim Remsik
+* Kennon Ballou
+* Henrik Nyh
+* Emil Tin
+* Doug Cole
+* Ed Hickey
+* Evan Weaver
+* Thibaut Barrere
+* Kristopher Chambers
+* Dmitrij Smalko
+* Aleksey Yeschenko
+* Lachie Cox
+* Lourens Naude
+* Tom Davies
+* Dan Pickett
+* Alex Caudill
+* Jim Benton
+* John Aughey
+* Keith Pitty
+* Jeff Talbot
+* Dana Contreras
+* Menno van der Sman
+* Bill Harding
+* Isaac Feliu
+* Andrei Bocan
+* László Bácsi
+* Peter Wagenet
+* Max Lapshin
+* Martin Emde
+* David Wennergren
+* Mark Lane
+* Eric Lindvall
+* Lawrence Pit
+* Mike Bailey
+* Bill Leeper
+* Michael Reinsch
+* Anderson Dias
+* Jerome Riga
+* Tien Dung
+* Johannes Kaefer
+* Paul Campbell
+* Matthew Beale
+* Tom Simnett
+* Erik Ostrom
+* Ole Riesenberg
+* Josh Kalderimis
+* J.D. Hollis
+* Jeffrey Chupp
+* Rob Anderton
+* Zach Inglis
+* Ward Bekker
+* Brian Terlson
+* Christian Aust
+* Martin Sarasale
+* Édouard Brière
+* Steve Madsen
+* Justin DeWind
+* Chris Z
+* Chris Roos
+* Andrew Assarattanakul
+* Jonas von Andrian
+* Dimitri Krassovski
+* Sergey Kojin
+* Brad Sumersford
+* Amir Yalon
+* Edgars Beigarts
+* Ivan Ukhov
+* Tomáš Pospíšek
+* Tom Stuart
+* James Brooks
+* Mark Dodwell
+* Frédéric Malamitsas
+* Jon Gubman
+* Michael Schuerig
+* Ben Hutton
+* Alfonso Jiménez
+* Szymon Nowak
+* Keith Pitt
+* Lee Capps
+* Sam Goldstein
+* Matt Todd
+* Paco Guzmán
+* Marcin Stecki
+* Robert Glaser
+* Paul Schyska
+* Kirill Maximov
+* Hans Hasselberg
View
7 vendor/plugins/thinking-sphinx/Rakefile
@@ -0,0 +1,7 @@
+require 'rubygems'
+require 'bundler'
+
+Bundler.require :default, :development
+
+require "#{File.dirname(__FILE__)}/tasks/distribution"
+require "#{File.dirname(__FILE__)}/tasks/testing"
View
1  vendor/plugins/thinking-sphinx/VERSION
@@ -0,0 +1 @@
+1.4.3
View
385 vendor/plugins/thinking-sphinx/contribute.rb
@@ -0,0 +1,385 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
+require 'yaml'
+require 'pp'
+
+begin
+ require 'Win32/Console/ANSI' if RUBY_PLATFORM =~ /mswin/
+rescue LoadError
+end
+
+require 'optparse'
+
+options = {}
+OptionParser.new do |opts|
+ opts.banner = "Usage: example.rb [options]"
+
+ opts.on("-g [NAME]", "--ginger [NAME]", "Ginger gem name") do |name|
+ options[:ginger] = name
+ end
+
+ opts.on("-s [NAME]", "--sphinx [NAME]", "Sphinx daemon name") do |name|
+ options[:sphinx] = name
+ end
+end.parse!
+
+OPTIONS = options
+
+module ContributeHelper; end
+
+class Contribute
+ include ContributeHelper
+
+ def dependencies
+ [
+ Dependencies::Sphinx,
+ Dependencies::Mysql,
+ Dependencies::AR,
+ Dependencies::Rspec,
+ Dependencies::Cucumber,
+ Dependencies::Yard,
+ Dependencies::Jeweler,
+ Dependencies::Ginger,
+ ]
+ end
+
+ def show
+ show_welcome_screen
+
+ (
+ check_for_dependencies &&
+ create_database_yaml &&
+ check_mysql_is_working &&
+ create_test_database
+ ) || exit(1)
+
+ show_done_screen
+ end
+
+private
+WELCOME_SCREEN = <<-EO_WELCOME
+<banner>Thinking Sphinx Contribution</banner>
+
+Thanks for contributing to Thinking Sphinx.
+
+In this script we'll help you get setup to hack:
+
+ <b>1.</b> We'll check that you have the right software installed and running.
+ <b>2.</b> We'll set up the test database for specs to run against.
+
+EO_WELCOME
+
+DONE_SCREEN = <<-EO_DONE
+<banner>Setup done!</banner>
+
+All done! Now you can start hacking by running
+
+ <b>rake spec</b>
+
+EO_DONE
+
+REVIEW_YAML = <<-EO_REVIEW_YAML
+
+Please review the database details in the yaml file details before continuing.
+
+This file is used by the specs to connect to the database.
+
+Current details:
+EO_REVIEW_YAML
+
+
+
+MYSQL_FAILED = <<-EO_MYSQL_FAILED
+
+Looks like we couldn't successfully talk to the mysql database.
+
+Don't worry though...
+
+EO_MYSQL_FAILED
+
+CREATE_DATABASE_FAILED = <<-EO_CREATE_DATABASE_FAILED
+
+Looks like we couldn't create a test database to work against.
+
+Don't worry though...
+
+EO_CREATE_DATABASE_FAILED
+
+ def show_welcome_screen
+ colour_puts WELCOME_SCREEN
+ wait!
+ end
+
+ def show_done_screen
+ colour_puts DONE_SCREEN
+ end
+
+ # create database.yml
+ def create_database_yaml
+ colour_puts "<banner>creating database yaml</banner>"
+ puts
+
+
+ config = {
+ 'username' => 'root',
+ 'password' => nil,
+ 'host' => 'localhost'
+ }
+
+
+ colour_print " * <b>#{db_yml}</b>... "
+ unless File.exist?(db_yml)
+ open(db_yml,'w') {|f| f << config.to_yaml}
+ colour_puts "<green>created</green>"
+ else
+ config = YAML.load_file(db_yml)
+ colour_puts "<green>already exists</green>"
+ end
+
+ colour_puts REVIEW_YAML
+
+ config.each do |(k,v)|
+ colour_puts " * <b>#{k}</b>: #{v}"
+ end
+
+ puts
+
+ wait!
+ true
+ end
+
+ def check_mysql_is_working
+ require 'activerecord'
+ colour_puts "<banner>check mysql is working</banner>"
+ puts
+
+ connect_to_db
+
+ print " * connecting to mysql... "
+
+ begin
+ ActiveRecord::Base.connection.select_value('select sysdate() from dual')
+
+ colour_puts "<green>successful</green>"
+ puts
+
+ return true
+ rescue defined?(JRUBY_VERSION) ? Java::JavaSql::SQLException : Mysql::Error
+ colour_puts "<red>failed</red>"
+
+ puts MYSQL_FAILED
+ end
+
+ false
+ end
+
+ # create test db
+ def create_test_database
+ colour_puts "<banner>create test database</banner>"
+ puts
+
+ connect_to_db
+
+ colour_print " * <b>creating thinking_sphinx database</b>... "
+ begin
+ ActiveRecord::Base.connection.create_database('thinking_sphinx')
+ colour_puts "<green>successful</green>"
+ puts
+ return true
+ rescue ActiveRecord::StatementInvalid
+ if $!.message[/database exists/]
+ colour_puts "<green>successful</green> (database already existed)"
+ puts
+ return true
+ else
+ colour_puts "<red>failed</red>"
+ colour_puts CREATE_DATABASE_FAILED
+ end
+ end
+
+ false
+ end
+
+ # project
+ def ts_root
+ File.expand_path(File.dirname(__FILE__))
+ end
+
+ def specs
+ ts_root / 'spec'
+ end
+
+ def db_yml
+ specs / 'fixtures' / 'database.yml'
+ end
+
+ def mysql_adapter
+ defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql'
+ end
+
+ def connect_to_db
+ config = YAML.load_file(db_yml)
+ config.update(:adapter => mysql_adapter, :database => 'thinking_sphinx')
+ config.symbolize_keys!
+
+ ActiveRecord::Base.establish_connection(config)
+ end
+end
+
+
+
+
+
+
+
+class String
+ def /(other)
+ "#{self}/#{other}"
+ end
+end
+
+module ContributeHelper
+ class Dependency
+ def self.name(name=nil)
+ if name then @name = name else @name end
+ end
+
+ attr_reader :location
+
+ def initialize
+ @found = false
+ @location = nil
+ end
+
+ def name; self.class.name end
+
+ def check; false end
+ def check!
+ @found = check
+ end
+
+ def found?
+ @found
+ end
+ end
+
+ class Gem < Dependency
+ def gem_name; self.class.name end
+ def name; "#{super} gem" end
+
+ def check
+ ::Gem.available? self.gem_name
+ end
+ end
+
+
+ def check_for_dependencies
+ colour_puts "<banner>Checking for required software</banner>"
+ puts
+
+ all_found = true
+
+ dependencies.each do |klass|
+ dep = klass.new
+ print " * #{dep.name}... "
+ dep.check!
+
+ if dep.found?
+ if dep.location
+ colour_puts "<green>found at #{dep.location}</green>"
+ else
+ colour_puts "<green>found</green>"
+ end
+ else
+ all_found &= false
+ colour_puts "<red>not found</red>"
+ end
+ end
+
+ puts
+
+ if !all_found
+ print "You may wish to try setting additional options. Use ./contribute.rb -h for details"
+ puts
+ end
+
+ all_found
+ end
+
+ def colourise_output?
+ @colourise_output = !!(RUBY_PLATFORM !~ /mswin/ || defined?(Win32::Console::ANSI)) if @colourise_output.nil?
+ @colourise_output
+ end
+
+ DEFAULT_TERMINAL_COLORS = "\e[0m\e[37m\e[40m"
+ MONOCHROME_OUTPUT = "\\1"
+ def subs_colour(data)
+ data = data.gsub(%r{<b>(.*?)</b>}m, colourise_output? ? "\e[1m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT)
+ data.gsub!(%r{<red>(.*?)</red>}m, colourise_output? ? "\e[1m\e[31m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT)
+ data.gsub!(%r{<green>(.*?)</green>}m, colourise_output? ? "\e[1m\e[32m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT)
+ data.gsub!(%r{<yellow>(.*?)</yellow>}m, colourise_output? ? "\e[1m\e[33m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT)
+ data.gsub!(%r{<banner>(.*?)</banner>}m, colourise_output? ? "\e[33m\e[44m\e[1m\\1#{DEFAULT_TERMINAL_COLORS}" : MONOCHROME_OUTPUT)
+
+ return data
+ end
+
+ def colour_puts(text)
+ puts subs_colour(text)
+ end
+
+ def colour_print(text)
+ print subs_colour(text)
+ end
+
+
+ def wait!
+ colour_puts "<b>Hit Enter to continue, or Ctrl-C to quit.</b>"
+ STDIN.readline
+ rescue Interrupt
+ exit!
+ end
+end
+
+module Dependencies
+ class Mysql < ContributeHelper::Gem
+ name(defined?(JRUBY_VERSION) ? 'jdbc-mysql' : 'mysql')
+ end
+
+ class Rspec < ContributeHelper::Gem
+ name 'rspec'
+ end
+
+ class Cucumber < ContributeHelper::Gem
+ name 'cucumber'
+ end
+
+ class Yard < ContributeHelper::Gem
+ name 'yard'
+ end
+
+ class Jeweler < ContributeHelper::Gem
+ name 'jeweler'
+ end
+
+ class AR < ContributeHelper::Gem
+ name 'activerecord'
+ end
+
+ class Ginger < ContributeHelper::Gem
+ name(OPTIONS.has_key?(:ginger) ? OPTIONS[:ginger] : 'ginger')
+ end
+
+ class Sphinx < ContributeHelper::Dependency
+ name 'sphinx'
+
+ def check
+ app_name = OPTIONS.has_key?(:sphinx) ? OPTIONS[:sphinx] : 'searchd'
+ app_name << '.exe' if RUBY_PLATFORM =~ /mswin/ && app_name[-4, 4] != '.exe'
+
+ !(@location = ENV['PATH'].split(File::PATH_SEPARATOR).map { |path| File.join(path, app_name) }.find { |path| File.file?(path) && File.executable?(path) }).nil?
+ end
+ end
+end
+
+Contribute.new.show
View
1  vendor/plugins/thinking-sphinx/cucumber.yml
@@ -0,0 +1 @@
+default: "--require features/support/env.rb --require features/step_definitions/alpha_steps.rb --require features/step_definitions/beta_steps.rb --require features/step_definitions/common_steps.rb --require features/step_definitions/extensible_delta_indexing_steps.rb --require features/step_definitions/facet_steps.rb --require features/step_definitions/find_arguments_steps.rb --require features/step_definitions/gamma_steps.rb --require features/step_definitions/scope_steps.rb --require features/step_definitions/search_steps.rb --require features/step_definitions/sphinx_steps.rb"
View
10 vendor/plugins/thinking-sphinx/features/abstract_inheritance.feature
@@ -0,0 +1,10 @@
+Feature: Abstract inheritance
+ In order to use Thinking Sphinx in complex situations
+ As a developer
+ I want to define indexes on subclasses of abstract models
+
+ Scenario: Searching on subclasses of abstract models
+ Given Sphinx is running
+ And I am searching on music
+ When I search
+ Then I should get 3 results
View
27 vendor/plugins/thinking-sphinx/features/alternate_primary_key.feature
@@ -0,0 +1,27 @@
+Feature: Searching on a single model
+ In order to use search models with non-integer primary keys
+ A developer
+ Should be able to search on a single model
+
+ Scenario: Searching using a basic query
+ Given Sphinx is running
+ And I am searching on robots
+ When I search for Sizzle
+ Then I should get 2 results
+
+ Scenario: Searching using another basic query
+ Given Sphinx is running
+ And I am searching on robots
+ When I search for fritz
+ Then I should get 1 result
+
+ Scenario: Deleting an instance
+ Given Sphinx is running
+ And I am searching on robots
+ When I search for Expendable
+ Then I should get 1 result
+
+ When I destroy robot Expendable
+ And I wait for Sphinx to catch up
+ And I search for Expendable
+ Then I should get 0 results
View
22 vendor/plugins/thinking-sphinx/features/attribute_transformation.feature
@@ -0,0 +1,22 @@
+Feature: Handle not-quite-supported column types as attributes
+ In order for Thinking Sphinx to be more understanding with model structures
+ The plugin
+ Should be able to use translatable columns as attributes
+
+ Scenario: Decimals as floats
+ Given Sphinx is running
+ And I am searching on alphas
+ When I filter between 1.0 and 3.0 on cost
+ Then I should get 2 results
+
+ Scenario: Dates as Datetimes
+ Given Sphinx is running
+ And I am searching on alphas
+ When I filter between 1 and 3 days ago on created_on
+ Then I should get 2 results
+
+ Scenario: Timestamps as Datetimes
+ Given Sphinx is running
+ And I am searching on alphas
+ When I filter between 1 and 3 days ago on created_at
+ Then I should get 2 results
View
77 vendor/plugins/thinking-sphinx/features/attribute_updates.feature
@@ -0,0 +1,77 @@
+Feature: Update attributes directly to Sphinx
+ In order for updates to be more seamless
+ The plugin
+ Should update Sphinx's attributes where possible
+
+ Scenario: Updating attributes in Sphinx without delta indexes
+ Given Sphinx is running
+ And I am searching on alphas
+ When I filter by 3 on value
+ Then I should get 1 result
+
+ When I change the value of alpha four to 13
+ And I wait for Sphinx to catch up
+ And I filter by 13 on value
+ And I use index alpha_core
+ Then I should get 1 result
+ When I use index alternative_core
+ Then I should get 1 result
+
+ When I change the value of alpha four to 4
+ And I wait for Sphinx to catch up
+ And I filter by 13 on value
+ And I use index alpha_core
+ Then I should get 0 results
+ When I use index alternative_core
+ Then I should get 0 result
+
+ Scenario: Updating attributes in Sphinx with delta indexes
+ Given Sphinx is running
+ And I am searching on betas
+ When I filter by 8 on value
+ Then I should get 1 result
+
+ When I change the value of beta eight to 18
+ And I wait for Sphinx to catch up
+ And I filter by 18 on value
+ Then I should get 1 result
+
+ When I search for the document id of beta eight in the beta_delta index
+ Then it should not exist
+
+ Scenario: Updating attributes in a delta index
+ Given Sphinx is running
+ And I am searching on betas
+
+ When I change the name of beta nine to nineteen
+ And I change the value of beta nineteen to 19
+ And I wait for Sphinx to catch up
+
+ When I filter by 19 on value
+ And I use index beta_delta
+ Then I should get 1 result
+
+ Scenario: Updating attributes in a delta index with deltas disabled
+ Given Sphinx is running
+ And I am searching on betas
+
+ When I change the name of beta eleven to twentyone
+ And I disable delta updates
+ And I change the value of beta twentyone to 21
+ And I wait for Sphinx to catch up
+
+ When I filter by 21 on value
+ And I use index beta_delta
+ Then I should get 1 result
+ And I enable delta updates
+
+ Scenario: Updating boolean attribute in Sphinx
+ Given Sphinx is running
+ And I am searching on alphas
+ When I filter by active alphas
+ Then I should get 10 results
+
+ When I flag alpha five as inactive
+ And I wait for Sphinx to catch up
+ And I filter by active alphas
+ Then I should get 9 results
View
67 vendor/plugins/thinking-sphinx/features/deleting_instances.feature
@@ -0,0 +1,67 @@
+Feature: Keeping Sphinx in line with deleted model instances
+ In order to avoid deleted items being returned by Sphinx
+ Thinking Sphinx
+ Should keep deleted items out of search results
+
+ Scenario: Deleting instances from the core index
+ Given Sphinx is running
+ And I am searching on betas
+ When I search for three
+ Then I should get 1 result
+
+ When I destroy beta three
+ And I wait for Sphinx to catch up
+ And I search for three
+ Then I should get 0 results
+
+ Scenario: Deleting subclasses when the parent class is indexed
+ Given Sphinx is running
+ And I am searching on cats
+ When I search for moggy
+ Then I should get 1 result
+
+ When I destroy cat moggy
+ And I wait for Sphinx to catch up
+ And I search for moggy
+ Then I should get 0 results
+
+ Scenario: Deleting created instances from the delta index
+ Given Sphinx is running
+ And I am searching on betas
+ When I create a new beta named eleven
+ And I wait for Sphinx to catch up
+ And I search for eleven
+ Then I should get 1 result
+
+ When I destroy beta eleven
+ And I wait for Sphinx to catch up
+ And I search for eleven
+ Then I should get 0 results
+
+ Scenario: Deleting edited instances from the delta index
+ Given Sphinx is running
+ And I am searching on betas
+ When I change the name of beta four to fourteen
+ And I wait for Sphinx to catch up
+ And I search for fourteen
+ Then I should get 1 result
+
+ When I destroy beta fourteen
+ And I wait for Sphinx to catch up
+ And I search for fourteen
+ Then I should get 0 results
+
+ Scenario: Deleting created instances from the delta index when deltas are disabled
+ Given Sphinx is running
+ And I am searching on betas
+ When I create a new beta named thirteen
+ And I wait for Sphinx to catch up
+ And I search for thirteen
+ Then I should get 1 result
+
+ And I disable delta updates
+ And I destroy beta thirteen
+ And I wait for Sphinx to catch up
+ And I enable delta updates
+ And I search for thirteen
+ Then I should get 0 results
View
11 vendor/plugins/thinking-sphinx/features/direct_attributes.feature
@@ -0,0 +1,11 @@
+Feature: Direct Attributes
+ In order to avoid unnecessary SQL queries
+ I want to access attribute values from Sphinx's response
+
+ Scenario: Accessing attribute values directly
+ Given Sphinx is running
+ And I am searching on posts
+ When I search
+ Then the first result should have a comments count of 9
+
+
View
21 vendor/plugins/thinking-sphinx/features/excerpts.feature
@@ -0,0 +1,21 @@
+Feature: Generate excerpts for search results
+
+ Scenario: Basic Excerpts Syntax
+ Given Sphinx is running
+ And I am searching on comments
+ And I search for "lorem punto"
+ Then the content excerpt of the first result is "de un sitio mientras que mira su diseño. El <span class="match">punto</span> de usar <span class="match">Lorem</span> Ipsum es que tiene una distribución"
+
+ Scenario: Integrated Excerpts Syntax
+ Given Sphinx is running
+ And I am searching on comments
+ And I search for "lorem"
+ Then calling content on the first result excerpts object should return "de un sitio mientras que mira su diseño. El punto de usar <span class="match">Lorem</span> Ipsum es que tiene una distribución"
+
+ Scenario: Excerpt Options
+ Given Sphinx is running
+ And I am searching on comments
+ And I search for "lorem"
+ And I provide excerpt option "before_match" with value "<em>"
+ And I provide excerpt option "after_match" with value "</em>"
+ Then calling content on the first result excerpts object should return "de un sitio mientras que mira su diseño. El punto de usar <em>Lorem</em> Ipsum es que tiene una distribución"
View
9 vendor/plugins/thinking-sphinx/features/extensible_delta_indexing.feature
@@ -0,0 +1,9 @@
+Feature: Delayed Delta Indexing
+ In order to have delta indexing on frequently-updated sites
+ Developers
+ Should be able to create their own handlers for delta indexing
+
+ Scenario: I specify a valid handler for delta indexing
+ Given Sphinx is running
+ When I change the name of extensible beta one to eleven
+ Then the generic delta handler should handle the delta indexing
View
88 vendor/plugins/thinking-sphinx/features/facets.feature
@@ -0,0 +1,88 @@
+Feature: Search and browse models by their defined facets
+
+ Background:
+ Given Sphinx is running
+
+ Scenario: Requesting facets
+ Given I am searching on developers
+ When I am requesting facet results
+ Then I should have valid facet results
+ And I should have 6 facets
+ And I should have the facet State
+ And I should have the facet Country
+ And I should have the facet Age
+ And I should have the facet City
+ And I should have the facet Tag Ids
+ And I should have the facet Tags
+
+ Scenario: Requesting specific facets
+ Given I am searching on developers
+ When I am requesting facet results
+ And I am requesting just the facet State
+ Then I should have valid facet results
+ And I should have 1 facet
+ And I should have the facet State
+ When I am requesting just the facets State and Age
+ Then I should have valid facet results
+ And I should have 2 facet
+ And I should have the facet State
+ And I should have the facet Age
+
+ Scenario: Requesting float facets
+ Given I am searching on alphas
+ When I am requesting facet results
+ Then I should have 1 facet
+ And the Cost facet should have a 5.55 key
+
+ Scenario: Requesting facet results
+ Given I am searching on developers
+ When I am requesting facet results
+ And I drill down where Country is Australia
+ Then I should get 11 results
+
+ Scenario: Requesting facet results by multiple facets
+ Given I am searching on developers
+ When I am requesting facet results
+ And I drill down where Country is Australia and Age is 30
+ Then I should get 4 results
+
+ Scenario: Requesting facets with classes included
+ Given I am searching on developers
+ When I am requesting facet results
+ And I want classes included
+ Then I should have valid facet results
+ And I should have 7 facets
+ And I should have the facet Class
+
+ Scenario: Requesting MVA facets
+ Given I am searching on developers
+ When I am requesting facet results
+ And I drill down where tag_ids includes the id of tag Australia
+ Then I should get 11 results
+ When I am requesting facet results
+ And I drill down where tag_ids includes the id of tags Melbourne or Sydney
+ Then I should get 5 results
+
+ Scenario: Requesting MVA string facets
+ Given I am searching on developers
+ When I am requesting facet results
+ Then the Tags facet should have an "Australia" key
+ Then the Tags facet should have an "Melbourne" key
+ Then the Tags facet should have an "Victoria" key
+
+ Scenario: Requesting MVA facets from source queries
+ Given I am searching on posts
+ When I am requesting facet results
+ Then the Comment Ids facet should have 9 keys
+
+ Scenario: Requesting facets from a subclass
+ Given I am searching on animals
+ When I am requesting facet results
+ And I want classes included
+ Then I should have the facet Class
+
+ Scenario: Requesting facets with explicit value sources
+ Given I am searching on developers
+ When I am requesting facet results
+ Then the City facet should have a "Melbourne" key
+
View
29 vendor/plugins/thinking-sphinx/features/facets_across_model.feature
@@ -0,0 +1,29 @@
+Feature: Search and browse across models by their defined facets
+
+ Scenario: Requesting facets across multiple models
+ Given Sphinx is running
+ When I am requesting facet results
+ And I want all possible attributes
+ Then I should have valid facet results
+ And I should have 12 facets
+ And I should have the facet Class
+ And the Class facet should have a "Person" key
+ And I should have the facet Gender
+ And the Gender facet should have a "female" key
+ And I should have the facet Country
+ And I should have the facet Category Name
+ And the Category Name facet should have a "hello" key with 10 hits
+
+ Scenario: Requesting facets across models without class results
+ Given Sphinx is running
+ When I am requesting facet results
+ And I want all possible attributes
+ And I don't want classes included
+ Then I should have 11 facets
+ And I should not have the facet Class
+
+ Scenario: Requesting facets common to all indexed models
+ Given Sphinx is running
+ When I am requesting facet results
+ Then I should have the facet Class
+ And I should have 1 facet
View
18 vendor/plugins/thinking-sphinx/features/field_sorting.feature
@@ -0,0 +1,18 @@
+Feature: Field Sorting
+ In order to sort by strings
+ As a developer
+ I want to enable sorting by existing fields
+
+ Background:
+ Given Sphinx is running
+ And I am searching on people
+
+ Scenario: Searching with ordering on a sortable field
+ When I order by first_name
+ Then I should get 20 results
+ And the first_name of each result should indicate order
+
+ Scenario: Sort on a case insensitive sortable field
+ When I order by last_name
+ Then the first result's "last_name" should be "abbott"
+
View
92 vendor/plugins/thinking-sphinx/features/handling_edits.feature
@@ -0,0 +1,92 @@
+Feature: Keeping Sphinx in line with model changes when requested
+ In order to keep indexes as up to date as possible
+ Thinking Sphinx
+ Should return the expected results depending on whether delta indexes are used
+
+ Scenario: Returning instance from old data if there is no delta
+ Given Sphinx is running
+ And I am searching on alphas
+ When I search for two
+ Then I should get 1 result
+
+ When I change the name of alpha two to twelve
+ And I wait for Sphinx to catch up
+ And I search for two
+ Then I should get 1 result
+
+ Scenario: Not returning an instance from old data if there is a delta
+ Given Sphinx is running
+ And I am searching on betas
+ When I search for two
+ Then I should get 1 result
+
+ When I change the name of beta two to twelve
+ And I wait for Sphinx to catch up
+ And I search for two
+ Then I should get 0 results
+
+ Scenario: Returning instance from new data if there is a delta
+ Given Sphinx is running
+ And I am searching on betas
+ When I search for one
+ Then I should get 1 result
+
+ When I change the name of beta one to eleven
+ And I wait for Sphinx to catch up
+ And I search for one
+ Then I should get 0 results
+
+ When I search for eleven
+ Then I should get 1 result
+
+ Scenario: Returning new records if there's a delta
+ Given Sphinx is running
+ And I am searching on betas
+ When I search for fifteen
+ Then I should get 0 results
+
+ When I create a new beta named fifteen
+ And I wait for Sphinx to catch up
+ And I search for fifteen
+ Then I should get 1 result
+
+ Scenario: Avoiding delta updates if there hasn't been changes
+ Given Sphinx is running
+ And I am searching on betas
+ When I search for five
+ Then I should get 1 result
+
+ When I change the name of beta five to five
+ And I wait for Sphinx to catch up
+ And I search for five
+ Then I should get 1 result
+
+ When I search for the document id of beta five in the beta_core index
+ Then it should exist if using Rails 2.1 or newer
+ When I search for the document id of beta five in the beta_delta index
+ Then it should not exist if using Rails 2.1 or newer
+
+ Scenario: Handling edits with a delta when Sphinx isn't running
+ Given Sphinx is running
+ And I am searching on betas
+ When I stop Sphinx
+ And I change the name of beta six to sixteen
+ And I start Sphinx
+ And I search for sixteen
+ Then I should get 1 result
+
+ Scenario: Handling edits when updates are disabled
+ Given Sphinx is running
+ And updates are disabled
+ And I am searching on betas
+
+ When I search for seven
+ Then I should get 1 result
+
+ When I change the name of beta seven to seventeen
+ And I wait for Sphinx to catch up
+ And I search for seven
+ Then I should get 1 result
+
+ When I search for seventeen
+ Then I should get 0 results
View
24 vendor/plugins/thinking-sphinx/features/retry_stale_indexes.feature
@@ -0,0 +1,24 @@
+Feature: Manually updating Sphinx indexes to handle uncaught deletions
+ In order to keep indexes as up to date as possible
+ Thinking Sphinx
+ Should automatically update the indexes and retry the search if it gets a nil result
+
+ Scenario: Changing retry_stale settings
+ Given Sphinx is running
+ And I am searching on gammas
+ Then I should not get 0 results
+
+ When I set retry stale to false
+ And I set per page to 1
+ And I order by "sphinx_internal_id ASC"
+ And I destroy gamma one without callbacks
+ Then I should get a single result of nil
+
+ When I set retry stale to 1
+ Then I should get a single gamma result with a name of two
+
+ When I destroy gamma two without callbacks
+ Then I should get a single result of nil
+
+ When I set retry stale to true
+ Then I should get a single gamma result with a name of three
View
20 vendor/plugins/thinking-sphinx/features/searching_across_models.feature
@@ -0,0 +1,20 @@
+Feature: Searching across multiple model
+ In order to use Thinking Sphinx's core functionality
+ A developer
+ Should be able to search on multiple models
+
+ Scenario: Retrieving total result count
+ Given Sphinx is running
+ When I search for James
+ And I am retrieving the result count
+ Then I should get a value of 6
+
+ Scenario: Confirming existance of a document id in a given index
+ Given Sphinx is running
+ When I search for the document id of alpha one in the alpha_core index
+ Then it should exist
+
+ Scenario: Retrieving results from multiple models
+ Given Sphinx is running
+ When I search for ten
+ Then I should get 4 results
View
40 vendor/plugins/thinking-sphinx/features/searching_by_index.feature
@@ -0,0 +1,40 @@
+Feature: Searching within a single index
+ In order to use Thinking Sphinx's core functionality
+ A developer
+ Should be able to search on a single index
+
+ Scenario: Searching with alternative index
+ Given Sphinx is running
+ And I am searching on alphas
+ When I order by value
+ And I use index alternative_core
+ Then I should get 7 results
+
+ Scenario: Searching with default index
+ Given Sphinx is running
+ And I am searching on alphas
+ When I order by value
+ And I use index alpha_core
+ Then I should get 10 results
+
+ Scenario: Searching without specified index
+ Given Sphinx is running
+ And I am searching on alphas
+ When I order by value
+ Then I should get 10 results
+
+ Scenario: Deleting instances from the core index
+ Given Sphinx is running
+ And I am searching on alphas
+
+ When I create a new alpha named eleven
+ And I process the alpha_core index
+ And I process the alternative_core index
+ And I wait for Sphinx to catch up
+ And I search for eleven
+ Then I should get 1 result
+
+ When I destroy alpha eleven
+ And I wait for Sphinx to catch up
+ And I search for eleven
+ Then I should get 0 results
View
168 vendor/plugins/thinking-sphinx/features/searching_by_model.feature
@@ -0,0 +1,168 @@
+Feature: Searching on a single model
+ In order to use Thinking Sphinx's core functionality
+ A developer
+ Should be able to search on a single model
+
+ Scenario: Searching using a basic query
+ Given Sphinx is running
+ And I am searching on people
+ When I search for James
+ Then I should get 3 results
+
+ Scenario: Searching on a specific field
+ Given Sphinx is running
+ And I am searching on people
+ When I search for James on first_name
+ Then I should get 2 results
+
+ Scenario: Searching on multiple fields
+ Given Sphinx is running
+ And I am searching on people
+ When I search for James on first_name
+ And I search for Chamberlain on last_name
+ Then I should get 1 result
+
+ Scenario: Searching on association content
+ Given Sphinx is running
+ And I am searching on posts
+
+ When I search for "Waffles"
+ Then I should get 1 result
+
+ When I search for "Turtle"
+ Then I should get 1 result
+
+ Scenario: Searching with a filter
+ Given Sphinx is running
+ And I am searching on alphas
+ When I filter by 1 on value
+ Then I should get 1 result
+
+ Scenario: Searching with multiple filters
+ Given Sphinx is running
+ And I am searching on boxes
+ When I filter by 2 on width
+ And I filter by 2 on length
+ Then I should get 1 result
+
+ Scenario: Searching with a ranged time filter
+ Given Sphinx is running
+ And I am searching on people
+ When I filter by birthday between 1975 and 1976
+ Then I should get 16 results
+
+ Scenario: Searching to filter multiple values on an MVA
+ Given Sphinx is running
+ And I am searching on boxes
+ When I filter by 11 and 12 on dimensions
+ Then I should get 2 results
+ When I clear existing filters
+ And I filter by both 11 and 12 on dimensions
+ Then I should get 1 result
+
+ Scenario: Filtering on timestamp MVAs
+ Given Sphinx is running
+ And I am searching on posts
+ When I filter by 2001-01-01 on comments_created_at
+ Then I should get 1 result
+
+ Scenario: Searching by NULL/0 values in MVAs
+ Given Sphinx is running
+ And I am searching on boxes
+ When I filter by 0 on dimensions
+ Then I should get 1 result
+
+ Given Sphinx is running
+ And I am searching on developers
+ When I clear existing filters
+ And I filter by 0 on tag_ids
+ Then I should get 1 result
+
+ Scenario: Searching on a MVA configured as ranged_query
+ Given Sphinx is running
+ And I am searching on posts
+ When I filter by 1 on comment_ids
+ Then I should get 1 result
+ When I clear existing filters
+ And I filter by both 1 and 2 on comment_ids
+ Then I should get 1 results
+ When I clear existing filters
+ And I filter by 10 on comment_ids
+ Then I should get 0 results
+
+ Scenario: Searching with ordering by attribute
+ Given Sphinx is running
+ And I am searching on alphas
+ When I order by value
+ Then I should get 10 results
+ And the value of each result should indicate order
+
+ Scenario: Intepreting Sphinx Internal Identifiers
+ Given Sphinx is running
+ And I am searching on people
+ Then I should get 20 results
+ And each result id should match the corresponding sphinx internal id
+
+ Scenario: Retrieving weightings
+ Given Sphinx is running
+ And I am searching on people
+ When I search for "Ellie Ford"
+ And I set match mode to any
+ Then I can iterate by result and weighting
+
+ Scenario: Retrieving group counts
+ Given Sphinx is running
+ And I am searching on people
+ When I group results by the birthday attribute
+ Then I can iterate by result and count
+
+ Scenario: Retrieving group values
+ Given Sphinx is running
+ And I am searching on people
+ When I group results by the birthday attribute
+ Then I can iterate by result and group
+
+ Scenario: Retrieving both group values and counts
+ Given Sphinx is running
+ And I am searching on people
+ When I group results by the birthday attribute
+ Then I can iterate by result and group and count
+
+ Scenario: Searching for ids
+ Given Sphinx is running
+ And I am searching on people
+ When I search for Ellie
+ And I am searching for ids
+ Then I should have an array of integers
+
+ Scenario: Search results should match Sphinx's order
+ Given Sphinx is running
+ And I am searching on people
+ When I search for Ellie
+ And I order by "sphinx_internal_id DESC"
+ Then searching for ids should match the record ids of the normal search results
+
+ Scenario: Retrieving total result count when total is less than a page
+ Given Sphinx is running
+ And I am searching on people
+ When I search for James
+ And I am retrieving the result count
+ Then I should get a value of 3
+
+ Scenario: Retrieving total result count for more than a page
+ Given Sphinx is running
+ And I am searching on people
+ When I am retrieving the result count
+ Then I should get a value of 1000
+
+ Scenario: Searching with Unicode Characters
+ Given Sphinx is running
+ And I am searching on people
+ When I search for "José* "
+ Then I should get 1 result
+
+ Scenario: Searching by fields from HABTM joins
+ Given Sphinx is running
+ And I am searching on posts
+ When I search for "Shakespeare"
+ Then I should get 1 result
View
56 vendor/plugins/thinking-sphinx/features/searching_with_find_arguments.feature
@@ -0,0 +1,56 @@
+Feature: Keeping AR::Base.find arguments in search calls
+ To keep things as streamlined as possible
+ Thinking Sphinx
+ Should respect particular arguments to AR::Base.find calls
+
+ Scenario: Respecting the include option
+ Given Sphinx is running
+ And I am searching on posts
+ Then I should get 1 result
+
+ When I get the first comment
+ And I track queries
+ And I compare comments
+ Then I should have 1 query
+
+ When I include comments
+ Then I should get 1 result
+ When I track queries
+ And I compare comments
+ Then I should have 0 queries
+
+ Scenario: Respecting the include option without using a specific model
+ Given Sphinx is running
+ And I search for "Hello World"
+ Then I should get 1 result
+
+ When I get the first comment
+ And I track queries
+ And I compare comments
+ Then I should have 1 query
+
+ When I include comments
+ Then I should get 1 result
+ When I track queries
+ And I compare comments
+ Then I should have 0 queries
+
+ Scenario: Respecting the select option
+ Given Sphinx is running
+ And I am searching on posts
+ Then I should get 1 result
+ And I should not get an error accessing the subject
+
+ When I select only content
+ Then I should get 1 result
+ And I should get an error accessing the subject
+
+ Scenario: Respecting the select option without using a specific model
+ Given Sphinx is running
+ When I search for "Hello World"
+ Then I should get 1 result
+ And I should not get an error accessing the subject
+
+ When I select only content
+ Then I should get 1 result
+ And I should get an error accessing the subject
View
25 vendor/plugins/thinking-sphinx/features/sphinx_detection.feature
@@ -0,0 +1,25 @@
+Feature: Checking whether Sphinx is running or not
+ In order to avoid unnecessary errors
+ Thinking Sphinx
+ Should be able to determine whether Sphinx is running or not
+
+ Scenario: Checking Sphinx's status
+ Given Sphinx is running
+ Then Sphinx should be running
+
+ When I stop Sphinx
+ And I wait for Sphinx to catch up
+ Then Sphinx should not be running
+
+ When I start Sphinx
+ And I wait for Sphinx to catch up
+ Then Sphinx should be running
+
+ Given Sphinx is running
+ When I kill the Sphinx process
+ And I wait for Sphinx to catch up
+ Then Sphinx should not be running
+
+ When I start Sphinx again
+ And I wait for Sphinx to catch up
+ Then Sphinx should be running again
View
68 vendor/plugins/thinking-sphinx/features/sphinx_scopes.feature
@@ -0,0 +1,68 @@
+Feature: Sphinx Scopes
+
+ Scenario: Single Scope
+ Given Sphinx is running
+ And I am searching on people
+ When I use the with_first_name scope set to "Andrew"
+ Then I should get 7 results
+
+ Scenario: Two Field Scopes
+ Given Sphinx is running
+ And I am searching on people
+ When I use the with_first_name scope set to "Andrew"
+ And I use the with_last_name scope set to "Byrne"
+ Then I should get 1 result
+
+ Scenario: Mixing Filter and Field Scopes
+ Given Sphinx is running
+ And I am searching on people
+ When I use the with_first_name scope set to "Andrew"
+ And I use the with_id scope set to 99
+ Then I should get 1 result
+
+ Scenario: Mixing Field and ID Scopes
+ Given Sphinx is running
+ And I am searching on people
+ When I use the with_first_name scope set to "Andrew"
+ And I use the ids_only scope
+ Then I should get 7 results
+ And I should have an array of integers
+
+ Scenario: Non-field/filter Scopes
+ Given Sphinx is running
+ And I am searching on people
+ When I use the ids_only scope
+ Then I should have an array of integers
+
+ Scenario: Counts with scopes
+ Given Sphinx is running
+ And I am searching on people
+ When I use the with_first_name scope set to "Andrew"
+ And I am retrieving the scoped result count
+ Then I should get a value of 7
+
+ Scenario: Counts with scopes and additional query terms
+ Given Sphinx is running
+ And I am searching on people
+ When I use the with_first_name scope set to "Andrew"
+ And I am retrieving the scoped result count for "Byrne"
+ Then I should get a value of 1
+
+ Scenario: Default Scope
+ Given Sphinx is running
+ And I am searching on andrews
+ Then I should get 7 results
+
+ Scenario: Default Scope and additional query terms
+ Given Sphinx is running
+ And I am searching on andrews
+ When I search for "Byrne"
+ Then I should get 1 result
+
+ Scenario: Explicit scope plus search over a default scope
+ Given Sphinx is running
+ And I am searching on andrews
+ When I use the locked_last_name scope
+ And I search for "Cecil"
+ Then I should get 1 result
+
View
16 vendor/plugins/thinking-sphinx/features/step_definitions/alpha_steps.rb
@@ -0,0 +1,16 @@
+When /^I create a new alpha named (\w+)$/ do |name|
+ Alpha.create!(:name => name, :value => 101)
+end
+
+When /^I change the (\w+) of alpha (\w+) to (\w+)$/ do |column, name, replacement|
+ Alpha.find_by_name(name).update_attributes(column.to_sym => replacement)
+end
+
+When /^I filter by active alphas$/ do
+ @results = nil
+ @with[:active] = true
+end