Sha256: f6f1b58150a170a577481366573c95f361545f291d6489cb5094ee89b113cb1b

Contents?: true

Size: 1.06 KB

Versions: 89

Compression:

Stored size: 1.06 KB

Contents

module ActivityActionsHelper
  def toggle_follow_action(activity_object)
    action = activity_object.action_from(current_subject)
    action ||= activity_object.received_actions.build :actor_id => current_subject.actor_id

    action.follow ^= true

    action
  end

  # Show the {SocialStream::Models::Subject Subjects} that follow
  # the {ActivityObject object}
  #
  # TODO: DRY with ActivitiesHelper#like_sentence
  def followers_sentence(object, options = {})
    options[:followers_shown] ||= 2

    followers_count = object.follower_count

    return "" unless followers_count > 0

    followers =
      object.followers.
      map{ |a| a.subject }.
      map{ |l| link_to l.name, l }

    followers_other = followers_count - options[:followers_shown]

    if followers_other > 0
      followers.push t("activity_action.sentence.more", :count => followers_other)
    end

    t("#{ object.object_type.underscore }.activity_action.sentence.follow", :followers => followers.to_sentence, :count => followers_count, :default => :"activity_action.sentence.follow").html_safe
  end
end

Version data entries

89 entries across 89 versions & 2 rubygems

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