tkh_search 0.2 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ec2548d73c8962999cf9eb77004b5ab2da38126
4
- data.tar.gz: 03f8807ddfca834983c47a36e9012777ec1eda0e
3
+ metadata.gz: e46f0c7ae302f4b399f6585ff098de3e4db77678
4
+ data.tar.gz: 0a274e2a010c2e15f9ae13a614fc61bddfac6a22
5
5
  SHA512:
6
- metadata.gz: 36f41316f96bf10a0ee22e4f088228665031774f6f624d199178207f924802ad98800d20f13d616d3d41f633d7709b1be4124c48c18bb85b9640ce77c4e6f09f
7
- data.tar.gz: 7012552fcf9027737a3e89c4b674214ce8e437140a76d40de9da8a9a13bf6be2a759a6e1fb306aa638a264c5eb5ecc5616fa9c9c3f7b18408801126f2a688e99
6
+ metadata.gz: f540f7810be0a1e3ca547d67446dd8d20980308f5b8cb8f138fca30284e5aeb61c18ff51d1e7ed781c6e79ecee5c044f711ec5e185487b4dc25381f60585d9be
7
+ data.tar.gz: c0c0b950ff96a9bd20a820dfbb311ab4d27d4e89250b9c78a3d6b02ccf46bdedc4ef19a79f69ea2abc51d978666af0711560e5a63894d05cbf15ce9906324b13
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
 
4
4
 
5
+ ## 0.3
6
+
7
+ * Added internationalization of queries
8
+ * Little aesthetic improvement in search stats
9
+
10
+
5
11
  ## 0.2
6
12
 
7
13
  * Added search stats section to readme.
@@ -4,14 +4,16 @@ class SearchController < ApplicationController
4
4
  @query = params[:query].downcase.strip
5
5
  @models_to_search = params[:models_to_search].split
6
6
  @results_css_class = params[:results_css_class] || 'js-search-results'
7
+ current_locale = @cl
8
+ @the_current_locale = I18n.locale
7
9
  token = SecureRandom.base64
8
10
  search_terms = []
9
11
  @query.split.each do |query_word|
10
- search_terms << TkhSearchTerm.includes(:tkh_search_instances).find_or_create_by( word: query_word )
12
+ search_terms << TkhSearchTerm.find_or_create_by( word: query_word )
11
13
  end
12
14
  search_terms.each do |search_term|
13
- if search_term.tkh_search_instances.any?
14
- search_term.tkh_search_instances.each do |search_instance|
15
+ if search_term.tkh_search_instances.for_locale(current_locale).any?
16
+ search_term.tkh_search_instances.for_locale(current_locale).each do |search_instance|
15
17
  if @models_to_search.include? search_instance.host_model_name
16
18
  search_result = TkhSearchResult.find_or_create_by(
17
19
  token: token,
@@ -4,7 +4,7 @@ class SearchStatsController < ApplicationController
4
4
  before_filter :authenticate_with_admin
5
5
 
6
6
  def index
7
- switch_to_admin_layout
7
+ render :layout => 'admin'
8
8
  end
9
9
 
10
10
  end
@@ -4,6 +4,7 @@ class TkhSearchInstance < ActiveRecord::Base
4
4
 
5
5
  scope :a_bit_old, -> { where('updated_at <= ?', ( Time.now - 2.minutes )) }
6
6
  scope :by_top_rating, -> { order('rating desc') }
7
+ scope :for_locale, ->(loc) { where('language = ?', loc) }
7
8
 
8
9
  def unique_record_name
9
10
  "#{host_model_name}-#{model_record_id}"
@@ -20,3 +20,5 @@
20
20
  <li>There are no page results corresponding to this query.</li>
21
21
  <% end %>
22
22
  </ul>
23
+ <p>The current locale in the controller is: <%= @the_current_locale %></p>
24
+ <p>The current locale in the view is: <%= I18n.locale %></p>
@@ -28,7 +28,7 @@
28
28
 
29
29
  <ul>
30
30
  <% TkhSearchEvent.last_month.group(:tkh_search_query_id).order('COUNT(tkh_search_query_id) desc').limit(50).each do |event| %>
31
- <li><%= "#{event.tkh_search_query.string} #{TkhSearchEvent.last_month.where(tkh_search_query_id: event.tkh_search_query_id).count}" %></li>
31
+ <li><%= "#{event.tkh_search_query.string}&nbsp;&nbsp;<span class=\"badge\">#{TkhSearchEvent.last_month.where(tkh_search_query_id: event.tkh_search_query_id).count}</span>".html_safe %></li>
32
32
  <% end %>
33
33
  </ul>
34
34
 
data/config/routes.rb CHANGED
@@ -1,7 +1,18 @@
1
1
  Rails.application.routes.draw do
2
- scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
3
- post 'search' => 'search#index'
4
- get 'index_all_models' => 'search#index_all_models'
5
- get 'search_stats' => 'search_stats#index'
2
+
3
+ # The yoga center madrid site uses a different internationalization system :-(
4
+ unless request.domain == 'yogacentersc.es'
5
+ localized do
6
+ post 'search' => 'search#index'
7
+ get 'index_all_models' => 'search#index_all_models'
8
+ get 'search_stats' => 'search_stats#index'
9
+ end
10
+ else
11
+ scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
12
+ post 'search' => 'search#index'
13
+ get 'index_all_models' => 'search#index_all_models'
14
+ get 'search_stats' => 'search_stats#index'
15
+ end
6
16
  end
17
+
7
18
  end
@@ -1,3 +1,3 @@
1
1
  module TkhSearch
2
- VERSION = "0.2"
2
+ VERSION = "0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tkh_search
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swami Atma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-17 00:00:00.000000000 Z
11
+ date: 2015-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 2.4.4
132
+ rubygems_version: 2.2.2
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: Lightweigh Rails search engine