Module: SearchHelper
- Defined in:
- app/helpers/search_helper.rb
Instance Method Summary (collapse)
- - (Object) highlighted_content(result)
- - (Object) highlighted_title_link(result, url)
- - (Object) print_category(category)
- - (Object) print_content_type(content_type)
- - (Object) show_search_results_index(prefix = "Results"))
Instance Method Details
- (Object) highlighted_content(result)
11 12 13 14 15 16 17 |
# File 'app/helpers/search_helper.rb', line 11 def highlighted_content(result) if result.highlighted_content.blank? highlight(truncate_html(white_list(result.content), 200), @query.split, '<span class="searchHighlight">\1</span>') else white_list(result.highlighted_content, :tags => ["span"], :attributes => ["class"]) end end |
- (Object) highlighted_title_link(result, url)
3 4 5 6 7 8 9 |
# File 'app/helpers/search_helper.rb', line 3 def highlighted_title_link(result, url) if result.highlighted_title.blank? link_to(highlight(white_list(result.title), @query.split, '<span class="searchHighlight">\1</span>'), url) else link_to(white_list(result.highlighted_title, :tags => ["span"], :attributes => ["class"]), url) end end |
- (Object) print_category(category)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/helpers/search_helper.rb', line 30 def print_category(category) = { :advanced => true, :query => "*", :search_engine => params[:search_engine] } [:programme] = category.parent ? category.parent_id : category.id if category.parent link_to(category.parent.name, search_path()) + " | " + link_to(category.name, search_path({:project => category.id}.merge())) else link_to category.name, search_path() end end |
- (Object) print_content_type(content_type)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/helpers/search_helper.rb', line 46 def print_content_type(content_type) case(content_type) when 'Product' t('search.products') when 'Permit' t('search.permits') when 'NewsItem' t('search.news_items') when 'CalendarItem' t('search.calendar_items') when 'Legislation' t('search.legislations') when 'Attachment' t('search.attachments') else t('search.common_pages') end end |
- (Object) show_search_results_index(prefix = "Results"))
19 20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/search_helper.rb', line 19 def show_search_results_index(prefix = "Results") first_page_record = (@results.page-1)*@results.page_size+1 last_page_record = @results.page*@results.page_size last_page_record = @results.size if @results.size < last_page_record result = "#{prefix} <strong>" result << first_page_record.to_s + " - " result << last_page_record.to_s + "</strong>" result end |