Module: QuickSearch::ApplicationHelper

Includes:
EncodeUtf8
Defined in:
app/helpers/quick_search/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#application_nameObject



4
5
6
7
8
9
10
# File 'app/helpers/quick_search/application_helper.rb', line 4

def application_name
  if action_name == "website"
    I18n.t "website_search.title_name"
  else
    I18n.t "defaults_search.title_name"
  end
end

#body_classObject



64
65
66
# File 'app/helpers/quick_search/application_helper.rb', line 64

def body_class
  [controller_name, action_name].join('-')
end

#display_queryObject



20
21
22
# File 'app/helpers/quick_search/application_helper.rb', line 20

def display_query
  params_q_scrubbed.nil? || params_q_scrubbed == "" ? "" : truncate(params_q_scrubbed, length: 40, separator: ' ')
end

#get_best_bets_data(best_bets_searcher) ⇒ Object



53
54
55
56
57
58
59
60
61
62
# File 'app/helpers/quick_search/application_helper.rb', line 53

def get_best_bets_data(best_bets_searcher)
  best_bets = {}
  best_bets[:id] = best_bets_searcher.results.first.id
  best_bets[:title] = best_bets_searcher.results.first.title
  best_bets[:link] = best_bets_searcher.results.first.link
  best_bets[:description] = best_bets_searcher.results.first.description
  best_bets[:best_bets_type] = best_bets_searcher.results.first.best_bets_type

  best_bets
end

#log_queryObject



24
25
26
# File 'app/helpers/quick_search/application_helper.rb', line 24

def log_query
  params_q_scrubbed.nil? || params_q_scrubbed == "" ? "" : truncate(sanitize(params_q_scrubbed), length: 100, separator: ' ')
end

#organization_nameObject



12
13
14
# File 'app/helpers/quick_search/application_helper.rb', line 12

def organization_name
  I18n.t 'organization_name'
end

#pages(page) ⇒ Object

FIXME this should use en definitions



39
40
41
42
43
44
45
46
47
# File 'app/helpers/quick_search/application_helper.rb', line 39

def pages(page)
  format_pages ||= ''
  if page.count('-') > 0
    format_pages << "pp.&nbsp;"
  else
    format_pages << "p.&nbsp;"
  end
  format_pages << page
end

#render_module(searcher, service_name, partial_name = '/quick_search/search/module', per_page = 3) ⇒ Object



49
50
51
# File 'app/helpers/quick_search/application_helper.rb', line 49

def render_module(searcher, service_name, partial_name = '/quick_search/search/module', per_page = 3)
  render partial: partial_name , locals: { module_display_name: t("#{service_name}_search.display_name"), searcher: searcher, search: '', service_name: service_name, per_page: per_page }
end

#sanitized_queryObject



16
17
18
# File 'app/helpers/quick_search/application_helper.rb', line 16

def sanitized_query
  params_q_scrubbed.nil? || params_q_scrubbed == "" ? "" : sanitize(params_q_scrubbed)
end

#title(page_title = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'app/helpers/quick_search/application_helper.rb', line 28

def title(page_title = nil)
  query = params_q_scrubbed.nil? || params_q_scrubbed == "" ? "" : truncate(params_q_scrubbed, length: 40, separator: ' ', escape: false)
  page_title ||= ''
  page_title << "#{query} |" unless query.blank?
  page_title << " #{application_name} |" unless application_name.blank?
  page_title << " #{organization_name}" unless organization_name.blank?

  content_for :title, page_title
end