From 807a5056bc519e5823144d52d41987fac9c047ba Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Fri, 19 Oct 2007 18:43:36 +0000 Subject: [PATCH] ActionItem111: search is now functional --- app/controllers/public/search_controller.rb | 6 ++++++ app/helpers/application_helper.rb | 14 +++++++++++++- app/helpers/search_helper.rb | 2 ++ app/models/article.rb | 1 + app/views/layouts/application.rhtml | 5 +---- app/views/search/index.rhtml | 6 ++++++ config/routes.rb | 3 +++ po/noosfero.pot | 697 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------- po/pt_BR/noosfero.po | 867 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------- test/functional/search_controller_test.rb | 18 ++++++++++++++++++ 10 files changed, 1364 insertions(+), 255 deletions(-) create mode 100644 app/controllers/public/search_controller.rb create mode 100644 app/helpers/search_helper.rb create mode 100644 app/views/search/index.rhtml create mode 100644 test/functional/search_controller_test.rb diff --git a/app/controllers/public/search_controller.rb b/app/controllers/public/search_controller.rb new file mode 100644 index 0000000..a47c66d --- /dev/null +++ b/app/controllers/public/search_controller.rb @@ -0,0 +1,6 @@ +class SearchController < ApplicationController + def index + @query = params[:query] + @results = Article.find_tagged_with(@query) + Article.find_by_contents(@query) + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 36da6e9..b928d2d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -208,7 +208,7 @@ module ApplicationHelper end def design_links - links = [ + links = desig[ [(link_to _('Change template'), :controller => 'profile_editor', :action => 'design_editor_change_template')], [(link_to _('Change block theme'), :controller => 'profile_editor', :action => 'design_editor_change_theme')], [(link_to _('Change icon theme'), :controller => 'profile_editor', :action => 'design_editor_change_icon_theme')], @@ -245,6 +245,9 @@ module ApplicationHelper end.map{|l| link_if_permitted(l[0], l[1], l[2]) } end +# def user_options +# end + def accessibility_link doc = Article.find_all_by_title(_('Accessibility')).select do |a| a.full_path.split(/\//).shift == 'noosfero' @@ -252,6 +255,15 @@ module ApplicationHelper link_to_document doc, _('Accessibility') if doc end + def search_box + [form_tag( '/search'), + text_field_tag( 'query', _(''), :id => "input_search"), + submit_tag(_('Search'), :id => 'button_search'), + '', + observe_field('input_search', :function => '', :on => :click) + ].join("\n") + end + def footer # FIXME: add some information from the environment [ diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb new file mode 100644 index 0000000..b3ce20a --- /dev/null +++ b/app/helpers/search_helper.rb @@ -0,0 +1,2 @@ +module SearchHelper +end diff --git a/app/models/article.rb b/app/models/article.rb index 338a0db..1d2775f 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -1,6 +1,7 @@ class Article < Comatose::Page acts_as_taggable + acts_as_ferret :fields => [:title, :body] def keywords tag_list.to_s end diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index f42a6df..456a77c 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -77,10 +77,7 @@