Patch #6277 » search_rest_api.patch
| controllers/search_controller.rb (??ƃR?s?[) | ||
|---|---|---|
| 20 | 20 | |
| 21 | 21 |
helper :messages |
| 22 | 22 |
include MessagesHelper |
| 23 |
accept_key_auth :index |
|
| 23 | 24 | |
| 24 | 25 |
def index |
| 25 | 26 |
@question = params[:q] || "" |
| ... | ... | |
| 100 | 101 |
else |
| 101 | 102 |
@question = "" |
| 102 | 103 |
end |
| 103 |
render :layout => false if request.xhr? |
|
| 104 |
respond_to do |format| |
|
| 105 |
format.html { render :template => 'search/index.rhtml', :layout => !request.xhr? }
|
|
| 106 |
format.xml { render :layout => false }
|
|
| 107 |
end |
|
| 104 | 108 |
end |
| 105 | 109 | |
| 106 | 110 |
private |
| views/search/index.xml.builder (???r?W???? 0) | ||
|---|---|---|
| 1 |
xml.instruct! |
|
| 2 |
xml.search_results :type => 'array' do |
|
| 3 |
@results.each do |result| |
|
| 4 |
xml.result do |
|
| 5 |
xml.title result.event_title |
|
| 6 |
xml.type result.event_type |
|
| 7 |
xml.url url_for(result.event_url(:only_path => false)) |
|
| 8 |
xml.description result.event_description |
|
| 9 |
xml.datetime result.event_datetime |
|
| 10 |
end |
|
| 11 |
end |
|
| 12 |
end |
|