Module: ActivitiesHelper
- Defined in:
- app/helpers/activities_helper.rb
Instance Method Summary collapse
- #like_sentence(activity, options = {}) ⇒ Object
-
#link_like(object) ⇒ String
Link to ‘like’ or ‘unlike’ depending on the like status of the activity to current_subject.
- #link_like_params(object) ⇒ Object
-
#new_post(receiver) ⇒ Object
Build a new post based on the current_subject.
Instance Method Details
#like_sentence(activity, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/helpers/activities_helper.rb', line 38 def like_sentence(activity, = {}) [:likers_shown] ||= 2 # TODO: select likers from current_subject's contacts likers = activity.likes.first([:likers_shown]). map{ |a| a.sender_subject }. map{ |l| link_to l.name, l } likers_count = activity.likes.count likers_other = likers_count - [:likers_shown] if likers_other > 0 likers.push t("activity_action.sentence.more", :count => likers_other) end t("activity.like_sentence", :likers => likers.to_sentence, :count => likers_count).html_safe end |
#link_like(object) ⇒ String
Link to ‘like’ or ‘unlike’ depending on the like status of the activity to current_subject
6 7 8 9 |
# File 'app/helpers/activities_helper.rb', line 6 def link_like(object) params = link_like_params(object) link_to params[0],params[1],params[2] end |
#link_like_params(object) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/activities_helper.rb', line 11 def link_like_params(object) params = Array.new if !user_signed_in? params << image_tag("btn/nolike.png", :class => "menu_icon")+t('activity.like') params << new_user_session_path params << {:class => "verb_like",:id => "like_" + dom_id(object)} else if (object.liked_by?(current_subject)) params << image_tag("btn/like.png", :class => "menu_icon")+t('activity.unlike') params << [object, :like] params << {:class => "verb_like",:id => "like_" + dom_id(object),:method => :delete, :remote => true} else params << image_tag("btn/nolike.png", :class => "menu_icon")+t('activity.like') params << [object, :like] params << {:class => "verb_like",:id => "like_" + dom_id(object),:method => :post, :remote => true} end end end |
#new_post(receiver) ⇒ Object
Build a new post based on the current_subject. Useful for authorization queries
31 32 33 34 35 36 |
# File 'app/helpers/activities_helper.rb', line 31 def new_post(receiver) return Post.new unless user_signed_in? Post.new :author_id => Actor.normalize_id(current_subject), :owner_id => Actor.normalize_id(receiver) end |