diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb
index f9d26c1..bd485ed 100644
--- a/app/controllers/public/search_controller.rb
+++ b/app/controllers/public/search_controller.rb
@@ -6,7 +6,7 @@ class SearchController < ApplicationController
before_filter :prepare_filter
before_filter :check_search_whole_site
before_filter :load_search_assets
- before_filter :check_valid_assets, :only => [ :assets, :directory ]
+ before_filter :check_valid_assets, :only => [ :assets ]
no_design_blocks
@@ -191,14 +191,6 @@ class SearchController < ApplicationController
end
attr_reader :category
- def directory
- @results = { @asset => @finder.find_by_initial(@asset, params[:initial]) }
- @asset_name = gettext(SEARCH_IN.find { |entry| entry.first == @asset }[1])
- @names = { @asset => @asset_name }
-
- render :action => @asset
- end
-
def tags
@tags = Tag.find(:all).inject({}) do |memo,tag|
memo[tag.name] = tag.taggings.count
@@ -211,25 +203,6 @@ class SearchController < ApplicationController
@tagged = @tag.taggings.map(&:taggable)
end
- def sellers
- # FIXME use a better select for category
- @categories = ProductCategory.find(:all)
- @regions = Region.find(:all).select{|r|r.lat && r.lng}
- @product_category = ProductCategory.find(params[:category]) if params[:category]
- @region = Region.find(params[:region]) if params[:region]
-
- options = {}
- options.merge! :origin => [params[:lat].to_f, params[:long].to_f], :within => params[:radius] if !params[:lat].blank? && !params[:long].blank? && !params[:radius].blank?
- options.merge! :origin => [@region.lat, @region.lng], :within => params[:radius] if !params[:region].blank? && !params[:radius].blank?
- if @product_category
- finder = CategoryFinder.new(@product_category)
- product_ids = finder.find('products',nil)
- options.merge! :include => :products, :conditions => ['products.id IN ?', product_ids ]
- end
-
- @enterprises = Enterprise.find(:all, options)
- end
-
#######################################################
def popup
diff --git a/app/models/article.rb b/app/models/article.rb
index f915cfe..63cb33d 100644
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -136,10 +136,6 @@ class Article < ActiveRecord::Base
false
end
- def self.find_by_initial(initial)
- self.find(:all, :order => 'articles.name', :conditions => [ 'articles.name like (?) or articles.name like (?)', initial + '%', initial.upcase + '%'])
- end
-
def display_to?(user)
if self.profile.public_content
true
diff --git a/app/models/category_finder.rb b/app/models/category_finder.rb
index c1a9c9d..783173a 100644
--- a/app/models/category_finder.rb
+++ b/app/models/category_finder.rb
@@ -28,10 +28,6 @@ class CategoryFinder
find(asset, nil, :limit => limit)
end
- def find_by_initial(asset, initial)
- asset_class(asset).find(:all, options_for_find_by_initial(asset_class(asset), initial))
- end
-
def count(asset, query='', options={})
# because will_paginate needs a page
options = {:page => 1}.merge(options)
@@ -81,20 +77,6 @@ class CategoryFinder
end
end
- def options_for_find_by_initial(klass, initial)
- # FIXME copy/pasted from options_for_find above !!!
- case klass.name
- when 'Product'
- {:select => 'distinct products.*', :joins => 'inner join categories_profiles on products.enterprise_id = categories_profiles.profile_id', :conditions => ['categories_profiles.category_id = (?) and (products.name like (?) or products.name like (?))', category_id, initial + '%', initial.upcase + '%']}
- when 'Article'
- {:joins => 'inner join articles_categories on (articles_categories.article_id = articles.id)', :conditions => ['articles_categories.category_id = (?) and (%s.name like (?) or %s.name like (?))' % [klass.table_name, klass.table_name], category_id, initial + '%', initial.upcase + '%']}
- when 'Person', 'Community', 'Enterprise'
- {:joins => 'inner join categories_profiles on (categories_profiles.profile_id = profiles.id)', :conditions => ['categories_profiles.category_id = (?) and (%s.name like (?) or %s.name like (?))' % [klass.table_name, klass.table_name], category_id, initial + '%', initial.upcase + '%']}
- else
- raise "unreconized class #{klass.name}"
- end
- end
-
def asset_class(asset)
asset.to_s.singularize.camelize.constantize
end
diff --git a/app/models/environment_finder.rb b/app/models/environment_finder.rb
index 2ec4436..66648ad 100644
--- a/app/models/environment_finder.rb
+++ b/app/models/environment_finder.rb
@@ -42,10 +42,6 @@ class EnvironmentFinder
find(asset, nil, :limit => limit)
end
- def find_by_initial(asset, initial)
- @environment.send(asset).find_by_initial(initial)
- end
-
def count(asset, query = '', options = {})
# because will_paginate needs a page
options = {:page => 1}.merge(options)
diff --git a/app/models/product.rb b/app/models/product.rb
index 262c75c..f499d53 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -43,10 +43,6 @@ class Product < ActiveRecord::Base
self.find(:all, :order => 'id desc', :limit => limit)
end
- def self.find_by_initial(initial)
- self.find(:all, :order => 'products.name', :conditions => [ 'products.name like (?) or products.name like (?)', initial + '%', initial.upcase + '%'])
- end
-
def enterprise_updated(e)
self.lat = e.lat
self.lng = e.lng
diff --git a/app/models/profile.rb b/app/models/profile.rb
index fa8af1f..6950f07 100644
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -342,10 +342,6 @@ class Profile < ActiveRecord::Base
self.find(:all, :order => 'id desc', :limit => limit)
end
- def self.find_by_initial(initial)
- self.find(:all, :order => 'profiles.name', :conditions => [ 'profiles.name like (?) or profiles.name like (?)', (initial + '%'), (initial.upcase + '%') ])
- end
-
# returns +true+ if the given +user+ can see profile information about this
# +profile+, and +false+ otherwise.
def display_info_to?(user)
diff --git a/app/views/search/_directory.rhtml b/app/views/search/_directory.rhtml
deleted file mode 100644
index 246887a..0000000
--- a/app/views/search/_directory.rhtml
+++ /dev/null
@@ -1,6 +0,0 @@
-
- <%= link_to_unless(params[:initial].blank?, _('Recent'), params.merge(:action => 'assets', :initial => nil)) %>
-
- <%= ('a'..'z').map { |initial| link_to_unless(params[:initial] == initial, initial.upcase, params.merge(:action => 'directory', :asset => @asset, :initial => initial)) }.join(' ') %>
-
-
diff --git a/app/views/search/people.rhtml b/app/views/search/people.rhtml
index ec51837..62c2d84 100644
--- a/app/views/search/people.rhtml
+++ b/app/views/search/people.rhtml
@@ -11,7 +11,6 @@
<%= _('(recently added)') %>
<% end %>
- <%= render :partial => 'directory' %>
<% else %>
<%= @asset_name %>: <%= h(@category ? (_('Search results for "%{query}" in "%{category}"') % { :query => @query, :category => @category.name}) : (_('Search results for "%s"') % @query)) %>
diff --git a/public/designs/themes/zen3/stylesheets/controller_search.css b/public/designs/themes/zen3/stylesheets/controller_search.css
index 8179a00..241b7d9 100644
--- a/public/designs/themes/zen3/stylesheets/controller_search.css
+++ b/public/designs/themes/zen3/stylesheets/controller_search.css
@@ -1,8 +1,3 @@
-
-.search-index {
- color: #EA5;
-}
-
#view-category,
#search-results {
padding: 0% 2%;
diff --git a/public/stylesheets/controller_search.css b/public/stylesheets/controller_search.css
index e19d99a..6113bc7 100644
--- a/public/stylesheets/controller_search.css
+++ b/public/stylesheets/controller_search.css
@@ -2,17 +2,6 @@
position: relative; /* to the text appear on MSIE 6 */
}
-.search-index {
- text-align: center;
- position: relative;
- font-weight: bold;
-}
-
-.search-index a {
- text-decoration: none;
- font-weight: normal;
-}
-
#search-results {
margin-top: 10px;
/* none by default, but... Who knows the future? :-) */
diff --git a/test/functional/search_controller_test.rb b/test/functional/search_controller_test.rb
index 9b3a184..91d6c0a 100644
--- a/test/functional/search_controller_test.rb
+++ b/test/functional/search_controller_test.rb
@@ -514,138 +514,6 @@ class SearchControllerTest < Test::Unit::TestCase
assert_no_tag :tag => 'input', :attributes => { :name => 'find_in[]', :value => 'products', :checked => 'checked' }
end
- ############## directory ####################
- should 'link to people directory in index' do
- get :assets, :asset => 'people'
- assert_tag :tag => 'a', :attributes => { :href => '/directory/people/a'}, :content => 'A'
- assert_tag :tag => 'a', :attributes => { :href => '/directory/people/b'}, :content => 'B'
- end
-
- should 'display link in people directory to other initials but not to the same' do
- get :directory, :asset => 'people', :initial => 'r'
- assert_tag :tag => 'a', :attributes => { :href => '/directory/people/a' }
- assert_no_tag :tag => 'a', :attributes => { :href => '/directory/people/r' }
- end
-
- should 'display link to recent people while in directory' do
- get :directory, :asset => 'people', :initial => 'a'
- assert_tag :tag => 'a', :attributes => { :href => '/assets/people' }, :content => 'Recent'
- end
-
- should 'not leave category in link to other char in directory' do
- cat = Category.create!(:name => 'just_a_category', :environment => Environment.default)
- get :directory, :asset => 'people', :initial => 'r', :category_path => cat.path.split('/')
- assert_tag :tag => 'a', :attributes => { :href => "/directory/people/k/#{cat.path}" }
- end
-
- ############### directory for every kind of asset #################
- should 'display people with a given initial' do
- included = create_user('fergunson').person
- not_included = create_user('yanerson').person
-
- get :directory, :asset => 'people', :initial => 'f'
- assert_includes assigns(:results)[:people], included
- assert_not_includes assigns(:results)[:people], not_included
- end
-
- should 'display communities with a given initial' do
- c1 = Community.create!(:name => 'a beautiful community', :identifier => 'bea_comm', :environment => Environment.default)
- c2 = Community.create!(:name => 'beautiful community (another)', :identifier => 'an_bea_comm', :environment => Environment.default)
-
- get :directory, :asset => 'communities', :initial => 'a'
-
- assert_includes assigns(:results)[:communities], c1
- assert_not_includes assigns(:results)[:communities], c2
- end
-
- should 'display enterprises with a given initial' do
- ent1 = Enterprise.create!(:name => 'aaaaa', :identifier => 'teste1')
- ent2 = Enterprise.create!(:name => 'bbbbb', :identifier => 'teste2')
-
- get :directory, :asset => 'enterprises', :initial => 'a'
-
- assert_includes assigns(:results)[:enterprises], ent1
- assert_not_includes assigns(:results)[:enterprises], ent2
- end
-
- should 'display articles with a given initial' do
- person = create_user('teste').person
- art1 = person.articles.build(:name => 'an article to be found'); art1.save!
- art2 = person.articles.build(:name => 'better article'); art2.save!
-
- get :directory, :asset => 'articles', :initial => 'a'
-
- assert_includes assigns(:results)[:articles], art1
- assert_not_includes assigns(:results)[:articles], art2
- end
-
- should 'display people with a given initial, under a specific category' do
-
- in_category_and_with_initial = create_user('fergunson').person
- in_category_and_with_initial.add_category @category
-
- in_category_but_without_initial = create_user('yanerson').person
- in_category_but_without_initial.add_category @category
-
- not_in_category_but_with_initial = create_user('fergy').person
- not_in_category_and_without_initial = create_user('xalanxalan').person
-
- get :directory, :asset => 'people', :initial => 'f', :category_path => [ 'my-category' ]
-
- assert_includes assigns(:results)[:people], in_category_and_with_initial
- assert_not_includes assigns(:results)[:people], in_category_but_without_initial
- assert_not_includes assigns(:results)[:people], not_in_category_but_with_initial
- assert_not_includes assigns(:results)[:people], not_in_category_and_without_initial
- end
-
- should 'display communities with a given initial, under a specific category' do
- c1 = Community.create!(:name => 'a beautiful community', :identifier => 'bea_comm', :environment => Environment.default); c1.add_category @category
- c2 = Community.create!(:name => 'beautiful community (another)', :identifier => 'an_bea_comm', :environment => Environment.default); c2.add_category @category
-
- c3 = Community.create!(:name => 'another beautiful community', :identifier => 'lalala', :environment => Environment.default);
- c4 = Community.create!(:name => 'damn beautiful community (another)', :identifier => 'lelele', :environment => Environment.default)
-
- get :directory, :asset => 'communities', :initial => 'a', :category_path => [ 'my-category' ]
-
- assert_includes assigns(:results)[:communities], c1
- assert_not_includes assigns(:results)[:communities], c2
- assert_not_includes assigns(:results)[:communities], c3
- assert_not_includes assigns(:results)[:communities], c4
- end
-
- should 'display enterprises with a given initial, under a specific category' do
- ent1 = Enterprise.create!(:name => 'aaaaa', :identifier => 'teste1'); ent1.add_category @category
- ent2 = Enterprise.create!(:name => 'bbbbb', :identifier => 'teste2'); ent1.add_category @category
- ent3 = Enterprise.create!(:name => 'aaaa1111', :identifier => 'teste1111')
- ent4 = Enterprise.create!(:name => 'ddddd', :identifier => 'teste2222')
-
- get :directory, :asset => 'enterprises', :initial => 'a', :category_path => [ 'my-category' ]
-
- assert_includes assigns(:results)[:enterprises], ent1
- assert_not_includes assigns(:results)[:enterprises], ent2
- assert_not_includes assigns(:results)[:enterprises], ent3
- assert_not_includes assigns(:results)[:enterprises], ent4
- end
-
- should 'display articles with a given initial, under a specific category' do
- person = create_user('teste').person
- art1 = person.articles.build(:name => 'an article to be found'); art1.save!
- art1.add_category @category
- art2 = person.articles.build(:name => 'better article'); art2.save!
- art2.add_category @category
-
- art3 = person.articles.build(:name => 'another article to be found'); art3.save!
- art4 = person.articles.build(:name => 'damn article'); art4.save!
-
-
- get :directory, :asset => 'articles', :initial => 'a', :category_path => [ 'my-category' ]
-
- assert_includes assigns(:results)[:articles], art1
- assert_not_includes assigns(:results)[:articles], art2
- assert_not_includes assigns(:results)[:articles], art3
- assert_not_includes assigns(:results)[:articles], art4
- end
-
should 'find enterprise by product category' do
ent1 = Enterprise.create!(:name => 'test1', :identifier => 'test1')
prod_cat = ProductCategory.create!(:name => 'pctest', :environment => Environment.default)
diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb
index 04b9147..2de5d6f 100644
--- a/test/unit/article_test.rb
+++ b/test/unit/article_test.rb
@@ -211,18 +211,6 @@ class ArticleTest < Test::Unit::TestCase
assert_equal [articles[1], articles[0]], person.articles.most_commented(2)
end
- should 'find by initial' do
- person = create_user('testuser').person
-
- a1 = person.articles.create!(:name => 'An nice article')
- a2 = person.articles.create!(:name => 'Better stay off here')
-
- list = Article.find_by_initial('a')
-
- assert_includes list, a1
- assert_not_includes list, a2
- end
-
should 'identify itself as a non-folder' do
assert !Article.new.folder?, 'should identify itself as non-folder'
end
diff --git a/test/unit/category_finder_test.rb b/test/unit/category_finder_test.rb
index 5054d8f..98e7f25 100644
--- a/test/unit/category_finder_test.rb
+++ b/test/unit/category_finder_test.rb
@@ -111,34 +111,6 @@ class CategoryFinderTest < ActiveSupport::TestCase
assert_includes f.find(:articles, 'beautiful'), article
end
- should 'find communites by initial in category hierarchy' do
- parent = Category.create!(:name => 'parent category', :environment => Environment.default)
- child = Category.create!(:name => 'child category', :environment => Environment.default, :parent => parent)
- p1 = create_user('people_1').person
- p1.name = 'person with inner beaity'
- p1.add_category(child)
- p1.save!
-
- parent.reload
-
- f = CategoryFinder.new(parent)
- assert_includes f.find_by_initial(:people, 'p'), p1
- end
-
- should 'find articles by initial in category hierarchy' do
- parent = Category.create!(:name => 'parent category', :environment => Environment.default)
- child = Category.create!(:name => 'child category', :environment => Environment.default, :parent => parent)
-
- p1 = create_user('people_1').person
-
- article = p1.articles.create!(:name => 'fucking beautiful article', :category_ids => [child.id])
-
- parent.reload
-
- f = CategoryFinder.new(parent)
- assert_includes f.find_by_initial(:articles, 'f'), article
- end
-
should 'list recent enterprises' do
ent = Enterprise.create!(:name => 'teste', :identifier => 'teste', :category_ids => [@category.id])
assert_includes @finder.recent('enterprises'), ent
@@ -276,60 +248,6 @@ class CategoryFinderTest < ActiveSupport::TestCase
assert_equal [articles[1], articles[0]], @finder.most_commented_articles(2)
end
- should 'find people by initial' do
- p1 = create_user('aaaa').person; p1.add_category(@category)
- p2 = create_user('bbbb').person; p2.add_category(@category)
-
- list = CategoryFinder.new(@category).find_by_initial(:people, 'a')
-
- assert_includes list, p1
- assert_not_includes list, p2
- end
-
- should 'find enterprises by initial' do
- ent1 = Enterprise.create!(:name => 'aaaa', :identifier => 'aaaa'); ent1.add_category(@category)
- ent2 = Enterprise.create!(:name => 'bbbb', :identifier => 'bbbb'); ent2.add_category(@category)
-
- list = CategoryFinder.new(@category).find_by_initial(:enterprises, 'a')
-
- assert_includes list, ent1
- assert_not_includes list, ent2
- end
-
- should 'find communities by initial' do
- comm1 = Community.create!(:name => 'aaaa', :identifier => 'aaaa'); comm1.add_category(@category)
- comm2 = Community.create!(:name => 'bbbb', :identifier => 'bbbb'); comm2.add_category(@category)
-
- list = CategoryFinder.new(@category).find_by_initial(:communities, 'a')
-
- assert_includes list, comm1
- assert_not_includes list, comm2
- end
-
- should 'find products by initial' do
- ent = Enterprise.create!(:name => 'my enterprise', :identifier => 'myent')
- ent.add_category(@category)
-
- p1 = ent.products.create!(:name => 'A product')
- p2 = ent.products.create!(:name => 'Better product')
-
- list = CategoryFinder.new(@category).find_by_initial(:products, 'a')
-
- assert_includes list, p1
- assert_not_includes list, p2
- end
-
- should 'find articles by initial' do
- person = create_user('testuser').person
- a1 = person.articles.create!(:name => 'aaaa', :body => '...', :category_ids => [@category.id])
- a2 = person.articles.create!(:name => 'bbbb', :body => '...', :category_ids => [@category.id])
-
- list = CategoryFinder.new(@category).find_by_initial(:articles, 'a')
-
- assert_includes list, a1
- assert_not_includes list, a2
- end
-
should 'find person and enterprise by radius and region' do
finder = CategoryFinder.new(@category)
diff --git a/test/unit/environment_finder_test.rb b/test/unit/environment_finder_test.rb
index 623fc4b..b5b34a1 100644
--- a/test/unit/environment_finder_test.rb
+++ b/test/unit/environment_finder_test.rb
@@ -125,59 +125,6 @@ class EnvironmentFinderTest < ActiveSupport::TestCase
assert_equal 99, finder.count('people', 'my query', {})
end
- should 'find articles by initial' do
- person = create_user('teste').person
- art1 = person.articles.create!(:name => 'an article to be found')
- art2 = person.articles.create!(:name => 'blah: an article that cannot be found')
- found = EnvironmentFinder.new(Environment.default).find_by_initial(:articles, 'a')
-
- assert_includes found, art1
- assert_not_includes found, art2
- end
-
- should 'find people by initial' do
- finder = EnvironmentFinder.new(Environment.default)
- p1 = create_user('alalala').person
- p2 = create_user('blablabla').person
-
- found = finder.find_by_initial(:people, 'a')
- assert_includes found, p1
- assert_not_includes found, p2
- end
-
- should 'find communities by initial' do
- c1 = Community.create!(:name => 'a beautiful community', :identifier => 'bea_comm', :environment => Environment.default)
- c2 = Community.create!(:name => 'b: another beautiful community', :identifier => 'bbbbb', :environment => Environment.default)
-
- found = EnvironmentFinder.new(Environment.default).find_by_initial(:communities, 'a')
-
- assert_includes found, c1
- assert_not_includes found, c2
- end
-
- should 'find products by initial' do
- finder = EnvironmentFinder.new(Environment.default)
- ent = Enterprise.create!(:name => 'teste', :identifier => 'teste')
- prod1 = ent.products.create!(:name => 'a beautiful product')
- prod2 = ent.products.create!(:name => 'b: a beautiful product')
-
- found = finder.find_by_initial(:products, 'a')
-
- assert_includes found, prod1
- assert_not_includes found, prod2
- end
-
- should 'find enterprises by initial' do
- finder = EnvironmentFinder.new(Environment.default)
- ent1 = Enterprise.create!(:name => 'aaaa', :identifier => 'aaaa')
- ent2 = Enterprise.create!(:name => 'bbbb', :identifier => 'bbbb')
-
- found = finder.find_by_initial(:enterprises, 'a')
-
- assert_includes found, ent1
- assert_not_includes found, ent2
- end
-
should 'find person and enterprise by radius and region' do
finder = EnvironmentFinder.new(Environment.default)
diff --git a/test/unit/product_test.rb b/test/unit/product_test.rb
index b6f7588..a6f5de6 100644
--- a/test/unit/product_test.rb
+++ b/test/unit/product_test.rb
@@ -55,18 +55,6 @@ class ProductTest < Test::Unit::TestCase
end
end
- should 'find by initial' do
- p1 = Product.create!(:name => 'a test product')
- p2 = Product.create!(:name => 'A Capitalize Product')
- p3 = Product.create!(:name => 'b-class test product')
-
- list = Product.find_by_initial('a')
-
- assert_includes list, p1
- assert_includes list, p2
- assert_not_includes list, p3
- end
-
should 'calculate catagory full name' do
cat = mock
cat.expects(:full_name).returns('A/B/C')
diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb
index 635f28f..528e6b0 100644
--- a/test/unit/profile_test.rb
+++ b/test/unit/profile_test.rb
@@ -437,16 +437,6 @@ class ProfileTest < Test::Unit::TestCase
assert profile.articles.find_by_path('feed').advertise?
end
- should 'find by initial' do
- inside = Profile.create!(:name => 'A person', :identifier => 'aperson')
- outside = Profile.create!(:name => 'B Movie', :identifier => 'bmovie')
-
- list = Profile.find_by_initial('a')
-
- assert_includes list, inside
- assert_not_includes list, outside
- end
-
should 'have latitude and longitude' do
e = Enterprise.create!(:name => 'test1', :identifier => 'test1')
e.lat, e.lng = 45, 45 ; e.save!
--
libgit2 0.21.2