Module: MuckActivityHelper
- Included in:
- Muck::ActivitiesController
- Defined in:
- app/helpers/muck_activity_helper.rb
Instance Method Summary collapse
- #activity_comment_link(activity, comment = nil) ⇒ Object
- #activity_comments(activity) ⇒ Object
-
#activity_feed_for(activities_object, limited = false) ⇒ Object
Renders a full activity feed for activities_object activities_object: object to get activities for limited: a value passed to each activity template which can result in a smaller amount of data being rendered.
-
#activity_filter(activities_object, *dont_include) ⇒ Object
Renders an activity feed filter.
-
#activity_for(activity, options = {}, &block) ⇒ Object
Render an activity using a block and the given activity.
- #activity_scripts ⇒ Object
- #all_activities_url ⇒ Object
-
#cached_activities(activities, limited = false) ⇒ Object
Renders an activity feed using the cache where possible activities: the activities for the feed limited: a value passed to each activity template which can result in a smaller amount of data being rendered.
-
#contribute(activities_object) ⇒ Object
Renders a status update form for activities_object that has photo and file upload as well as video sharing.
-
#current_status(activities_object) ⇒ Object
Renders the last status update made by activities_object.
-
#delete_activity(activity, button_type = :button, button_text = t("muck.activities.clear")) ⇒ Object
Renders a delete button for an activity.
-
#delete_activity_comment(comment, button_type = :button, button_text = t("muck.activities.delete")) ⇒ Object
Renders a delete button for a comment inside an activity feed.
- #get_activities(activities_object) ⇒ Object
- #get_profile_activities(activities_object) ⇒ Object
- #has_comments_css(activity) ⇒ Object
- #is_current_filter?(template) ⇒ Boolean
-
#limited_activity_feed_for(activities_object, limited = false) ⇒ Object
Renders an activity with only activities created by activities_object activities_object: object to get activities for limited: a value passed to each activity template which can result in a smaller amount of data being rendered.
- #no_filter? ⇒ Boolean
-
#status_update(activities_object) ⇒ Object
Renders a status update form for activities_object.
Instance Method Details
#activity_comment_link(activity, comment = nil) ⇒ Object
7 8 9 10 11 |
# File 'app/helpers/muck_activity_helper.rb', line 7 def activity_comment_link(activity, comment = nil) if MuckActivities.configuration.enable_activity_comments comment_form(activity, comment) end end |
#activity_comments(activity) ⇒ Object
3 4 5 |
# File 'app/helpers/muck_activity_helper.rb', line 3 def activity_comments(activity) render :partial => 'activities/comments', :locals => { :activity => activity } end |
#activity_feed_for(activities_object, limited = false) ⇒ Object
Renders a full activity feed for activities_object activities_object: object to get activities for limited: a value passed to each activity template which can result in a smaller amount of data
being rendered
48 49 50 51 |
# File 'app/helpers/muck_activity_helper.rb', line 48 def activity_feed_for(activities_object, limited = false) activities = get_activities(activities_object) render :partial => 'activities/activity_feed', :locals => { :activities_object => activities_object, :activities => activities, :limited => limited } end |
#activity_filter(activities_object, *dont_include) ⇒ Object
Renders an activity feed filter. Filter items come from the name of the templates used to render the activities. Pass in an array of templates to leave out as the second parameter
88 89 90 91 92 93 94 |
# File 'app/helpers/muck_activity_helper.rb', line 88 def activity_filter(activities_object, *dont_include) dont_include = [dont_include] unless dont_include.is_a?(Array) activity_types = Activity.where(:id => activities_object.id).select("DISTINCT(template)") #activity_types = activities_object.activities.select("DISTINCT(activities.template)") filter_types = activity_types.find_all {|activity| !dont_include.include?(activity.template)} render :partial => 'activities/template_filter', :locals => { :activity_types => filter_types, :dont_include => dont_include } end |
#activity_for(activity, options = {}, &block) ⇒ Object
Render an activity using a block and the given activity. options: activity_css_class - css class to attach to the given activity
131 132 133 |
# File 'app/helpers/muck_activity_helper.rb', line 131 def activity_for(activity, = {}, &block) block_to_partial('activity_templates/generic', .merge(:activity => activity), &block) end |
#activity_scripts ⇒ Object
13 14 15 16 |
# File 'app/helpers/muck_activity_helper.rb', line 13 def activity_scripts render( :partial => "activities/activity_scripts") time_scripts(I18n.locale) end |
#all_activities_url ⇒ Object
108 109 110 |
# File 'app/helpers/muck_activity_helper.rb', line 108 def all_activities_url request.url.gsub(request.query_string, '') end |
#cached_activities(activities, limited = false) ⇒ Object
Renders an activity feed using the cache where possible activities: the activities for the feed limited: a value passed to each activity template which can result in a smaller amount of data
being rendered
22 23 24 25 |
# File 'app/helpers/muck_activity_helper.rb', line 22 def cached_activities(activities, limited = false) return '' if activities.blank? render( :partial => "activities/cached_activities", :locals => {:activities => activities, :limited => limited}) end |
#contribute(activities_object) ⇒ Object
Renders a status update form for activities_object that has photo and file upload as well as video sharing.
59 60 61 |
# File 'app/helpers/muck_activity_helper.rb', line 59 def contribute(activities_object) render :partial => 'activities/contribute', :locals => { :activities_object => activities_object } end |
#current_status(activities_object) ⇒ Object
Renders the last status update made by activities_object
64 65 66 |
# File 'app/helpers/muck_activity_helper.rb', line 64 def current_status(activities_object) render :partial => 'activities/current_status_wrapper', :locals => { :activities_object => activities_object } end |
#delete_activity(activity, button_type = :button, button_text = t("muck.activities.clear")) ⇒ Object
Renders a delete button for an activity
69 70 71 72 73 74 75 |
# File 'app/helpers/muck_activity_helper.rb', line 69 def delete_activity(activity, = :button, = t("muck.activities.clear")) render :partial => 'shared/delete', :locals => { :delete_object => activity, :button_type => , :button_text => , :form_class => 'activity-delete', :delete_path => activity_path(activity, :format => 'js') } end |
#delete_activity_comment(comment, button_type = :button, button_text = t("muck.activities.delete")) ⇒ Object
Renders a delete button for a comment inside an activity feed
78 79 80 81 82 83 84 |
# File 'app/helpers/muck_activity_helper.rb', line 78 def delete_activity_comment(comment, = :button, = t("muck.activities.delete")) render :partial => 'shared/delete', :locals => { :delete_object => comment, :button_type => , :button_text => , :form_class => 'comment-delete', :delete_path => comment_path(comment, :format => 'js') } end |
#get_activities(activities_object) ⇒ Object
120 121 122 123 124 125 126 |
# File 'app/helpers/muck_activity_helper.rb', line 120 def get_activities(activities_object) if !params[:latest_activity_id].blank? activities_object.activities.by_latest.filter_by_template(params[:activity_filter]).after(params[:latest_activity_id]).includes(:comments).paginate(:page => @page, :per_page => @per_page) else activities_object.activities.by_latest.filter_by_template(params[:activity_filter]).includes(:comments).paginate(:page => @page, :per_page => @per_page) end end |
#get_profile_activities(activities_object) ⇒ Object
112 113 114 115 116 117 118 |
# File 'app/helpers/muck_activity_helper.rb', line 112 def get_profile_activities(activities_object) if !params[:latest_activity_id].blank? activities_object.activities.by_latest.filter_by_template(params[:activity_filter]).after(params[:latest_activity_id]).is_public.created_by(activities_object).includes(:comments).paginate(:page => @page, :per_page => @per_page) else activities_object.activities.by_latest.filter_by_template(params[:activity_filter]).is_public.created_by(activities_object).includes(:comments).paginate(:page => @page, :per_page => @per_page) end end |
#has_comments_css(activity) ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/helpers/muck_activity_helper.rb', line 27 def has_comments_css(activity) if activity.has_comments? 'activity-has-comments' else 'activity-no-comments' end end |
#is_current_filter?(template) ⇒ Boolean
96 97 98 99 100 |
# File 'app/helpers/muck_activity_helper.rb', line 96 def is_current_filter?(template) if params[:activity_filter] == template 'current' end end |
#limited_activity_feed_for(activities_object, limited = false) ⇒ Object
Renders an activity with only activities created by activities_object activities_object: object to get activities for limited: a value passed to each activity template which can result in a smaller amount of data
being rendered
39 40 41 42 |
# File 'app/helpers/muck_activity_helper.rb', line 39 def limited_activity_feed_for(activities_object, limited = false) activities = activities_object.activities.by_latest.created_by(activities_object).is_public.includes(:comments).paginate(:page => @page, :per_page => @per_page) render :partial => 'activities/activity_feed', :locals => { :activities_object => activities_object, :activities => activities, :limited => limited } end |
#no_filter? ⇒ Boolean
102 103 104 105 106 |
# File 'app/helpers/muck_activity_helper.rb', line 102 def no_filter? if params[:activity_filter].blank? 'current' end end |
#status_update(activities_object) ⇒ Object
Renders a status update form for activities_object
54 55 56 |
# File 'app/helpers/muck_activity_helper.rb', line 54 def status_update(activities_object) render :partial => 'activities/status_update', :locals => { :activities_object => activities_object } end |