app/views/search/_results.html.haml

Summary

Maintainability
Test Coverage
.clear  
#content-tabs
  %ul.nav-list
    - scope.content_item_types.each do |ci_type|
      - if ci_type == scope.current_content_item_type
        %li.selected
          = scope.link_text_for(ci_type)
      - else
        %li
          = link_to scope.link_text_for(ci_type), scope.link_path_params_for(ci_type)

  %div{:style => "clear:both;"}

#content-wrapper{class: "full-width"}
  = render "basket_navigation_menu" if show_basket_list_naviation_menu?
  #main-content-wrapper
    #main-content-container
      %a{name: "main-content"}
      %h3= scope.title

      .prev-next.before-results
        = will_paginate scope.paginated_results,
                        next_label:     t('slideshows_helper.next'),
                        previous_label: t('slideshows_helper.previous'),
                        params:         scope.pagination_link_params

      - search_source_result = ''
      - if scope.search_sources_amount > 0
        - search_source_result = display_search_sources(scope.search_terms, { :target => [:all, :search], :do_not_cache => true,
          :limit => (scope.number_per_page.to_f / scope.search_sources_amount.to_f).ceil,
          :title => t('search.results.search_source_title') })
        - unless search_source_result.blank?
          #search_page_search_sources
            = search_source_result

      - if scope.results.size > 0
        #result-show
          = scope.search_results_info_and_links
          = render partial: 'search/refine_results', locals: { scope: scope }
        - markers = Array.new
        - scope.results.each_with_index do |result,index|
          - if SystemSetting.enable_maps? && scope.view_as_map?
            - marker_options = { 'title' => result[:title] }
            - summary_for_info_window = result[:short_summary].present? ? result[:short_summary] : String.new
            - marker_options['description'] = link_to(h(result[:title]), result[:url], :tabindex => '1') + '<br />' + summary_for_info_window
            - if result.class == StillImage
              - marker_options['description'] += '<br />' + image_tag(result[:thumbnail][:src], result[:thumbnail])
              - marker_options['picture'] = result[:thumbnail][:src]
              - marker_options['width'] = 50
              - marker_options['height'] = 50

            - related_items = render('related',
                                      :related => result[:related],
                                      :source_url => result[:url],
                                      :locally_hosted => result[:locally_hosted],
                                      :title => result[:title]) if result[:related]

            - result[:associated_locations].each do |location|
              - marker_options['description'] += '<br />'
              - marker_options['description'] += '<br />' + t('search.results.address') + ' ' + location[:address] unless location[:address].blank?
              - marker_options['description'] += '<br />' + t('search.results.coordinates') + ' ' + location[:latlng]
              - marker_options['description'] += '<br /><br />' + related_items if related_items
              - marker_options['lat'] = location[:latitude]
              - marker_options['lng'] = location[:longitude]
              - markers << marker_options
          - else
            - if result.class == StillImage
              = render partial: "image", locals: { result: result, scope: scope }
            - else
              = render partial: "generic", locals: { result: result, scope: scope }
      - else
        #result-show
          - if other_results.size > 0
            = t 'search.results.no_results_of_this_type_found', :zoom_class => zoom_class_humanize(scope.current_content_item_type).downcase
            %ul= other_results.collect { |r| "<li>#{r.downcase}</li>" }.join
          - else
            = t 'search.results.no_results_of_any_type_found'

          #refine_search_dropdown_trigger
            = render partial: 'search/refine_results', locals: {scope: scope}

      - if scope.view_as_map?
        - if markers.present?
          = gmaps("markers" => { 'data' => markers.to_json, 'options' => { 'randomize' => true, 'do_clustering' => true, 'clusterer_maxZoom' => 20 } } )                                                      |
        - else
          = t 'search.results.no_results_of_this_type_found', :zoom_class => zoom_class_humanize(scope.current_content_item_type).downcase

      %div{:style => "clear:both;"}

      .prev-next.after-results
        = will_paginate scope.paginated_results,
                        next_label:     t('slideshows_helper.next'),
                        previous_label: t('slideshows_helper.previous'),
                        params:         scope.pagination_link_params
      #bottomlinks
        #addnew
          - if current_user_can_see_add_links? && scope.current_content_item_type != 'Comment'
            = scope.link_to_add_item(:phrase => t('search.results.add_a_new'), :item_class => scope.current_content_item_type)
        \&nbsp;
      .cleaner &nbsp;