Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

2 0 stable merge #20

Closed
wants to merge 5 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 12, 2012
  1. @ugisozols
  2. @ugisozols

    Add Guard support.

    ugisozols authored
    Conflicts:
    
    	Gemfile
  3. @ugisozols

    Update readme.

    ugisozols authored
  4. @ugisozols

    Fix typo in readme.

    ugisozols authored
Commits on Apr 16, 2012
  1. @parndt
This page is out of date. Refresh to see the latest.
Showing with 59 additions and 34 deletions.
  1. +6 −5 Gemfile
  2. +20 −0 Guardfile
  3. +33 −26 readme.md
  4. +0 −3  refinerycms-search.gemspec
View
11 Gemfile
@@ -5,9 +5,8 @@ gemspec
gem 'refinerycms', '~> 2.0.0'
group :development, :test do
- require 'rbconfig'
-
gem 'refinerycms-testing', '~> 2.0.0'
+ gem 'guard-rspec', '~> 0.6.0'
platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter'
@@ -29,13 +28,14 @@ group :development, :test do
end
platforms :ruby do
- gem 'spork', '0.9.0.rc9'
+ gem 'spork', '~> 0.9.0.rc'
gem 'guard-spork'
unless ENV['TRAVIS']
+ require 'rbconfig'
if RbConfig::CONFIG['target_os'] =~ /darwin/i
gem 'rb-fsevent', '>= 0.3.9'
- gem 'growl', '~> 1.0.3'
+ gem 'ruby_gntp'
end
if RbConfig::CONFIG['target_os'] =~ /linux/i
gem 'rb-inotify', '>= 0.5.1'
@@ -47,8 +47,9 @@ group :development, :test do
platforms :jruby do
unless ENV['TRAVIS']
+ require 'rbconfig'
if RbConfig::CONFIG['target_os'] =~ /darwin/i
- gem 'growl', '~> 1.0.3'
+ gem 'ruby_gntp'
end
if RbConfig::CONFIG['target_os'] =~ /linux/i
gem 'rb-inotify', '>= 0.5.1'
View
20 Guardfile
@@ -0,0 +1,20 @@
+guard 'rspec', :version => 2, :cli => "--color" do
+ watch(%r{^spec/.+_spec\.rb$})
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/controllers/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
+ watch('spec/spec_helper.rb') { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+ # Capybara request specs
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+end
+
+guard 'spork', :wait => 60, :cucumber => false, :rspec_env => { 'RAILS_ENV' => 'test' } do
+ watch('config/application.rb')
+ watch('config/environment.rb')
+ watch(%r{^config/environments/.+\.rb$})
+ watch(%r{^config/initializers/.+\.rb$})
+ watch('spec/spec_helper.rb')
+end
View
59 readme.md
@@ -7,55 +7,62 @@ Powered by: [acts_as_indexed](http://github.com/dougal/acts_as_indexed) - Check
## Installation
-Simply use this by adding the following to your ``Gemfile``:
+Simply use this by adding the following to your `Gemfile`:
- gem 'refinerycms-search', '~> 0.9.8'
+```ruby
+gem 'refinerycms-search', '~> 2.0.0', :git => 'git://github.com/resolve/refinerycms-search.git', :branch => '2-0-stable'
+```
-You'll also need to create a page (from the 'Pages' tab) with a custom URL of '/search'.
-You can set a custom URL for a page in the Advanced Options via the "Forward this page to another website or page" option.
-It's probably also a good idea to uncheck the 'show in menu' option for this page.
+## RE-SAVE all records that have not been indexed before.
-## Restart your web server and RE-SAVE all records that have not been indexed before.
-
-A sample search form can be found in [views/shared/_search.html.erb](http://github.com/resolve/refinerycms-search/blob/master/app/views/shared/_search.html.erb).
+A sample search form can be found in [views/refinery/shared/_search.html.erb](http://github.com/resolve/refinerycms-search/blob/master/app/views/refinery/shared/_search.html.erb).
You can either use this partial directly, or copy the appropriate parts.
## Searching
The default installation will search in Pages.
-If you wish to find results in other plugins you have created or installed, you can specify these in ``config/application.rb`` like so:
+If you wish to find results in other plugins you have created or installed, you can specify these in `config/application.rb` like so:
- config.to_prepare do
- Refinery.searchable_models = [Page]
- end
+```ruby
+config.to_prepare do
+ Refinery.searchable_models = [Refinery::Page]
+end
+```
Simply add any additional models you wish to search to this array. For example, if you have the [portfolio plugin](http://github.com/resolve/refinerycms-portfolio) installed:
- config.to_prepare do
- Refinery.searchable_models = [Page, PortfolioEntry]
- end
+```ruby
+config.to_prepare do
+ Refinery.searchable_models = [Refinery::Page, Refinery::PortfolioEntry]
+end
+```
The above line will add indexing to PortfolioEntry in the portfolio plugin, which does not come indexed.
Any model you wish to search will need to be indexed using acts as indexed. To add indexing, simple add:
- acts_as_indexed :fields => [:title, :body]
+```ruby
+acts_as_indexed :fields => [:title, :body]
+```
-If your model doesn't use a ``:title`` attribute, remember to add an ``alias_attribute``:
+If your model doesn't use a `:title` attribute, remember to add an `alias_attribute`:
- alias_attribute :title, :name #for example
+```ruby
+alias_attribute :title, :name #for example
+```
-You can use any public method, as well. So if you have ``:first_name`` and ``:last_name`` but a method like ``name`` to join them, it can be indexed.
+You can use any public method, as well. So if you have `:first_name` and `:last_name` but a method like `name` to join them, it can be indexed.
- acts_as_indexed :fields => [:name, :biography]
+```ruby
+acts_as_indexed :fields => [:name, :biography]
- #...
+#...
- def name
- (first_name, last_name).compact.join(' ')
- end
+def name
+ [first_name, last_name].reject(&:blank?).join(' ')
+end
+```
You will need to replace the indexed fields with those appropriate for your model.
-
-If you wish to override the url used in the search results just add a ``url`` method to your model and the result of this method will be used instead.
+If you wish to override the url used in the search results just add a `url` method to your model and the result of this method will be used instead.
View
3  refinerycms-search.gemspec
@@ -13,7 +13,4 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- spec/*`.split("\n")
s.add_dependency 'refinerycms-core', '~> 2.0.0'
-
- # Development dependencies
- s.add_development_dependency 'refinerycms-testing', '~> 2.0.0'
end
Something went wrong with that request. Please try again.