@@ -544,10 +544,12 class ProjectsController < ApplicationController | |||||
544 | @scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents) ) |
|
544 | @scope = params[:scope] || (params[:submit] ? [] : %w(issues news documents) ) | |
545 |
|
545 | |||
546 | if @token and @token.length > 2 |
|
546 | if @token and @token.length > 2 | |
|
547 | @token.strip! | |||
|
548 | like_token = "%#{@token}%" | |||
547 | @results = [] |
|
549 | @results = [] | |
548 |
@results += @project.issues.find(:all, :include => :author, :conditions => ["issues.subject 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' | |
549 |
@results += @project.news.find(:all, :conditions => ["news.title like ?", |
|
551 | @results += @project.news.find(:all, :conditions => ["news.title like ? or news.description like ?", like_token, like_token], :include => :author ) if @scope.include? 'news' | |
550 |
@results += @project.documents.find(:all, :conditions => ["title like ?", |
|
552 | @results += @project.documents.find(:all, :conditions => ["title like ? or description like ?", like_token, like_token] ) if @scope.include? 'documents' | |
551 | end |
|
553 | end | |
552 | end |
|
554 | end | |
553 |
|
555 |
@@ -15,5 +15,9 | |||||
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
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 | end |
|
23 | end |
@@ -16,15 +16,17 | |||||
16 | <% @results.each do |e| %> |
|
16 | <% @results.each do |e| %> | |
17 | <li><p> |
|
17 | <li><p> | |
18 | <% if e.is_a? Issue %> |
|
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 /> |
|
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> |
|
20 | <%= result_overview(e.description, @token) %><br /> | |
|
21 | <i><%= e.author.name %>, <%= format_time(e.created_on) %></i> | |||
21 | <% elsif e.is_a? News %> |
|
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 | <%=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 | <%= result_overview(e.description, @token) %><br /> | |
24 |
|
|
25 | <i><%= e.author.name %>, <%= format_time(e.created_on) %></i> | |
25 | <% elsif e.is_a? Document %> |
|
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 | <%=l(:label_document)%>: <%= link_to highlight(h(e.title), @token), :controller => 'documents', :action => 'show', :id => e %><br /> | |
27 |
|
|
28 | <%= result_overview(e.description, @token) %><br /> | |
|
29 | <i><%= format_time(e.created_on) %></i> | |||
28 | <% end %> |
|
30 | <% end %> | |
29 | </p></li> |
|
31 | </p></li> | |
30 | <% end %> |
|
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 | permissions_041: |
|
11 | permissions_041: | |
3 | action: add_file |
|
12 | action: add_file | |
4 | id: 41 |
|
13 | id: 41 | |
5 | description: button_add |
|
14 | description: button_add | |
6 | controller: projects |
|
15 | controller: projects | |
7 | mail_enabled: false |
|
16 | mail_enabled: false | |
8 |
mail_option: |
|
17 | mail_option: true | |
9 | sort: 1320 |
|
18 | sort: 1320 | |
10 | is_public: false |
|
19 | is_public: false | |
11 | permissions_030: |
|
20 | permissions_030: | |
@@ -35,6 +44,15 permissions_008: | |||||
35 | mail_option: false |
|
44 | mail_option: false | |
36 | sort: 221 |
|
45 | sort: 221 | |
37 | is_public: false |
|
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 | permissions_042: |
|
56 | permissions_042: | |
39 | action: destroy_file |
|
57 | action: destroy_file | |
40 | id: 42 |
|
58 | id: 42 | |
@@ -71,6 +89,24 permissions_009: | |||||
71 | mail_option: false |
|
89 | mail_option: false | |
72 | sort: 222 |
|
90 | sort: 222 | |
73 | is_public: false |
|
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 | permissions_032: |
|
110 | permissions_032: | |
75 | action: show |
|
111 | action: show | |
76 | id: 32 |
|
112 | id: 32 | |
@@ -98,6 +134,24 permissions_010: | |||||
98 | mail_option: false |
|
134 | mail_option: false | |
99 | sort: 320 |
|
135 | sort: 320 | |
100 | is_public: false |
|
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 | permissions_033: |
|
155 | permissions_033: | |
102 | action: download |
|
156 | action: download | |
103 | id: 33 |
|
157 | id: 33 | |
@@ -125,13 +179,31 permissions_011: | |||||
125 | mail_option: false |
|
179 | mail_option: false | |
126 | sort: 321 |
|
180 | sort: 321 | |
127 | is_public: false |
|
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 | permissions_034: |
|
200 | permissions_034: | |
129 | action: add_document |
|
201 | action: add_document | |
130 | id: 34 |
|
202 | id: 34 | |
131 | description: button_add |
|
203 | description: button_add | |
132 | controller: projects |
|
204 | controller: projects | |
133 | mail_enabled: false |
|
205 | mail_enabled: false | |
134 |
mail_option: |
|
206 | mail_option: true | |
135 | sort: 1220 |
|
207 | sort: 1220 | |
136 | is_public: false |
|
208 | is_public: false | |
137 | permissions_023: |
|
209 | permissions_023: | |
@@ -161,6 +233,24 permissions_001: | |||||
161 | mail_option: false |
|
233 | mail_option: false | |
162 | sort: 100 |
|
234 | sort: 100 | |
163 | is_public: true |
|
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 | permissions_035: |
|
254 | permissions_035: | |
165 | action: edit |
|
255 | action: edit | |
166 | id: 35 |
|
256 | id: 35 | |
@@ -176,7 +266,7 permissions_024: | |||||
176 | description: label_attachment_new |
|
266 | description: label_attachment_new | |
177 | controller: issues |
|
267 | controller: issues | |
178 | mail_enabled: false |
|
268 | mail_enabled: false | |
179 |
mail_option: |
|
269 | mail_option: true | |
180 | sort: 1070 |
|
270 | sort: 1070 | |
181 | is_public: false |
|
271 | is_public: false | |
182 | permissions_013: |
|
272 | permissions_013: | |
@@ -197,6 +287,24 permissions_002: | |||||
197 | mail_option: false |
|
287 | mail_option: false | |
198 | sort: 105 |
|
288 | sort: 105 | |
199 | is_public: true |
|
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 | permissions_036: |
|
308 | permissions_036: | |
201 | action: destroy |
|
309 | action: destroy | |
202 | id: 36 |
|
310 | id: 36 | |
@@ -233,13 +341,31 permissions_003: | |||||
233 | mail_option: false |
|
341 | mail_option: false | |
234 | sort: 110 |
|
342 | sort: 110 | |
235 | is_public: true |
|
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 | permissions_037: |
|
362 | permissions_037: | |
237 | action: add_attachment |
|
363 | action: add_attachment | |
238 | id: 37 |
|
364 | id: 37 | |
239 | description: label_attachment_new |
|
365 | description: label_attachment_new | |
240 | controller: documents |
|
366 | controller: documents | |
241 | mail_enabled: false |
|
367 | mail_enabled: false | |
242 |
mail_option: |
|
368 | mail_option: true | |
243 | sort: 1223 |
|
369 | sort: 1223 | |
244 | is_public: false |
|
370 | is_public: false | |
245 | permissions_026: |
|
371 | permissions_026: | |
@@ -269,6 +395,24 permissions_004: | |||||
269 | mail_option: false |
|
395 | mail_option: false | |
270 | sort: 150 |
|
396 | sort: 150 | |
271 | is_public: false |
|
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 | permissions_038: |
|
416 | permissions_038: | |
273 | action: destroy_attachment |
|
417 | action: destroy_attachment | |
274 | id: 38 |
|
418 | id: 38 | |
@@ -305,6 +449,15 permissions_005: | |||||
305 | mail_option: false |
|
449 | mail_option: false | |
306 | sort: 151 |
|
450 | sort: 151 | |
307 | is_public: false |
|
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 | permissions_039: |
|
461 | permissions_039: | |
309 | action: list_files |
|
462 | action: list_files | |
310 | id: 39 |
|
463 | id: 39 | |
@@ -341,6 +494,15 permissions_006: | |||||
341 | mail_option: false |
|
494 | mail_option: false | |
342 | sort: 200 |
|
495 | sort: 200 | |
343 | is_public: true |
|
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 | permissions_040: |
|
506 | permissions_040: | |
345 | action: download |
|
507 | action: download | |
346 | id: 40 |
|
508 | id: 40 |
@@ -111,4 +111,14 class ProjectsControllerTest < Test::Unit::TestCase | |||||
111 | assert_template 'changelog' |
|
111 | assert_template 'changelog' | |
112 | assert_not_nil assigns(:fixed_issues) |
|
112 | assert_not_nil assigns(:fixed_issues) | |
113 | end |
|
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 | end |
|
124 | end |
General Comments 0
You need to be logged in to leave comments.
Login now