bborn/communityengine

View on GitHub
app/views/activities/_activity.html.haml

Summary

Maintainability
Test Coverage
%tr{:id => 'activity-' + activity.id.to_s }
  %td
    =time_ago_in_words(activity.created_at)
  %td 
    =link_to activity.user.login.capitalize, user_path(activity.user.friendly_id)  
    - if activity.item
      - case activity.item_type
        - when 'Post'
          =:wrote_a_post.l
          = link_to activity.item.title, user_post_path(activity.item.user, activity.item)
        - when 'Photo'
          =:uploaded_a_photo.l
          = link_to image_tag(activity.item.photo.url(:thumb), :class => 'thumbnail col-sm-1 pull-right'), user_photo_path(activity.item.user, activity.item)
        - when 'Album'
          =:created_an_album.l
          = link_to activity.item.title, user_album_path(activity.item.user, activity.item)
        - when 'Topic'
          =:started_a_topic.l
          -topic = activity.item
          = link_to truncate_words(topic.title), forum_topic_path(topic.forum, topic)
        - when 'SbPost'
          =:added_to_a_forum_topic.l
          - topic = activity.item.topic
          = link_to truncate_words(activity.item.body), forum_topic_path(topic.forum, topic)
        - when 'Comment'
          =:left_a_comment.l
          = link_to truncate_words(activity.item.comment), commentable_url(activity.item)
        - when 'Favorite'
          =:favorited.l
          = link_to " a #{activity.item.favoritable.class.to_s.humanize.downcase}", user_favorite_path(activity.item.user, activity.item)
        - when 'Clipping'
          =:added_a_clipping.l
          = link_to image_tag( activity.item.image_uri(:thumb), :class => 'thumbnail col-sm-1 pull-right'), user_clipping_path(activity.item.user, activity.item)
        - when 'Invitation'
          =:invited_friends.l
        - when 'Event'
          =:posted_an_event.l
          = link_to activity.item.name, event_path(activity.item)
        - when 'Rsvp'
          =:rsvped_for_an_event.l
          = link_to activity.item.event.name, event_path(activity.item.event)
        -else
          =render :partial => 'activities/unhandled_item', :locals => {:activity => activity}
    - else
      - case activity.action
        - when 'updated_profile'
          =:updated_their_profile.l
        - when 'logged_in'
          =:logged_into_the_site.l
        - when 'joined_the_site'
          =:joined_the_site.l(:site => configatron.community_name)
        - else
          = " #{activity.action.humanize.downcase }"
  %td
    -if activity.can_be_deleted_by?(current_user)
      =link_to fa_icon("times"), activity, :remote => true, :method => 'delete', 'data-manual-confirm' => :are_you_sure.l, :class => 'clear-right pull-right btn btn-danger btn-xs delete-via-ajax'