Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details



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

def custom_link_unless_current(link_text, url)
  "<li>#{link_to(link_text, url)}</li>".html_safe unless current_page?(url)
end

#follows?(project) ⇒ Boolean

Returns:

  • (Boolean)


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

def follows?(project)
  followed_projects.member?(project)
end

#format_date_with_year(date) ⇒ Object



65
66
67
68
# File 'app/helpers/application_helper.rb', line 65

def format_date_with_year(date)
  return "" if date.nil?
  "#{date.strftime("%b %d")}<span class=\"year\">#{date.strftime("%Y")}</span>".html_safe
end

#format_time(time) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/helpers/application_helper.rb', line 48

def format_time(time)
  if time.nil?
    date, time = ["", "Never"]
  elsif time.to_date == Date.today
    date, time = ["Today", time.strftime("%l:%M %p")]
  elsif time.to_date == Date.today - 1
    date, time = ["Yesterday", time.strftime("%l:%M %p")]
  else
    date, time = [time.strftime("%b %e"), time.strftime("%l:%M %p")]
  end

  "  <span class=\"time-date\">\#{date}</span>\n  <span class=\"time-time\">\#{time.gsub(\" AM\", \"a\").gsub(\" PM\", \"p\")}</span>\n  HTML\nend\n".html_safe

#header {|PageHeaderBuilder.new(self)| ... } ⇒ Object

Yields:



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

def header
  yield PageHeaderBuilder.new(self)
  "<hr class=\"clear\" />".html_safe
end

#html_safe(html) ⇒ Object



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

def html_safe(html)
  html.html_safe
end

#in_columns(collection, options = {}, &block) ⇒ Object



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

def in_columns(collection, options={}, &block)
  max_size = options.fetch(:max_size, 10)
  column_count = (collection.length.to_f / max_size).ceil
  column_count = 1 if column_count < 1
  in_columns_of(collection, column_count, &block)
end

#in_groups_of(collection, column_count, css_class = "column") ⇒ Object Also known as: in_columns_of



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

def in_groups_of(collection, column_count, css_class="column")
  html = collection.in_groups_of(column_count).each_with_object("") do |items_in_column, html|
    html << "<div class=\"#{css_class}\">"
    items_in_column.compact.each do |item|
      html << capture { yield (item) }
    end
    html << "</div>"
  end
  html.html_safe
end

#revisionObject



7
8
9
# File 'app/helpers/application_helper.rb', line 7

def revision
  controller.revision
end

#titleObject



3
4
5
# File 'app/helpers/application_helper.rb', line 3

def title
  @title || Houston.config.title
end