@@ -544,10 +544,12 class ProjectsController < ApplicationController | |||
|
544 | 544 | @scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents) ) |
|
545 | 545 | |
|
546 | 546 | if @token and @token.length > 2 |
|
547 | @token.strip! | |
|
548 | like_token = "%#{@token}%" | |
|
547 | 549 | @results = [] |
|
548 |
@results += @project.issues.find(:all, :include => :author, :conditions => ["issues.subject like ?", |
|
|
549 |
@results += @project.news.find(:all, :conditions => ["news.title like ?", |
|
|
550 |
@results += @project.documents.find(:all, :conditions => ["title like ?", |
|
|
550 | @results += @project.issues.find(:all, :include => :author, :conditions => ["issues.subject like ? or issues.description like ?", like_token, like_token] ) if @scope.include? 'issues' | |
|
551 | @results += @project.news.find(:all, :conditions => ["news.title like ? or news.description like ?", like_token, like_token], :include => :author ) if @scope.include? 'news' | |
|
552 | @results += @project.documents.find(:all, :conditions => ["title like ? or description like ?", like_token, like_token] ) if @scope.include? 'documents' | |
|
551 | 553 | end |
|
552 | 554 | end |
|
553 | 555 |
@@ -15,5 +15,9 | |||
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | module ProjectsHelper | |
|
18 | module ProjectsHelper | |
|
19 | def result_overview(text, token) | |
|
20 | match = excerpt(text, token) | |
|
21 | match ? highlight(match, token) : truncate(text, 150) | |
|
22 | end | |
|
19 | 23 | end |
@@ -16,15 +16,17 | |||
|
16 | 16 | <% @results.each do |e| %> |
|
17 | 17 | <li><p> |
|
18 | 18 | <% if e.is_a? Issue %> |
|
19 | <%= link_to "#{e.tracker.name} ##{e.id}", :controller => 'issues', :action => 'show', :id => e %>: <%= highlight(h(e.subject), @token) %><br /> | |
|
20 | <i><%= e.author.name %>, <%= format_time(e.created_on) %></i> | |
|
19 | <%= link_to "#{e.tracker.name} ##{e.id}", :controller => 'issues', :action => 'show', :id => e %>: <%= highlight(h(e.subject), @token) %><br /> | |
|
20 | <%= result_overview(e.description, @token) %><br /> | |
|
21 | <i><%= e.author.name %>, <%= format_time(e.created_on) %></i> | |
|
21 | 22 | <% elsif e.is_a? News %> |
|
22 | <%=l(:label_news)%>: <%= link_to highlight(h(e.title), @token), :controller => 'news', :action => 'show', :id => e %><br /> | |
|
23 | <% unless e.summary.empty? %><%=h e.summary %><br /><% end %> | |
|
24 |
|
|
|
23 | <%=l(:label_news)%>: <%= link_to highlight(h(e.title), @token), :controller => 'news', :action => 'show', :id => e %><br /> | |
|
24 | <%= result_overview(e.description, @token) %><br /> | |
|
25 | <i><%= e.author.name %>, <%= format_time(e.created_on) %></i> | |
|
25 | 26 | <% elsif e.is_a? Document %> |
|
26 | <%=l(:label_document)%>: <%= link_to highlight(h(e.title), @token), :controller => 'documents', :action => 'show', :id => e %><br /> | |
|
27 |
|
|
|
27 | <%=l(:label_document)%>: <%= link_to highlight(h(e.title), @token), :controller => 'documents', :action => 'show', :id => e %><br /> | |
|
28 | <%= result_overview(e.description, @token) %><br /> | |
|
29 | <i><%= format_time(e.created_on) %></i> | |
|
28 | 30 | <% end %> |
|
29 | 31 | </p></li> |
|
30 | 32 | <% end %> |
@@ -1,11 +1,20 | |||
|
1 | 1 | --- |
|
2 | permissions_052: | |
|
3 | action: destroy_comment | |
|
4 | id: 52 | |
|
5 | description: label_comment_delete | |
|
6 | controller: news | |
|
7 | mail_enabled: false | |
|
8 | mail_option: false | |
|
9 | sort: 1133 | |
|
10 | is_public: false | |
|
2 | 11 | permissions_041: |
|
3 | 12 | action: add_file |
|
4 | 13 | id: 41 |
|
5 | 14 | description: button_add |
|
6 | 15 | controller: projects |
|
7 | 16 | mail_enabled: false |
|
8 |
mail_option: |
|
|
17 | mail_option: true | |
|
9 | 18 | sort: 1320 |
|
10 | 19 | is_public: false |
|
11 | 20 | permissions_030: |
@@ -35,6 +44,15 permissions_008: | |||
|
35 | 44 | mail_option: false |
|
36 | 45 | sort: 221 |
|
37 | 46 | is_public: false |
|
47 | permissions_053: | |
|
48 | action: add_query | |
|
49 | id: 53 | |
|
50 | description: button_create | |
|
51 | controller: projects | |
|
52 | mail_enabled: false | |
|
53 | mail_option: false | |
|
54 | sort: 600 | |
|
55 | is_public: false | |
|
38 | 56 | permissions_042: |
|
39 | 57 | action: destroy_file |
|
40 | 58 | id: 42 |
@@ -71,6 +89,24 permissions_009: | |||
|
71 | 89 | mail_option: false |
|
72 | 90 | sort: 222 |
|
73 | 91 | is_public: false |
|
92 | permissions_054: | |
|
93 | action: show | |
|
94 | id: 54 | |
|
95 | description: button_view | |
|
96 | controller: repositories | |
|
97 | mail_enabled: false | |
|
98 | mail_option: false | |
|
99 | sort: 1450 | |
|
100 | is_public: true | |
|
101 | permissions_043: | |
|
102 | action: move_issues | |
|
103 | id: 43 | |
|
104 | description: button_move | |
|
105 | controller: projects | |
|
106 | mail_enabled: false | |
|
107 | mail_option: false | |
|
108 | sort: 1061 | |
|
109 | is_public: false | |
|
74 | 110 | permissions_032: |
|
75 | 111 | action: show |
|
76 | 112 | id: 32 |
@@ -98,6 +134,24 permissions_010: | |||
|
98 | 134 | mail_option: false |
|
99 | 135 | sort: 320 |
|
100 | 136 | is_public: false |
|
137 | permissions_055: | |
|
138 | action: browse | |
|
139 | id: 55 | |
|
140 | description: label_browse | |
|
141 | controller: repositories | |
|
142 | mail_enabled: false | |
|
143 | mail_option: false | |
|
144 | sort: 1460 | |
|
145 | is_public: true | |
|
146 | permissions_044: | |
|
147 | action: add_note | |
|
148 | id: 44 | |
|
149 | description: label_add_note | |
|
150 | controller: issues | |
|
151 | mail_enabled: false | |
|
152 | mail_option: true | |
|
153 | sort: 1057 | |
|
154 | is_public: false | |
|
101 | 155 | permissions_033: |
|
102 | 156 | action: download |
|
103 | 157 | id: 33 |
@@ -125,13 +179,31 permissions_011: | |||
|
125 | 179 | mail_option: false |
|
126 | 180 | sort: 321 |
|
127 | 181 | is_public: false |
|
182 | permissions_056: | |
|
183 | action: entry | |
|
184 | id: 56 | |
|
185 | description: entry | |
|
186 | controller: repositories | |
|
187 | mail_enabled: false | |
|
188 | mail_option: false | |
|
189 | sort: 1462 | |
|
190 | is_public: true | |
|
191 | permissions_045: | |
|
192 | action: export_issues_pdf | |
|
193 | id: 45 | |
|
194 | description: label_export_pdf | |
|
195 | controller: projects | |
|
196 | mail_enabled: false | |
|
197 | mail_option: false | |
|
198 | sort: 1002 | |
|
199 | is_public: true | |
|
128 | 200 | permissions_034: |
|
129 | 201 | action: add_document |
|
130 | 202 | id: 34 |
|
131 | 203 | description: button_add |
|
132 | 204 | controller: projects |
|
133 | 205 | mail_enabled: false |
|
134 |
mail_option: |
|
|
206 | mail_option: true | |
|
135 | 207 | sort: 1220 |
|
136 | 208 | is_public: false |
|
137 | 209 | permissions_023: |
@@ -161,6 +233,24 permissions_001: | |||
|
161 | 233 | mail_option: false |
|
162 | 234 | sort: 100 |
|
163 | 235 | is_public: true |
|
236 | permissions_057: | |
|
237 | action: revisions | |
|
238 | id: 57 | |
|
239 | description: label_view_revisions | |
|
240 | controller: repositories | |
|
241 | mail_enabled: false | |
|
242 | mail_option: false | |
|
243 | sort: 1470 | |
|
244 | is_public: true | |
|
245 | permissions_046: | |
|
246 | action: export_pdf | |
|
247 | id: 46 | |
|
248 | description: label_export_pdf | |
|
249 | controller: issues | |
|
250 | mail_enabled: false | |
|
251 | mail_option: false | |
|
252 | sort: 1015 | |
|
253 | is_public: true | |
|
164 | 254 | permissions_035: |
|
165 | 255 | action: edit |
|
166 | 256 | id: 35 |
@@ -176,7 +266,7 permissions_024: | |||
|
176 | 266 | description: label_attachment_new |
|
177 | 267 | controller: issues |
|
178 | 268 | mail_enabled: false |
|
179 |
mail_option: |
|
|
269 | mail_option: true | |
|
180 | 270 | sort: 1070 |
|
181 | 271 | is_public: false |
|
182 | 272 | permissions_013: |
@@ -197,6 +287,24 permissions_002: | |||
|
197 | 287 | mail_option: false |
|
198 | 288 | sort: 105 |
|
199 | 289 | is_public: true |
|
290 | permissions_058: | |
|
291 | action: revision | |
|
292 | id: 58 | |
|
293 | description: label_view_revisions | |
|
294 | controller: repositories | |
|
295 | mail_enabled: false | |
|
296 | mail_option: false | |
|
297 | sort: 1472 | |
|
298 | is_public: true | |
|
299 | permissions_047: | |
|
300 | action: activity | |
|
301 | id: 47 | |
|
302 | description: label_activity | |
|
303 | controller: projects | |
|
304 | mail_enabled: false | |
|
305 | mail_option: false | |
|
306 | sort: 160 | |
|
307 | is_public: true | |
|
200 | 308 | permissions_036: |
|
201 | 309 | action: destroy |
|
202 | 310 | id: 36 |
@@ -233,13 +341,31 permissions_003: | |||
|
233 | 341 | mail_option: false |
|
234 | 342 | sort: 110 |
|
235 | 343 | is_public: true |
|
344 | permissions_059: | |
|
345 | action: diff | |
|
346 | id: 59 | |
|
347 | description: diff | |
|
348 | controller: repositories | |
|
349 | mail_enabled: false | |
|
350 | mail_option: false | |
|
351 | sort: 1480 | |
|
352 | is_public: true | |
|
353 | permissions_048: | |
|
354 | action: calendar | |
|
355 | id: 48 | |
|
356 | description: label_calendar | |
|
357 | controller: projects | |
|
358 | mail_enabled: false | |
|
359 | mail_option: false | |
|
360 | sort: 165 | |
|
361 | is_public: true | |
|
236 | 362 | permissions_037: |
|
237 | 363 | action: add_attachment |
|
238 | 364 | id: 37 |
|
239 | 365 | description: label_attachment_new |
|
240 | 366 | controller: documents |
|
241 | 367 | mail_enabled: false |
|
242 |
mail_option: |
|
|
368 | mail_option: true | |
|
243 | 369 | sort: 1223 |
|
244 | 370 | is_public: false |
|
245 | 371 | permissions_026: |
@@ -269,6 +395,24 permissions_004: | |||
|
269 | 395 | mail_option: false |
|
270 | 396 | sort: 150 |
|
271 | 397 | is_public: false |
|
398 | permissions_060: | |
|
399 | action: search | |
|
400 | id: 61 | |
|
401 | description: label_search | |
|
402 | controller: projects | |
|
403 | mail_enabled: false | |
|
404 | mail_option: false | |
|
405 | sort: 130 | |
|
406 | is_public: true | |
|
407 | permissions_049: | |
|
408 | action: gantt | |
|
409 | id: 49 | |
|
410 | description: label_gantt | |
|
411 | controller: projects | |
|
412 | mail_enabled: false | |
|
413 | mail_option: false | |
|
414 | sort: 166 | |
|
415 | is_public: true | |
|
272 | 416 | permissions_038: |
|
273 | 417 | action: destroy_attachment |
|
274 | 418 | id: 38 |
@@ -305,6 +449,15 permissions_005: | |||
|
305 | 449 | mail_option: false |
|
306 | 450 | sort: 151 |
|
307 | 451 | is_public: false |
|
452 | permissions_050: | |
|
453 | action: history | |
|
454 | id: 50 | |
|
455 | description: label_history | |
|
456 | controller: issues | |
|
457 | mail_enabled: false | |
|
458 | mail_option: false | |
|
459 | sort: 1006 | |
|
460 | is_public: true | |
|
308 | 461 | permissions_039: |
|
309 | 462 | action: list_files |
|
310 | 463 | id: 39 |
@@ -341,6 +494,15 permissions_006: | |||
|
341 | 494 | mail_option: false |
|
342 | 495 | sort: 200 |
|
343 | 496 | is_public: true |
|
497 | permissions_051: | |
|
498 | action: add_comment | |
|
499 | id: 51 | |
|
500 | description: label_comment_add | |
|
501 | controller: news | |
|
502 | mail_enabled: false | |
|
503 | mail_option: false | |
|
504 | sort: 1130 | |
|
505 | is_public: false | |
|
344 | 506 | permissions_040: |
|
345 | 507 | action: download |
|
346 | 508 | id: 40 |
@@ -111,4 +111,14 class ProjectsControllerTest < Test::Unit::TestCase | |||
|
111 | 111 | assert_template 'changelog' |
|
112 | 112 | assert_not_nil assigns(:fixed_issues) |
|
113 | 113 | end |
|
114 | ||
|
115 | def test_search | |
|
116 | get :search, :id => 1 | |
|
117 | assert_response :success | |
|
118 | assert_template 'search' | |
|
119 | ||
|
120 | get :search, :id => 1, :token => "can", :scope => ["issues", "news", "documents"] | |
|
121 | assert_response :success | |
|
122 | assert_template 'search' | |
|
123 | end | |
|
114 | 124 | end |
General Comments 0
You need to be logged in to leave comments.
Login now