@scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents) )\r
\r
if @token and @token.length > 2\r
+ @token.strip!\r
+ like_token = "%#{@token}%"\r
@results = []\r
- @results += @project.issues.find(:all, :include => :author, :conditions => ["issues.subject like ?", "%#{@token}%"] ) if @scope.include? 'issues'\r
- @results += @project.news.find(:all, :conditions => ["news.title like ?", "%#{@token}%"], :include => :author ) if @scope.include? 'news'\r
- @results += @project.documents.find(:all, :conditions => ["title like ?", "%#{@token}%"] ) if @scope.include? 'documents'\r
+ @results += @project.issues.find(:all, :include => :author, :conditions => ["issues.subject like ? or issues.description like ?", like_token, like_token] ) if @scope.include? 'issues'\r
+ @results += @project.news.find(:all, :conditions => ["news.title like ? or news.description like ?", like_token, like_token], :include => :author ) if @scope.include? 'news'\r
+ @results += @project.documents.find(:all, :conditions => ["title like ? or description like ?", like_token, like_token] ) if @scope.include? 'documents'\r
end\r
end\r
\r
# along with this program; if not, write to the Free Software\r
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
\r
-module ProjectsHelper
+module ProjectsHelper\r
+ def result_overview(text, token)\r
+ match = excerpt(text, token)\r
+ match ? highlight(match, token) : truncate(text, 150)\r
+ end
end
<% @results.each do |e| %>\r
<li><p>\r
<% if e.is_a? Issue %>\r
- <%= link_to "#{e.tracker.name} ##{e.id}", :controller => 'issues', :action => 'show', :id => e %>: <%= highlight(h(e.subject), @token) %><br />\r
- <i><%= e.author.name %>, <%= format_time(e.created_on) %></i>\r
+ <%= link_to "#{e.tracker.name} ##{e.id}", :controller => 'issues', :action => 'show', :id => e %>: <%= highlight(h(e.subject), @token) %><br />\r
+ <%= result_overview(e.description, @token) %><br />\r
+ <i><%= e.author.name %>, <%= format_time(e.created_on) %></i>\r
<% elsif e.is_a? News %>\r
- <%=l(:label_news)%>: <%= link_to highlight(h(e.title), @token), :controller => 'news', :action => 'show', :id => e %><br />\r
- <% unless e.summary.empty? %><%=h e.summary %><br /><% end %>\r
- <i><%= e.author.name %>, <%= format_time(e.created_on) %></i>\r
+ <%=l(:label_news)%>: <%= link_to highlight(h(e.title), @token), :controller => 'news', :action => 'show', :id => e %><br />\r
+ <%= result_overview(e.description, @token) %><br />\r
+ <i><%= e.author.name %>, <%= format_time(e.created_on) %></i>\r
<% elsif e.is_a? Document %>\r
- <%=l(:label_document)%>: <%= link_to highlight(h(e.title), @token), :controller => 'documents', :action => 'show', :id => e %><br />\r
- <i><%= format_time(e.created_on) %></i>\r
+ <%=l(:label_document)%>: <%= link_to highlight(h(e.title), @token), :controller => 'documents', :action => 'show', :id => e %><br />\r
+ <%= result_overview(e.description, @token) %><br />\r
+ <i><%= format_time(e.created_on) %></i>\r
<% end %>\r
</p></li> \r
<% end %>\r
--- \r
+permissions_052: \r
+ action: destroy_comment\r
+ id: 52\r
+ description: label_comment_delete\r
+ controller: news\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1133\r
+ is_public: false\r
permissions_041: \r
action: add_file\r
id: 41\r
description: button_add\r
controller: projects\r
mail_enabled: false\r
- mail_option: false\r
+ mail_option: true\r
sort: 1320\r
is_public: false\r
permissions_030: \r
mail_option: false\r
sort: 221\r
is_public: false\r
+permissions_053: \r
+ action: add_query\r
+ id: 53\r
+ description: button_create\r
+ controller: projects\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 600\r
+ is_public: false\r
permissions_042: \r
action: destroy_file\r
id: 42\r
mail_option: false\r
sort: 222\r
is_public: false\r
+permissions_054: \r
+ action: show\r
+ id: 54\r
+ description: button_view\r
+ controller: repositories\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1450\r
+ is_public: true\r
+permissions_043: \r
+ action: move_issues\r
+ id: 43\r
+ description: button_move\r
+ controller: projects\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1061\r
+ is_public: false\r
permissions_032: \r
action: show\r
id: 32\r
mail_option: false\r
sort: 320\r
is_public: false\r
+permissions_055: \r
+ action: browse\r
+ id: 55\r
+ description: label_browse\r
+ controller: repositories\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1460\r
+ is_public: true\r
+permissions_044: \r
+ action: add_note\r
+ id: 44\r
+ description: label_add_note\r
+ controller: issues\r
+ mail_enabled: false\r
+ mail_option: true\r
+ sort: 1057\r
+ is_public: false\r
permissions_033: \r
action: download\r
id: 33\r
mail_option: false\r
sort: 321\r
is_public: false\r
+permissions_056: \r
+ action: entry\r
+ id: 56\r
+ description: entry\r
+ controller: repositories\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1462\r
+ is_public: true\r
+permissions_045: \r
+ action: export_issues_pdf\r
+ id: 45\r
+ description: label_export_pdf\r
+ controller: projects\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1002\r
+ is_public: true\r
permissions_034: \r
action: add_document\r
id: 34\r
description: button_add\r
controller: projects\r
mail_enabled: false\r
- mail_option: false\r
+ mail_option: true\r
sort: 1220\r
is_public: false\r
permissions_023: \r
mail_option: false\r
sort: 100\r
is_public: true\r
+permissions_057: \r
+ action: revisions\r
+ id: 57\r
+ description: label_view_revisions\r
+ controller: repositories\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1470\r
+ is_public: true\r
+permissions_046: \r
+ action: export_pdf\r
+ id: 46\r
+ description: label_export_pdf\r
+ controller: issues\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1015\r
+ is_public: true\r
permissions_035: \r
action: edit\r
id: 35\r
description: label_attachment_new\r
controller: issues\r
mail_enabled: false\r
- mail_option: false\r
+ mail_option: true\r
sort: 1070\r
is_public: false\r
permissions_013: \r
mail_option: false\r
sort: 105\r
is_public: true\r
+permissions_058: \r
+ action: revision\r
+ id: 58\r
+ description: label_view_revisions\r
+ controller: repositories\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1472\r
+ is_public: true\r
+permissions_047: \r
+ action: activity\r
+ id: 47\r
+ description: label_activity\r
+ controller: projects\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 160\r
+ is_public: true\r
permissions_036: \r
action: destroy\r
id: 36\r
mail_option: false\r
sort: 110\r
is_public: true\r
+permissions_059: \r
+ action: diff\r
+ id: 59\r
+ description: diff\r
+ controller: repositories\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1480\r
+ is_public: true\r
+permissions_048: \r
+ action: calendar\r
+ id: 48\r
+ description: label_calendar\r
+ controller: projects\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 165\r
+ is_public: true\r
permissions_037: \r
action: add_attachment\r
id: 37\r
description: label_attachment_new\r
controller: documents\r
mail_enabled: false\r
- mail_option: false\r
+ mail_option: true\r
sort: 1223\r
is_public: false\r
permissions_026: \r
mail_option: false\r
sort: 150\r
is_public: false\r
+permissions_060: \r
+ action: search\r
+ id: 61\r
+ description: label_search\r
+ controller: projects\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 130\r
+ is_public: true\r
+permissions_049: \r
+ action: gantt\r
+ id: 49\r
+ description: label_gantt\r
+ controller: projects\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 166\r
+ is_public: true\r
permissions_038: \r
action: destroy_attachment\r
id: 38\r
mail_option: false\r
sort: 151\r
is_public: false\r
+permissions_050: \r
+ action: history\r
+ id: 50\r
+ description: label_history\r
+ controller: issues\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1006\r
+ is_public: true\r
permissions_039: \r
action: list_files\r
id: 39\r
mail_option: false\r
sort: 200\r
is_public: true\r
+permissions_051: \r
+ action: add_comment\r
+ id: 51\r
+ description: label_comment_add\r
+ controller: news\r
+ mail_enabled: false\r
+ mail_option: false\r
+ sort: 1130\r
+ is_public: false\r
permissions_040: \r
action: download\r
id: 40\r
assert_template 'changelog'\r
assert_not_nil assigns(:fixed_issues)\r
end
+
+ def test_search
+ get :search, :id => 1
+ assert_response :success
+ assert_template 'search'
+
+ get :search, :id => 1, :token => "can", :scope => ["issues", "news", "documents"]
+ assert_response :success
+ assert_template 'search'
+ end
end