Module: Bigmouth::ApplicationHelper

Included in:
Admin::ApplicationHelper
Defined in:
app/helpers/bigmouth/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#alert_class_for(flash_type) ⇒ Object

Returns Bootstrap friendly type



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

def alert_class_for(flash_type)
  {
    success: 'alert-success',
    error: 'alert-danger',
    danger: 'alert-danger',
    alert: 'alert-warning',
    notice: 'alert-info'
  }[flash_type.to_sym] || flash_type.to_s
end

#author(article) ⇒ Object



14
15
16
17
18
19
20
# File 'app/helpers/bigmouth/application_helper.rb', line 14

def author(article)
  if article.user.present?
    article.user[Bigmouth.config.username_key.to_sym] || "Guest"
  else
    "Guest"
  end
end

#summary(article) ⇒ Object



22
23
24
25
26
# File 'app/helpers/bigmouth/application_helper.rb', line 22

def summary(article)
  truncate_html sanitize(article.text),
                length: Bigmouth.config.summary_length,
                omission: "..."
end