SimpleGoogleCustomSearch
With Simple Google Custom Search, help people search what they need in your website just like in official google site.
Installation
Add this line to your application's Gemfile:
gem 'simple_google_custom_search'
And then execute:
$ bundle
Or install it yourself as:
$ gem install simple_google_custom_search
Configuration
You need to define a constant variable for the API to search the matching words to your domain:
SGCS_CONFIG = {
domain: 'YOUR_SITE_URL'
}
Usage
To perform a search:
results = SimpleGoogleCustomSearch.search("simple", offset +optional+)
The +results+ variable is now a SimpleGoogleCustomSearch::ResultSet object:
results.total # number of results (integer)
results.item # array of result objects (SimpleGoogleCustomSearch::Result)
Iterate through the results:
results.item.each do |result|
result.title # result title
result.link # result URL
result.description # excerpt, with terms highlighted
end
TODO
- Unit Test
- Add Pagination
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request