Module: Sunrise::ActivitiesHelper

Defined in:
app/helpers/sunrise/activities_helper.rb

Instance Method Summary collapse

Instance Method Details

#activity_icon_tag(key, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/sunrise/activities_helper.rb', line 11

def activity_icon_tag(key, options = {})
  icon = key.split('.').last
  image = image_path("sunrise/icons/#{icon}.svg")

  options = {
    class: 'mega-icon',
    style: "background-image: url(#{image});"
  }.merge(options)

  (:div, nil, options)
end

Check if object still exists in the database and display a link to it, otherwise display a proper message about it. This is used in activities that can refer to objects which no longer exist, like removed posts.



27
28
29
30
31
32
33
34
35
# File 'app/helpers/sunrise/activities_helper.rb', line 27

def link_to_trackable(object, object_type)
  model_name = object_type.downcase

  if object
    link_to(model_name, edit_path(model_name: model_name.pluralize, id: object.id))
  else
    "a #{model_name} which does not exist anymore"
  end
end

#timeago_tag(time, options = {}) ⇒ Object

For generating time tags calculated using jquery.timeago



6
7
8
9
# File 'app/helpers/sunrise/activities_helper.rb', line 6

def timeago_tag(time, options = {})
  options[:class] ||= 'timeago'
  (:abbr, time.to_s, options.merge(title: time.getutc.iso8601)) if time
end