Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#archived_button_text(params) ⇒ Object


56
57
58
# File 'app/helpers/application_helper.rb', line 56

def archived_button_text(params)
  params[:archived_view] ? '<i class="fa fa-archive tipster" title="Hide Archived"></i> <span class="hidden-xs hidden-sm">Hide Archived</span>' : '<i class="fa fa-archive tipster" title="View Archived"></i> <span class="hidden-xs hidden-sm">View Archived</span>'
end

#archived_view_button(params) ⇒ Object


52
53
54
# File 'app/helpers/application_helper.rb', line 52

def archived_view_button(params)
  params[:archived_view] ? params.merge(:archived_view => nil) : params.merge(:archived_view => "true")
end

#calculate_animal_age(birthday) ⇒ Object


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

def calculate_animal_age(birthday)
  age = (Time.now.year - birthday.year).to_s + " years"
  if age == "0 years"
    age = (Time.now.month - birthday.month).to_s + " months"
    if age == "0 months"
      age = (Time.now.day - birthday.day).to_s + " days"
    end
  end
  return age
end

14
15
16
# File 'app/helpers/application_helper.rb', line 14

def canonical_link_tag
  tag(:link, :rel => :canonical, :href => "https://hospitium.co#{@canonical_url}") if @canonical_url
end

#current_class?(con, act) ⇒ Boolean

Returns:

  • (Boolean)

18
19
20
21
22
23
24
# File 'app/helpers/application_helper.rb', line 18

def current_class?(con, act)
  if current_page?(:controller => con, :action => act)
    return 'active' 
  else
   return ''
  end
end

#indefinite_articlerize(params_word) ⇒ Object


71
72
73
# File 'app/helpers/application_helper.rb', line 71

def indefinite_articlerize(params_word)
    %w(a e i o u).include?(params_word[0].downcase) ? "an #{params_word}" : "a #{params_word}"
end

#is_table_view(params) ⇒ Object


40
41
42
# File 'app/helpers/application_helper.rb', line 40

def is_table_view(params)
  params.merge({:table_view => 'true'}) if params[:table_view]
end

#markdown(text) ⇒ Object


26
27
28
29
30
31
# File 'app/helpers/application_helper.rb', line 26

def markdown(text)
  markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(
      :hard_wrap => true, :filter_html => true),
      :no_intraemphasis => true, :autolink => true)
  return markdown.render(sanitize(text)).html_safe
end

#past_tense_actions(action) ⇒ Object


60
61
62
63
64
65
66
67
68
69
# File 'app/helpers/application_helper.rb', line 60

def past_tense_actions(action)
  case action
  when 'create'
    'created'
  when 'update'
    'updated'
  when 'destroy'
    'destroyed'
  end
end

#public_activity_icon(action) ⇒ Object


75
76
77
78
79
80
81
82
83
84
# File 'app/helpers/application_helper.rb', line 75

def public_activity_icon(action)
  case action
  when 'create'
    'fa fa-plus green'
  when 'update'
    'fa fa-pencil green'
  when 'destroy'
    'fa fa-trash red'
  end      
end

#table_button_text(params) ⇒ Object


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

def table_button_text(params)
  params[:table_view] ? '<i class="fa fa-th-large tipster" title="Card View"></i><span class="hidden-xs hidden-sm"> Card View</span>' : '<i class="fa fa-table tipster" title="Table View"></i><span class="hidden-xs hidden-sm"> Table View</span>'
end

#table_view_button(params) ⇒ Object


44
45
46
# File 'app/helpers/application_helper.rb', line 44

def table_view_button(params)
  params[:table_view] ? params.merge(:table_view => nil) : params.merge(:table_view => "true")
end

#unsafe_markdown(text) ⇒ Object


33
34
35
36
37
38
# File 'app/helpers/application_helper.rb', line 33

def unsafe_markdown(text)
  markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(
      :hard_wrap => true),
      :no_intraemphasis => true, :autolink => true)
  return markdown.render(sanitize(text)).html_safe
end