Commit ec7075b4 authored by Philip Arndt's avatar Philip Arndt
Browse files

Merge pull request #8 from refinery/fix-unicode

Use ascii fields for UTF-8 search terms in Page
parents 9282f419 c4899356
......@@ -14,11 +14,20 @@ Refinery CMS Acts As Indexed is the [Acts As Indexed](https://github.com/dougal/
Open up your ``Gemfile`` and add at the bottom this line:
```ruby
gem 'refinerycms-acts-as-indexed', '~> 2.0.1'
gem 'refinerycms-acts-as-indexed', '~> 3.0.0'
```
Now run `bundle install`.
## Upgrade
When upgrading to a new version of `refinerycms-acts-as-indexed` it is recommended you delete the index directory and allow it to be rebuilt.
## Contribute
Please see the [contributing.md](contributing.md) file for instructions.
## More Information
* Check out our [Website](http://refinerycms.com/)
* [Help and documentation](https://github.com/refinery/refinerycms#help-and-documentation)
* [Help and documentation](https://github.com/refinery/refinerycms#help-and-documentation)
\ No newline at end of file
require 'acts_as_indexed'
require 'stringex_lite'
begin
Refinery::Page.class_eval do
# Docs for acts_as_indexed https://github.com/dougal/acts_as_indexed
acts_as_indexed :fields => [:title, :meta_description,
:menu_title, :browser_title, :all_page_part_content]
acts_as_indexed :fields => [:ascii_title, :meta_description,
:menu_title, :browser_title, :ascii_all_page_part_content]
# Used to index all the content on this page so it can be easily searched.
def all_page_part_content
parts.map(&:body).join " "
end
private
def ascii_title
self.title.try(&:to_ascii)
end
def ascii_all_page_part_content
self.all_page_part_content.try(&:to_ascii)
end
end
rescue NameError
end
# Contribution Guidelines #
## Submitting a new issue ##
If you want to ensure that your issue gets fixed *fast* you should
attempt to reproduce the issue in an isolated example application that
you can share.
## Running tests ##
Always run tests first. Quick start for tests (requires a dummy application) :
bundle install
bundle exec rake refinery:testing:dummy_app
bundle exec rake
## Making a pull request ##
If you'd like to submit a pull request please adhere to the following:
1. Your code *must* be tested. Please TDD your code!
2. No single-character variables.
3. Two-spaces instead of tabs.
4. Double-quoted strings are fine for all use cases.
5. General Rails/Ruby naming conventions for files and classes.
6. Please add `[ci skip]` to your commit message for purely documentation changes **only**.
Please note that you must adhere to each of the above mentioned rules.
Failure to do so will result in an immediate closing of the pull
request. If you update and rebase the pull request to follow the
guidelines your pull request will be re-opened and considered for
inclusion.
## Links ##
See also the [Contributing to Refinery](http://refinerycms.com/guides/contributing-to-refinery) guide.
\ No newline at end of file
require 'acts_as_indexed'
require 'stringex_lite'
require 'refinerycms-core'
require 'refinery/acts_as_indexed'
......@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = %q{refinerycms-acts-as-indexed}
s.version = %q{2.0.1}
s.version = %q{3.0.0}
s.description = %q{An extension to handle the integration of Refinery CMS and ActsAsIndexed}
s.summary = %q{Refinery CMS ActsAsIndexed integration plugin}
s.email = %q{info@refinerycms.com}
......@@ -16,4 +16,5 @@ Gem::Specification.new do |s|
s.add_dependency 'refinerycms-core', ['>= 3.0.0', '< 4.0']
s.add_dependency 'acts_as_indexed', '~> 0.8.0'
s.add_dependency 'decorators', '~> 2.0.0'
s.add_dependency 'stringex', '~> 2.5.2'
end
......@@ -46,14 +46,20 @@ module Refinery
describe "pages extension" do
before do
FactoryGirl.create(:page, :title => "Ugis Ozols")
FactoryGirl.create(:page, :title => "Téléphone")
visit refinery.admin_pages_path
end
it "returns found page" do
fill_in "search", :with => "ugis"
it "returns found page without accents in the query" do
fill_in "search", :with => "Telephone"
click_button "Search"
expect(page).to have_content("Ugis Ozols")
expect(page).to have_content("Téléphone")
end
it "returns found page with accents in the query" do
fill_in "search", :with => "Téléphone"
click_button "Search"
expect(page).to have_content("Téléphone")
end
it_behaves_like "no result search"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment