Module: SocketsHelper
- Includes:
- ApplicationHelper, NotificationsHelper
- Included in:
- SocketsController
- Defined in:
- app/helpers/sockets_helper.rb
Overview
Copyright © 2010, Diaspora Inc. This file is
licensed under the Affero General Public License version 3 or later. See the COPYRIGHT file.
Instance Method Summary (collapse)
Methods included from NotificationsHelper
#new_notification_link, #notification_message_for, #notification_people_link, #object_link, #peoples_names, #the_day, #the_month, #translation
Methods included from ApplicationHelper
#bookmarklet, #direction_for, #get_javascript_strings_for, #hard_link, #how_long_ago, #info_text, #mine?, #object_fields, #object_path, #owner_image_link, #owner_image_tag, #person_image_link, #person_image_tag, #person_link, #post_yield_tag, #profile_photo, #rtl?, #timeago, #type_partial
Instance Method Details
- (Object) action_hash(user, object, opts = {})
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/helpers/sockets_helper.rb', line 19 def action_hash(user, object, opts={}) uid = user.id begin unless user.nil? old_locale = I18n.locale I18n.locale = user.language.to_s end if object.is_a? StatusMessage post_hash = {:post => object, :author => object., :photos => object.photos, :comments => object.comments.map{|c| {:comment => c, :author => c. } }, :current_user => user, :all_aspects => user.aspects, } v = render_to_string(:partial => 'shared/stream_element', :locals => post_hash) elsif object.is_a? Person person_hash = { :single_aspect_form => opts["single_aspect_form"], :person => object, :all_aspects => user.aspects, :contact => user.contact_for(object), :current_user => user} @all_aspects = user.aspects v = render_to_string(:partial => 'people/person', :locals => person_hash) elsif object.is_a? Comment v = render_to_string(:partial => 'comments/comment', :locals => {:post => object.post, :comment => object, :person => object., :current_user => user}) elsif object.is_a? Like v = render_to_string(:partial => 'likes/likes', :locals => {:likes => object.post.likes, :dislikes => object.post.dislikes}) elsif object.is_a? Notification v = render_to_string(:partial => 'notifications/popup', :locals => {:note => object, :person => opts[:actor]}) else raise "#{object.inspect} with class #{object.class} is not actionhashable." unless object.is_a? Retraction end rescue Exception => e Rails.logger.error("event=socket_render status=fail user=#{user.diaspora_handle} object=#{object.id.to_s}") raise e end action_hash = {:class =>object.class.to_s.underscore.pluralize, :html => v, :post_id => obj_id(object)} action_hash.merge! opts if object.is_a? Photo action_hash[:photo_hash] = object.thumb_hash end if object.is_a? Comment post = object.post action_hash[:comment_id] = object.id action_hash[:my_post?] = (post..owner_id == uid) action_hash[:post_guid] = post.guid end if object.is_a? Like action_hash[:post_guid] = object.post.guid end action_hash[:mine?] = object. && (object..owner_id == uid) if object.respond_to?(:author) I18n.locale = old_locale unless user.nil? action_hash.to_json end |
- (Object) obj_id(object)
9 10 11 12 13 14 15 16 17 |
# File 'app/helpers/sockets_helper.rb', line 9 def obj_id(object) if object.respond_to?(:post_id) object.post_id elsif object.respond_to?(:post_guid) object.post_guid else object.id end end |