Sha256: 6bcfe8e1098b7cbb29f5e7c0893093e6ee6e29be7df75cb37dc819a423b4e411

Contents?: true

Size: 1.09 KB

Versions: 103

Compression:

Stored size: 1.09 KB

Contents

module NotificationsHelper

  # An activity object title
  def title_of(act_obj)
    if act_obj.is_a? Comment
      'Re: ' + title_of(act_obj.parent_post)
    elsif act_obj.respond_to? :title and (not act_obj.title.nil?)
      act_obj.title.truncate(30, :separator => ' ')
    elsif act_obj.respond_to? :url and (not act_obj.url.nil?)
      act_obj.url.truncate(30, :separator => ' ')
    else I18n.t('notification.default')
    end
  end

  # An activity object description
  def description_of(act_obj)
    if act_obj.respond_to? :description and (not act_obj.description.nil?)
      sanitize(act_obj.description)
    else
      I18n.t('notification.watch_it')
    end
  end

  # Set locale as per subject preference
  def locale_as(subject)
    if subject.respond_to? :language
      I18n.locale = subject.language || I18n.default_locale
    end
  end

  # Add notification_id param to URL in order to mark notification read
  def notification_url_of(target, notification)
    return polymorphic_url(target, :notification_id => notification.id) unless notification.nil?
    polymorphic_url(target)
  end

end

Version data entries

103 entries across 103 versions & 2 rubygems

Version Path
social_stream-2.2.2 base/app/helpers/notifications_helper.rb
social_stream-base-2.2.2 app/helpers/notifications_helper.rb
social_stream-2.2.1 base/app/helpers/notifications_helper.rb
social_stream-base-2.2.1 app/helpers/notifications_helper.rb
social_stream-2.2.0 base/app/helpers/notifications_helper.rb
social_stream-base-2.2.0 app/helpers/notifications_helper.rb
social_stream-2.1.1 base/app/helpers/notifications_helper.rb
social_stream-1.1.12 base/app/helpers/notifications_helper.rb
social_stream-base-1.1.11 app/helpers/notifications_helper.rb
social_stream-2.1.0 base/app/helpers/notifications_helper.rb
social_stream-base-2.1.0 app/helpers/notifications_helper.rb
social_stream-2.0.4 base/app/helpers/notifications_helper.rb
social_stream-base-2.0.4 app/helpers/notifications_helper.rb
social_stream-2.0.3 base/app/helpers/notifications_helper.rb
social_stream-base-2.0.3 app/helpers/notifications_helper.rb
social_stream-1.1.11 base/app/helpers/notifications_helper.rb
social_stream-base-1.1.10 app/helpers/notifications_helper.rb
social_stream-1.1.10 base/app/helpers/notifications_helper.rb
social_stream-base-1.1.9 app/helpers/notifications_helper.rb
social_stream-1.1.9 base/app/helpers/notifications_helper.rb