Skip to content
Browse files

Merge branch 'LoD' into develop

  • Loading branch information...
2 parents f0619db + e70e48d commit 06d9ff221d8c17bbed59348b52ef60f879eea8ac @jhass jhass committed
Showing with 150 additions and 115 deletions.
  1. +1 −1 app/controllers/application_controller.rb
  2. +5 −5 app/controllers/conversations_controller.rb
  3. +1 −1 app/controllers/messages_controller.rb
  4. +1 −1 app/controllers/photos_controller.rb
  5. +1 −1 app/controllers/profiles_controller.rb
  6. +1 −1 app/controllers/reshares_controller.rb
  7. +4 −4 app/controllers/services_controller.rb
  8. +2 −2 app/controllers/users_controller.rb
  9. +3 −3 app/helpers/contacts_helper.rb
  10. +1 −1 app/helpers/invitation_codes_helper.rb
  11. +3 −3 app/helpers/mobile_helper.rb
  12. +1 −1 app/helpers/notifications_helper.rb
  13. +3 −3 app/helpers/posts_helper.rb
  14. +3 −2 app/mailers/notification_mailers/also_commented.rb
  15. +4 −0 app/mailers/notification_mailers/base.rb
  16. +2 −2 app/mailers/notification_mailers/comment_on_post.rb
  17. +1 −1 app/mailers/notification_mailers/confirm_email.rb
  18. +2 −1 app/mailers/notification_mailers/liked.rb
  19. +2 −1 app/mailers/notification_mailers/mentioned.rb
  20. +1 −1 app/mailers/notification_mailers/private_message.rb
  21. +3 −1 app/mailers/notification_mailers/reshared.rb
  22. +1 −1 app/mailers/notifier.rb
  23. +3 −1 app/models/block.rb
  24. +4 −0 app/models/comment.rb
  25. +4 −1 app/models/contact.rb
  26. +2 −0 app/models/invitation_code.rb
  27. +2 −0 app/models/message.rb
  28. +3 −1 app/models/person.rb
  29. +1 −0 app/models/photo.rb
  30. +2 −1 app/models/reshare.rb
  31. +4 −0 app/models/status_message.rb
  32. +5 −2 app/models/user.rb
  33. +3 −3 app/presenters/o_embed_presenter.rb
  34. +4 −4 app/presenters/person_presenter.rb
  35. +1 −1 app/presenters/post_presenter.rb
  36. +1 −1 app/views/community_spotlight/_user.html.haml
  37. +2 −2 app/views/contacts/index.html.haml
  38. +2 −2 app/views/contacts/sharing.haml
  39. +1 −1 app/views/notifications/_notify_popup_item.haml
  40. +2 −2 app/views/notifier/also_commented.markerb
  41. +1 −1 app/views/notifier/comment_on_post.markerb
  42. +3 −3 app/views/notifier/confirm_email.markerb
  43. +3 −3 app/views/notifier/liked.markerb
  44. +1 −1 app/views/notifier/mentioned.markerb
  45. +2 −2 app/views/notifier/reshared.markerb
  46. +2 −2 app/views/notifier/started_sharing.markerb
  47. +8 −8 app/views/people/_profile_sidebar.html.haml
  48. +1 −1 app/views/people/_sub_header.html.haml
  49. +1 −1 app/views/photos/_photo.haml
  50. +1 −1 app/views/posts/_photo.html.haml
  51. +5 −5 app/views/publics/hcard.haml
  52. +1 −1 app/views/shared/_photo_area.mobile.haml
  53. +1 −1 app/views/status_messages/_status_message.mobile.haml
  54. +1 −1 app/views/users/getting_started.haml
  55. +1 −1 app/views/users/privacy_settings.html.haml
  56. +5 −5 app/views/users/public.atom.builder
  57. +1 −1 lib/collect_user_photos.rb
  58. +2 −2 lib/diaspora/exporter.rb
  59. +3 −2 lib/diaspora/relayable.rb
  60. +2 −1 lib/diaspora/shareable.rb
  61. +1 −1 lib/email_inviter.rb
  62. +3 −3 lib/postzord/dispatcher.rb
  63. +2 −2 lib/postzord/receiver/local_batch.rb
  64. +1 −1 lib/postzord/receiver/private.rb
  65. +3 −3 lib/postzord/receiver/public.rb
  66. +2 −2 lib/stream/base.rb
  67. +1 −1 spec/presenters/post_presenter_spec.rb
View
2 app/controllers/application_controller.rb
@@ -86,7 +86,7 @@ def redirect_unless_admin
def set_grammatical_gender
if (user_signed_in? && I18n.inflector.inflected_locale?)
- gender = current_user.profile.gender.to_s.tr('!()[]"\'`*=|/\#.,-:', '').downcase
+ gender = current_user.gender.to_s.tr('!()[]"\'`*=|/\#.,-:', '').downcase
unless gender.empty?
i_langs = I18n.inflector.inflected_locales(:gender)
i_langs.delete I18n.locale
View
10 app/controllers/conversations_controller.rb
@@ -5,10 +5,10 @@ class ConversationsController < ApplicationController
def index
@conversations = Conversation.joins(:conversation_visibilities).where(
- :conversation_visibilities => {:person_id => current_user.person.id}).paginate(
+ :conversation_visibilities => {:person_id => current_user.person_id}).paginate(
:page => params[:page], :per_page => 15, :order => 'updated_at DESC')
- @visibilities = ConversationVisibility.where(:person_id => current_user.person.id).paginate(
+ @visibilities = ConversationVisibility.where(:person_id => current_user.person_id).paginate(
:page => params[:page], :per_page => 15, :order => 'updated_at DESC')
@unread_counts = {}
@@ -18,7 +18,7 @@ def index
@conversations.each { |c| @authors[c.id] = c.last_author }
@conversation = Conversation.joins(:conversation_visibilities).where(
- :conversation_visibilities => {:person_id => current_user.person.id, :conversation_id => params[:conversation_id]}).first
+ :conversation_visibilities => {:person_id => current_user.person_id, :conversation_id => params[:conversation_id]}).first
respond_with do |format|
format.html
@@ -31,7 +31,7 @@ def create
contact.person_id
end
- params[:conversation][:participant_ids] = person_ids | [current_user.person.id]
+ params[:conversation][:participant_ids] = person_ids | [current_user.person_id]
params[:conversation][:author] = current_user.person
message_text = params[:conversation].delete(:text)
params[:conversation][:messages_attributes] = [ {:author => current_user.person, :text => message_text }]
@@ -52,7 +52,7 @@ def create
def show
if @conversation = Conversation.joins(:conversation_visibilities).where(:id => params[:id],
- :conversation_visibilities => {:person_id => current_user.person.id}).first
+ :conversation_visibilities => {:person_id => current_user.person_id}).first
if @visibility = ConversationVisibility.where(:conversation_id => params[:id], :person_id => current_user.person.id).first
@visibility.unread = 0
@visibility.save
View
2 app/controllers/messages_controller.rb
@@ -11,7 +11,7 @@ class MessagesController < ApplicationController
def create
cnv = Conversation.joins(:conversation_visibilities).where(:id => params[:conversation_id],
- :conversation_visibilities => {:person_id => current_user.person.id}).first
+ :conversation_visibilities => {:person_id => current_user.person_id}).first
if cnv
message = Message.new(:conversation_id => cnv.id, :text => params[:message][:text], :author => current_user.person)
View
2 app/controllers/photos_controller.rb
@@ -58,7 +58,7 @@ def create
end
def make_profile_photo
- author_id = current_user.person.id
+ author_id = current_user.person_id
@photo = Photo.where(:id => params[:photo_id], :author_id => author_id).first
if @photo
View
2 app/controllers/profiles_controller.rb
@@ -42,7 +42,7 @@ def update
@profile_attrs[:nsfw] ||= false
if params[:photo_id]
- @profile_attrs[:photo] = Photo.where(:author_id => current_user.person.id, :id => params[:photo_id]).first
+ @profile_attrs[:photo] = Photo.where(:author_id => current_user.person_id, :id => params[:photo_id]).first
end
if current_user.update_profile(@profile_attrs)
View
2 app/controllers/reshares_controller.rb
@@ -6,7 +6,7 @@ def create
@reshare = current_user.build_post(:reshare, :root_guid => params[:root_guid])
if @reshare.save
current_user.add_to_streams(@reshare, current_user.aspects)
- current_user.dispatch_post(@reshare, :url => post_url(@reshare), :additional_subscribers => @reshare.root.author)
+ current_user.dispatch_post(@reshare, :url => post_url(@reshare), :additional_subscribers => @reshare.root_author)
end
render :json => ExtremePostPresenter.new(@reshare, current_user), :status => 201
View
8 app/controllers/services_controller.rb
@@ -33,9 +33,9 @@ def create
current_user.services << service
if service.persisted?
- fetch_photo = current_user.person.profile[:image_url].blank?
+ fetch_photo = current_user.profile[:image_url].blank?
- current_user.update_profile(current_user.person.profile.from_omniauth_hash(user))
+ current_user.update_profile(current_user.profile.from_omniauth_hash(user))
Resque.enqueue(Jobs::FetchProfilePhoto, current_user.id, service.id, user["image"]) if fetch_photo
flash[:notice] = I18n.t 'services.create.success'
@@ -44,7 +44,7 @@ def create
if existing_service = Service.where(:type => service.type.to_s, :uid => service.uid).first
flash[:error] << I18n.t('services.create.already_authorized',
- :diaspora_id => existing_service.user.person.profile.diaspora_handle,
+ :diaspora_id => existing_service.user.profile.diaspora_handle,
:service_name => provider.camelize )
end
end
@@ -65,4 +65,4 @@ def destroy
redirect_to services_url
end
-end
+end
View
4 app/controllers/users_controller.rb
@@ -101,7 +101,7 @@ def public
if @user = User.find_by_username(params[:username])
respond_to do |format|
format.atom do
- @posts = StatusMessage.where(:author_id => @user.person.id, :public => true).order('created_at DESC').limit(25)
+ @posts = StatusMessage.where(:author_id => @user.person_id, :public => true).order('created_at DESC').limit(25)
end
format.any { redirect_to person_path(@user.person) }
@@ -140,7 +140,7 @@ def user_photo
username = params[:username].split('@')[0]
user = User.find_by_username(username)
if user.present?
- redirect_to user.profile.image_url
+ redirect_to user.image_url
else
render :nothing => true, :status => 404
end
View
6 app/helpers/contacts_helper.rb
@@ -6,9 +6,9 @@ def contact_aspect_dropdown(contact)
:action => 'destroy',
:id => 42,
:aspect_id => @aspect.id,
- :person_id => contact.person.id
+ :person_id => contact.person_id
},
- :title => t('.remove_person_from_aspect', :person_name => contact.person.first_name, :aspect_name => @aspect.name),
+ :title => t('.remove_person_from_aspect', :person_name => contact.person_first_name, :aspect_name => @aspect.name),
:method => 'delete')
else
@@ -17,4 +17,4 @@ def contact_aspect_dropdown(contact)
:current_user => current_user }
end
end
-end
+end
View
2 app/helpers/invitation_codes_helper.rb
@@ -4,7 +4,7 @@ def invite_welcome_message
content_tag(:div, :class => 'media well') do
person_image_link(invite.user.person, :class => 'img') +
content_tag(:div, :class => 'bd') do
- I18n.translate('invitation_codes.excited', :name => invite.user.name)
+ I18n.translate('invitation_codes.excited', :name => invite.user_name)
end
end
end
View
6 app/helpers/mobile_helper.rb
@@ -8,11 +8,11 @@ def mobile_reshare_icon(post)
if (post.public? || reshare?(post)) && (user_signed_in? && post.author != current_user.person)
root = reshare?(post) ? post.root : post
- if root.author != current_user.person.id
- reshare = Reshare.where(:author_id => current_user.person.id,
+ if root.author != current_user.person_id
+ reshare = Reshare.where(:author_id => current_user.person_id,
:root_guid => root.guid).first
klass = reshare.present? ? "active" : "inactive"
- link_to '', reshares_path(:root_guid => root.guid), :title => t('reshares.reshare.reshare_confirmation', :author => root.author.name), :class => "image_link reshare_action #{klass}"
+ link_to '', reshares_path(:root_guid => root.guid), :title => t('reshares.reshare.reshare_confirmation', :author => root.author_name), :class => "image_link reshare_action #{klass}"
end
end
end
View
2 app/helpers/notifications_helper.rb
@@ -13,7 +13,7 @@ def object_link(note, actors)
end
elsif note.instance_of?(Notifications::CommentOnPost) || note.instance_of?(Notifications::AlsoCommented) || note.instance_of?(Notifications::Reshared) || note.instance_of?(Notifications::Liked)
if post = note.linked_object
- translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), post_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
+ translation(target_type, :actors => actors, :count => actors_count, :post_author => h(post.author_name), :post_link => link_to(t('notifications.post'), post_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
else
t(note.deleted_translation_key, :actors => actors, :count => actors_count).html_safe
end
View
6 app/helpers/posts_helper.rb
@@ -5,14 +5,14 @@
module PostsHelper
def post_page_title(post, opts={})
if post.is_a?(Photo)
- I18n.t "posts.show.photos_by", :count => 1, :author => post.status_message.author.name
+ I18n.t "posts.show.photos_by", :count => 1, :author => post.status_message_author_name
elsif post.is_a?(Reshare)
- I18n.t "posts.show.reshare_by", :author => post.author.name
+ I18n.t "posts.show.reshare_by", :author => post.author_name
else
if post.text.present?
truncate(post.text(:plain_text => true), :length => opts.fetch(:length, 20))
elsif post.respond_to?(:photos) && post.photos.present?
- I18n.t "posts.show.photos_by", :count => post.photos.size, :author => post.author.name
+ I18n.t "posts.show.photos_by", :count => post.photos.size, :author => post.author_name
end
end
end
View
5 app/mailers/notification_mailers/also_commented.rb
@@ -3,13 +3,14 @@ class AlsoCommented < NotificationMailers::Base
include ActionView::Helpers::TextHelper
attr_accessor :comment
+ delegate :post, to: :comment, prefix: true
def set_headers(comment_id)
@comment = Comment.find_by_id(comment_id)
if mail?
- @headers[:from] = "\"#{@comment.author.name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>"
- @headers[:subject] = truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN)
+ @headers[:from] = "\"#{@comment.author_name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>"
+ @headers[:subject] = truncate(@comment.comment_email_subject, :length => TRUNCATION_LEN)
@headers[:subject] = "Re: #{@headers[:subject]}"
end
end
View
4 app/mailers/notification_mailers/base.rb
@@ -3,6 +3,10 @@ module NotificationMailers
class Base
attr_accessor :recipient, :sender
+
+ delegate :unconfirmed_email, :confirm_email_token,
+ :first_name, to: :recipient, prefix: true
+ delegate :first_name, :name, :sender, to: :sender, prefix: true
def initialize(recipient_id, sender_id=nil, *args)
@headers = {}
View
4 app/mailers/notification_mailers/comment_on_post.rb
@@ -7,8 +7,8 @@ class CommentOnPost < NotificationMailers::Base
def set_headers(comment_id)
@comment = Comment.find(comment_id)
- @headers[:from] = "\"#{@comment.author.name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>"
- @headers[:subject] = truncate(@comment.parent.comment_email_subject, :length => TRUNCATION_LEN)
+ @headers[:from] = "\"#{@comment.author_name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>"
+ @headers[:subject] = truncate(@comment.comment_email_subject, :length => TRUNCATION_LEN)
@headers[:subject] = "Re: #{@headers[:subject]}"
end
end
View
2 app/mailers/notification_mailers/confirm_email.rb
@@ -1,7 +1,7 @@
module NotificationMailers
class ConfirmEmail < NotificationMailers::Base
def set_headers
- @headers[:to] = name_and_address(@recipient.profile.first_name, @recipient.unconfirmed_email)
+ @headers[:to] = name_and_address(@recipient.first_name, @recipient.unconfirmed_email)
@headers[:subject] = I18n.t('notifier.confirm_email.subject', :unconfirmed_email => @recipient.unconfirmed_email)
end
end
View
3 app/mailers/notification_mailers/liked.rb
@@ -1,6 +1,7 @@
module NotificationMailers
class Liked < NotificationMailers::Base
attr_accessor :like
+ delegate :target, to: :like, prefix: true
def set_headers(like_id)
@like = Like.find(like_id)
@@ -8,4 +9,4 @@ def set_headers(like_id)
@headers[:subject] = I18n.t('notifier.liked.liked', :name => @sender.name)
end
end
-end
+end
View
3 app/mailers/notification_mailers/mentioned.rb
@@ -1,6 +1,7 @@
module NotificationMailers
class Mentioned < NotificationMailers::Base
attr_accessor :post
+ delegate :author_name, to: :post, prefix: true
def set_headers(target_id)
@post = Mention.find_by_id(target_id).post
@@ -8,4 +9,4 @@ def set_headers(target_id)
@headers[:subject] = I18n.t('notifier.mentioned.subject', :name => @sender.name)
end
end
-end
+end
View
2 app/mailers/notification_mailers/private_message.rb
@@ -7,7 +7,7 @@ def set_headers(message_id)
@conversation = @message.conversation
@participants = @conversation.participants
- @headers[:from] = "\"#{@message.author.name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>"
+ @headers[:from] = "\"#{@message.author_name} (Diaspora*)\" <#{AppConfig[:smtp_sender_address]}>"
@headers[:subject] = @conversation.subject.strip
@headers[:subject] = "Re: #{@headers[:subject]}" if @conversation.messages.size > 1
end
View
4 app/mailers/notification_mailers/reshared.rb
@@ -1,6 +1,8 @@
module NotificationMailers
class Reshared < NotificationMailers::Base
attr_accessor :reshare
+
+ delegate :root, to: :reshare, prefix: true
def set_headers(reshare_id)
@reshare = Reshare.find(reshare_id)
@@ -8,4 +10,4 @@ def set_headers(reshare_id)
@headers[:subject] = I18n.t('notifier.reshared.reshared', :name => @sender.name)
end
end
-end
+end
View
2 app/mailers/notifier.rb
@@ -43,7 +43,7 @@ def invite(email, message, inviter, invitation_code, locale)
@invitation_code = invitation_code
mail_opts = {:to => email, :from => AppConfig[:smtp_sender_address],
- :subject => I18n.t('notifier.invited_you', :name => @inviter.person.name),
+ :subject => I18n.t('notifier.invited_you', :name => @inviter.name),
:host => AppConfig[:pod_uri].host}
I18n.with_locale(locale) do
View
4 app/models/block.rb
@@ -2,6 +2,8 @@ class Block < ActiveRecord::Base
belongs_to :person
belongs_to :user
+ delegate :name, to: :person, prefix: true
+
validates :user_id, :presence => true
validates :person_id, :presence => true, :uniqueness => { :scope => :user_id }
@@ -12,4 +14,4 @@ def not_blocking_yourself
errors[:person_id] << "stop blocking yourself!"
end
end
-end
+end
View
4 app/models/comment.rb
@@ -22,6 +22,10 @@ class Comment < ActiveRecord::Base
belongs_to :commentable, :touch => true, :polymorphic => true
alias_attribute :post, :commentable
belongs_to :author, :class_name => 'Person'
+
+ delegate :name, to: :author, prefix: true
+ delegate :comment_email_subject, to: :parent
+ delegate :author_name, to: :parent, prefix: true
validates :text, :presence => true, :length => {:maximum => 65535}
validates :parent, :presence => true #should be in relayable (pending on fixing Message)
View
5 app/models/contact.rb
@@ -7,6 +7,9 @@ class Contact < ActiveRecord::Base
belongs_to :person
validates :person, :presence => true
+
+ delegate :name, :diaspora_handle, :guid, :first_name,
+ to: :person, prefix: true
has_many :aspect_memberships
has_many :aspects, :through => :aspect_memberships
@@ -72,7 +75,7 @@ def contacts
incoming_aspects = Aspect.where(
:user_id => self.person.owner_id,
:contacts_visible => true).joins(:contacts).where(
- :contacts => {:person_id => self.user.person.id}).select('aspects.id')
+ :contacts => {:person_id => self.user.person_id}).select('aspects.id')
incoming_aspect_ids = incoming_aspects.map{|a| a.id}
similar_contacts = Person.joins(:contacts => :aspect_memberships).where(
:aspect_memberships => {:aspect_id => incoming_aspect_ids}).where(people[:id].not_eq(self.user.person.id)).select('DISTINCT people.*')
View
2 app/models/invitation_code.rb
@@ -5,6 +5,8 @@ class InvitationCode < ActiveRecord::Base
before_create :generate_token, :set_default_invite_count
+ delegate :name, to: :user, prefix: true
+
def to_param
token
end
View
2 app/models/message.rb
@@ -11,6 +11,8 @@ class Message < ActiveRecord::Base
belongs_to :author, :class_name => 'Person'
belongs_to :conversation, :touch => true
+
+ delegate :name, to: :author, prefix: true
validates :text, :presence => true
validate :participant_of_parent_conversation
View
4 app/models/person.rb
@@ -32,7 +32,9 @@ class Person < ActiveRecord::Base
xml_attr :exported_key
has_one :profile, :dependent => :destroy
- delegate :last_name, :image_url, :to => :profile
+ delegate :last_name, :image_url, :tag_string, :bio, :location,
+ :gender, :birthday, :formatted_birthday, :tags, :searchable,
+ to: :profile
accepts_nested_attributes_for :profile
before_validation :downcase_diaspora_handle
View
1 app/models/photo.rb
@@ -41,6 +41,7 @@ class Photo < ActiveRecord::Base
belongs_to :status_message, :foreign_key => :status_message_guid, :primary_key => :guid
validates_associated :status_message
+ delegate :author_name, to: :status_message, prefix: true
attr_accessible :text, :pending
validate :ownership_of_status_message
View
3 app/models/reshare.rb
@@ -9,6 +9,7 @@ class Reshare < Post
attr_accessible :root_guid, :public
validates_presence_of :root, :on => :create
validates_uniqueness_of :root_guid, :scope => :author_id
+ delegate :author, to: :root, prefix: true
xml_attr :root_diaspora_id
xml_attr :root_guid
@@ -58,7 +59,7 @@ def receive(recipient, sender)
end
def comment_email_subject
- I18n.t('reshares.comment_email_subject', :resharer => author.name, :author => root.author.name)
+ I18n.t('reshares.comment_email_subject', :resharer => author.name, :author => root.author_name)
end
def notification_type(user, person)
View
4 app/models/status_message.rb
@@ -146,6 +146,10 @@ def comment_email_subject
formatted_message(:plain_text => true)
end
+ def first_photo_url(*args)
+ photos.first.url(*args)
+ end
+
def text_and_photos_blank?
self.text.blank? && self.photos.blank?
end
View
7 app/models/user.rb
@@ -38,7 +38,10 @@ class User < ActiveRecord::Base
serialize :hidden_shareables, Hash
has_one :person, :foreign_key => :owner_id
- delegate :guid, :public_key, :posts, :photos, :owns?, :diaspora_handle, :name, :public_url, :profile, :first_name, :last_name, :participations, :to => :person
+ delegate :guid, :public_key, :posts, :photos, :owns?, :image_url,
+ :diaspora_handle, :name, :public_url, :profile, :url,
+ :first_name, :last_name, :gender, :participations, to: :person
+ delegate :id, :guid, to: :person, prefix: true
has_many :invitations_from_me, :class_name => 'Invitation', :foreign_key => :sender_id
has_many :invitations_to_me, :class_name => 'Invitation', :foreign_key => :recipient_id
@@ -361,7 +364,7 @@ def update_profile(params)
params[:image_url_small] = photo.url(:thumb_small)
end
- if self.person.profile.update_attributes(params)
+ if self.profile.update_attributes(params)
Postzord::Dispatcher.build(self, profile).post
true
else
View
6 app/presenters/o_embed_presenter.rb
@@ -15,7 +15,7 @@ def to_json(opts={})
def as_json(opts={})
{
:provider_name => "Diaspora",
- :provider_url => AppConfig[:pod_url],
+ :provider_hurl => AppConfig[:pod_url],
:type => 'rich',
:version => '1.0',
:title => post_title,
@@ -36,7 +36,7 @@ def post_title
end
def post_author
- @post.author.name
+ @post.author_name
end
def post_author_url
@@ -46,4 +46,4 @@ def post_author_url
def iframe_html
post_iframe_url(@post.id, :height => @opts[:maxheight], :width => @opts[:maxwidth])
end
-end
+end
View
8 app/presenters/person_presenter.rb
@@ -12,9 +12,9 @@ def as_json(options={})
if is_own_profile || person_is_following_current_user
attrs.merge!({
- :location => @person.profile.location,
- :birthday => @person.profile.formatted_birthday,
- :bio => @person.profile.bio
+ :location => @person.location,
+ :birthday => @person.formatted_birthday,
+ :bio => @person.bio
})
end
@@ -30,4 +30,4 @@ def is_own_profile
def person_is_following_current_user
@person.shares_with(@current_user)
end
-end
+end
View
2 app/presenters/post_presenter.rb
@@ -55,7 +55,7 @@ def previous_post_path
end
def title
- @post.text.present? ? @post.text(:plain_text => true) : I18n.translate('posts.presenter.title', :name => @post.author.name)
+ @post.text.present? ? @post.text(:plain_text => true) : I18n.translate('posts.presenter.title', :name => @post.author_name)
end
def template_name #kill me, lol, I should be client side
View
2 app/views/community_spotlight/_user.html.haml
@@ -4,7 +4,7 @@
= person.name
.tags
- - person.profile.tags.each do |tag|
+ - person.tags.each do |tag|
= link_to "##{tag}", tag_path(:name => tag.name)
.add_user_to_aspect
View
4 app/views/contacts/index.html.haml
@@ -29,7 +29,7 @@
- if @contacts.size > 0
- for contact in @contacts
- .stream_element{:id => contact.person.id}
+ .stream_element{:id => contact.person_id}
.float-right
= contact_aspect_dropdown(contact)
@@ -41,7 +41,7 @@
.bd
= person_link(contact.person)
.info
- = contact.person.diaspora_handle
+ = contact.person_diaspora_handle
= will_paginate @contacts
- else
View
4 app/views/contacts/sharing.haml
@@ -18,9 +18,9 @@
%li{:data=>{:contact_id=>contact.id}}
= person_image_tag contact.person
%h4.name
- = link_to contact.person.name, contact.person
+ = link_to contact.person_name, contact.person
.description
- = contact.person.diaspora_handle
+ = contact.person_diaspora_handle
.right
= aspect_membership_dropdown(contact, contact.person, 'right')
View
2 app/views/notifications/_notify_popup_item.haml
@@ -1,5 +1,5 @@
.notification_element{:data=>{:guid => n.id},:class => (n.unread ? "unread" : "read")}
- %img{:src => n.actors.first.profile.image_url(:thumb_medium)}
+ %img{:src => n.actors.first.image_url(:thumb_medium)}
= notification_message_for(n)
%br/
%abbr.timeago{:title=>n.created_at.iso8601}
View
4 app/views/notifier/also_commented.markerb
@@ -1,5 +1,5 @@
<%= comment_message(@notification.comment, :process_newlines => true) %>
-[<%= t('notifier.comment_on_post.reply', :name => @notification.comment.post.author.first_name) %>][1]
+[<%= t('notifier.comment_on_post.reply', :name => @notification.comment_post.author_first_name) %>][1]
-[1]: <%= post_url(@notification.comment.post) %>
+[1]: <%= post_url(@notification.comment_post) %>
View
2 app/views/notifier/comment_on_post.markerb
@@ -1,5 +1,5 @@
<%= comment_message(@notification.comment, :process_newlines => true) %>
-[<%= t('notifier.comment_on_post.reply', :name => @notification.comment.post.author.name) %>][1]
+[<%= t('notifier.comment_on_post.reply', :name => @notification.comment.parent_author_name) %>][1]
[1]: <%= post_url(@notification.comment.post) %>
View
6 app/views/notifier/confirm_email.markerb
@@ -1,5 +1,5 @@
-<%= t('notifier.hello', :name => @notification.recipient.profile.first_name) %>
+<%= t('notifier.hello', :name => @notification.recipient_first_name) %>
-<%= t('notifier.confirm_email.click_link', :unconfirmed_email => @notification.recipient.unconfirmed_email) %>
+<%= t('notifier.confirm_email.click_link', :unconfirmed_email => @notification.recipient_unconfirmed_email) %>
-<<%= confirm_email_url(:token => @notification.recipient.confirm_email_token) %>>
+<<%= confirm_email_url(:token => @notification.recipient_confirm_email_token) %>>
View
6 app/views/notifier/liked.markerb
@@ -1,7 +1,7 @@
-<%= "#{t('.liked', :name => "#{@notification.sender.name}")}:" %>
+<%= "#{t('.liked', :name => "#{@notification.sender_name}")}:" %>
-<%= post_message(@notification.like.target, :process_newlines => true) %>
+<%= post_message(@notification.like_target, :process_newlines => true) %>
[<%= t('.view_post') %>][1]
-[1]: <%= post_url(@notification.like.target) %>
+[1]: <%= post_url(@notification.like_target) %>
View
2 app/views/notifier/mentioned.markerb
@@ -1,5 +1,5 @@
<%= post_message(@notification.post, :process_newlines => true, :length => 600) %>
-[<%= t('notifier.comment_on_post.reply', :name => @notification.post.author.name) %>][1]
+[<%= t('notifier.comment_on_post.reply', :name => @notification.post_author_name) %>][1]
[1]: <%= post_url(@notification.post) %>
View
4 app/views/notifier/reshared.markerb
@@ -1,6 +1,6 @@
-<%= "#{t('.reshared', :name => "#{@notification.sender.name}")}:" %>
+<%= "#{t('.reshared', :name => "#{@notification.sender_name}")}:" %>
-<%= post_message(@notification.reshare.root, :process_newlines => true) %>
+<%= post_message(@notification.reshare_root, :process_newlines => true) %>
[<%= t('.view_post') %>][1]
View
4 app/views/notifier/started_sharing.markerb
@@ -1,5 +1,5 @@
-<%= @notification.sender.name %> <%= t('.sharing') %>
+<%= @notification.sender_name %> <%= t('.sharing') %>
-[<%= t('.view_profile', :name => @notification.sender.first_name) %>][1]
+[<%= t('.view_profile', :name => @notification.sender_first_name) %>][1]
[1]: <%= local_or_remote_person_path(@notification.sender, :absolute => true) %>
View
16 app/views/people/_profile_sidebar.html.haml
@@ -17,30 +17,30 @@
%br
-if contact.sharing? || person == current_user.person
%ul#profile_information
- - unless person.profile.bio.blank?
+ - unless person.bio.blank?
%li
%h4
=t('.bio')
- %div{ :class => direction_for(person.profile.bio) }
+ %div{ :class => direction_for(person.bio) }
= markdownify(person.profile.bio, :oembed => true, :newlines => true)
- unless person.profile.location.blank?
%li
%h4
=t('.location')
- %div{ :class => direction_for(person.profile.location) }
- = markdownify(person.profile.location, :oembed => true, :newlines => true)
+ %div{ :class => direction_for(person.location) }
+ = markdownify(person.location, :oembed => true, :newlines => true)
%li
- - unless person.profile.gender.blank?
+ - unless person.gender.blank?
%h4
=t('.gender')
- = person.profile.gender
+ = person.gender
%li
- - unless person.profile.birthday.blank?
+ - unless person.birthday.blank?
%h4
=t('.born')
- = birthday_format(person.profile.birthday)
+ = birthday_format(person.birthday)
%br
%br
View
2 app/views/people/_sub_header.html.haml
@@ -18,7 +18,7 @@
= last_post_link person
.description
- - if !person.profile.tag_string.blank? && user_signed_in?
+ - if !person.tag_string.blank? && user_signed_in?
= Diaspora::Taggable.format_tags(person.profile.tag_string)
- if user_signed_in? && person == current_user.person
%span.hover_edit
View
2 app/views/photos/_photo.haml
@@ -10,5 +10,5 @@
%p.photo_description
= post.text
-= link_to t('.view_all', :name => post.author.name), person_photos_path(post.author), :class => "small_text"
+= link_to t('.view_all', :name => post.author_name), person_photos_path(post.author), :class => "small_text"
View
2 app/views/posts/_photo.html.haml
@@ -9,7 +9,7 @@
= person_image_link(post.author)
.from
%h2
- = post.author.name
+ = post.author_name
#show_photo{:data=>{:guid=>post.id}}
= image_tag post.url(:scaled_full)
View
10 app/views/publics/hcard.haml
@@ -17,7 +17,7 @@
%dl.entity_family_name
%dt Family name
%dd
- %span.family_name= @person.profile.last_name
+ %span.family_name= @person.last_name
%dl.entity_fn
%dt Full name
@@ -32,19 +32,19 @@
%dl.entity_photo
%dt Photo
%dd
- %img.photo.avatar{:src=>@person.profile.image_url, :width=>'300px', :height=>'300px'}
+ %img.photo.avatar{:src=>@person.image_url, :width=>'300px', :height=>'300px'}
%dl.entity_photo_medium
%dt Photo
%dd
- %img.photo.avatar{:src=>@person.profile.image_url(:thumb_medium), :width=>'100px', :height=>'100px'}
+ %img.photo.avatar{:src=>@person.image_url(:thumb_medium), :width=>'100px', :height=>'100px'}
%dl.entity_photo_small
%dt Photo
%dd
- %img.photo.avatar{:src=>@person.profile.image_url(:thumb_small), :width=>'50px', :height=>'50px'}
+ %img.photo.avatar{:src=>@person.image_url(:thumb_small), :width=>'50px', :height=>'50px'}
%dl.entity_searchable
%dt Searchable
%dd
- %span.searchable= @person.profile.searchable
+ %span.searchable= @person.searchable
View
2 app/views/shared/_photo_area.mobile.haml
@@ -9,7 +9,7 @@
- if post.photos.size > 1
.additional_photo_count
= "+ #{post.photos.size-1}"
- = image_tag post.photos.first.url(:thumb_large), :class => "stream-photo big-stream-photo"
+ = image_tag post.first_photo_url(:thumb_large), :class => "stream-photo big-stream-photo"
- elsif post.activity_streams?
= image_tag post.image_url
View
2 app/views/status_messages/_status_message.mobile.haml
@@ -10,7 +10,7 @@
- if post.photos.size > 1
.additional_photo_count
= "+ #{post.photos.size-1}"
- = image_tag post.photos.first.url(:thumb_large), :class => "stream-photo big-stream-photo"
+ = image_tag post.first_photo_url(:thumb_large), :class => "stream-photo big-stream-photo"
- elsif post.activity_streams?
= image_tag post.image_url
View
2 app/views/users/getting_started.haml
@@ -38,7 +38,7 @@
.clearfix
= label_tag 'profile[first_name]', t('profiles.edit.your_name'), :class => "bootstrapped"
.input
- = text_field_tag 'profile[first_name]', current_user.person.profile.first_name
+ = text_field_tag 'profile[first_name]', current_user.first_name
= image_tag 'ajax-loader.gif', :id => "gs-name-form-spinner", :class => "hidden"
%span.saved{:class => "hidden"}
View
2 app/views/users/privacy_settings.html.haml
@@ -15,7 +15,7 @@
= t('.ignored_users')
- @blocks.each do |block|
- = block.person.name
+ = block.person_name
\-
= link_to t('.stop_ignoring'), block_path(block),
:method => :delete
View
10 app/views/users/public.atom.builder
@@ -11,10 +11,10 @@ atom_feed({'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
feed.tag! :generator, 'Diaspora', :uri => "#{AppConfig[:pod_url]}"
feed.title "#{@user.name}'s Public Feed"
feed.subtitle "Updates from #{@user.name} on Diaspora"
- feed.logo "#{@user.person.profile.image_url(:thumb_small)}"
+ feed.logo "#{@user.image_url(:thumb_small)}"
feed.updated @posts[0].created_at if @posts.length > 0
feed.tag! :link, :rel => 'avatar', :type => 'image/jpeg', 'media:width' => '100',
- 'media:height' => '100', :href => "#{@user.profile.image_url}"
+ 'media:height' => '100', :href => "#{@user.image_url}"
feed.tag! :link, :href => "#{AppConfig[:pubsub_server]}", :rel => 'hub'
feed.author do |author|
@@ -23,13 +23,13 @@ atom_feed({'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
author.tag! 'activity:object-type', 'http://activitystrea.ms/schema/1.0/person'
author.tag! 'poco:preferredUsername', @user.username
- author.tag! 'poco:displayName', @user.person.name
+ author.tag! 'poco:displayName', @user.name
end
@posts.each do |post|
- feed.entry post, :url => "#{@user.person.url}p/#{post.id}",
- :id => "#{@user.person.url}p/#{post.id}" do |entry|
+ feed.entry post, :url => "#{@user.url}p/#{post.id}",
+ :id => "#{@user.url}p/#{post.id}" do |entry|
entry.title truncate(post.formatted_message(:plain_text => true), :length => 50)
entry.content auto_link(post.formatted_message(:plain_text => true)), :type => 'html'
View
2 lib/collect_user_photos.rb
@@ -5,7 +5,7 @@ def self.move_photos(user)
FileUtils::mkdir_p temp_dir
Dir.chdir 'tmp/exports'
- photos = user.visible_shareables(Post).where(:author_id => user.person.id, :type => 'Photo')
+ photos = user.visible_shareables(Post).where(:author_id => user.person_id, :type => 'Photo')
photos_dir = "#{user.id}/photos"
FileUtils::mkdir_p photos_dir
View
4 lib/diaspora/exporter.rb
@@ -14,7 +14,7 @@ module Exporters
module XML
def execute(user)
builder = Nokogiri::XML::Builder.new do |xml|
- user_person_id = user.person.id
+ user_person_id = user.person_id
xml.export {
xml.user {
xml.username user.username
@@ -50,7 +50,7 @@ def execute(user)
xml.contact {
xml.user_id contact.user_id
xml.person_id contact.person_id
- xml.person_guid contact.person.guid
+ xml.person_guid contact.person_guid
xml.aspects {
contact.aspects.each do |aspect|
View
5 lib/diaspora/relayable.rb
@@ -17,7 +17,8 @@ def self.included(model)
validates :author, :presence => true
validate :author_is_not_ignored
- delegate :public?, :to => :parent
+ delegate :public?, to: :parent
+ delegate :author, :diaspora_handle, to: :parent, prefix: true
after_create do
parent.touch(:interacted_at) if parent.respond_to?(:interacted_at)
@@ -68,7 +69,7 @@ def receive(user, person=nil)
comment_or_like = self.class.where(:guid => self.guid).first || self
# Check to make sure the signature of the comment or like comes from the person claiming to author it
- unless comment_or_like.parent.author == user.person || comment_or_like.verify_parent_author_signature
+ unless comment_or_like.parent_author == user.person || comment_or_like.verify_parent_author_signature
Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{user.diaspora_handle} sender=#{self.parent.author.diaspora_handle} payload_type=#{self.class} parent_id=#{self.parent.id}")
return
end
View
3 lib/diaspora/shareable.rb
@@ -16,6 +16,7 @@ def self.included(model)
belongs_to :author, :class_name => 'Person'
+ delegate :id, :name, :first_name, to: :author, prefix: true
#scopes
scope :all_public, where(:public => true, :pending => false)
@@ -26,7 +27,7 @@ def self.owned_or_visible_by_user(user)
where(
Contact.arel_table[:user_id].eq(user.id).or(
self.arel_table[:public].eq(true).or(
- self.arel_table[:author_id].eq(user.person.id)
+ self.arel_table[:author_id].eq(user.person_id)
)
)
).
View
2 lib/email_inviter.rb
@@ -27,4 +27,4 @@ def send!
def mail(email)
Notifier.invite(email, message, inviter, invitation_code, locale).deliver!
end
-end
+end
View
6 lib/postzord/dispatcher.rb
@@ -118,8 +118,8 @@ def deliver_to_local(people)
batch_deliver_to_local(people)
else
people.each do |person|
- Rails.logger.info("event=push route=local sender=#{@sender.person.diaspora_handle} recipient=#{person.diaspora_handle} payload_type=#{@object.class}")
- Resque.enqueue(Jobs::Receive, person.owner_id, @xml, @sender.person.id)
+ Rails.logger.info("event=push route=local sender=#{@sender.diaspora_handle} recipient=#{person.diaspora_handle} payload_type=#{@object.class}")
+ Resque.enqueue(Jobs::Receive, person.owner_id, @xml, @sender.person_id)
end
end
end
@@ -128,7 +128,7 @@ def deliver_to_local(people)
def batch_deliver_to_local(people)
ids = people.map{ |p| p.owner_id }
Resque.enqueue(Jobs::ReceiveLocalBatch, @object.class.to_s, @object.id, ids)
- Rails.logger.info("event=push route=local sender=#{@sender.person.diaspora_handle} recipients=#{ids.join(',')} payload_type=#{@object.class}")
+ Rails.logger.info("event=push route=local sender=#{@sender.diaspora_handle} recipients=#{ids.join(',')} payload_type=#{@object.class}")
end
def deliver_to_hub
View
4 lib/postzord/receiver/local_batch.rb
@@ -32,9 +32,9 @@ def receive!
# NOTE(copied over from receiver public)
# @return [Object]
def receive_relayable
- if @object.parent.author.local?
+ if @object.parent_author.local?
# receive relayable object only for the owner of the parent object
- @object.receive(@object.parent.author.owner)
+ @object.receive(@object.parent_author.owner)
end
@object
end
View
2 lib/postzord/receiver/private.rb
@@ -76,7 +76,7 @@ def validate_object
def xml_author
if @object.respond_to?(:relayable?)
#if A and B are friends, and A sends B a comment from C, we delegate the validation to the owner of the post being commented on
- xml_author = @user.owns?(@object.parent) ? @object.diaspora_handle : @object.parent.author.diaspora_handle
+ xml_author = @user.owns?(@object.parent) ? @object.diaspora_handle : @object.parent_author.diaspora_handle
@author = Webfinger.new(@object.diaspora_handle).fetch if @object.author
else
xml_author = @object.diaspora_handle
View
6 lib/postzord/receiver/public.rb
@@ -38,9 +38,9 @@ def receive!
# @return [Object]
def receive_relayable
- if @object.parent.author.local?
+ if @object.parent_author.local?
# receive relayable object only for the owner of the parent object
- @object.receive(@object.parent.author.owner, @author)
+ @object.receive(@object.parent_author.owner, @author)
end
# notify everyone who can see the parent object
receiver = Postzord::Receiver::LocalBatch.new(@object, self.recipient_user_ids)
@@ -64,7 +64,7 @@ def recipient_user_ids
def xml_author
if @object.respond_to?(:relayable?)
#this is public, so it would only be owners sending us other people comments etc
- @object.parent.author.local? ? @object.diaspora_handle : @object.parent.diaspora_handle
+ @object.parent_author.local? ? @object.diaspora_handle : @object.parent_diaspora_handle
else
@object.diaspora_handle
end
View
4 lib/stream/base.rb
@@ -100,7 +100,7 @@ def order=(order_string)
def like_posts_for_stream!(posts)
return posts unless @user
- likes = Like.where(:author_id => @user.person.id, :target_id => posts.map(&:id), :target_type => "Post")
+ likes = Like.where(:author_id => @user.person_id, :target_id => posts.map(&:id), :target_type => "Post")
like_hash = likes.inject({}) do |hash, like|
hash[like.target_id] = like
@@ -133,7 +133,7 @@ def spotlight_diaspora_id
def post_is_from_contact?(post)
@can_comment_cache ||= {}
@can_comment_cache[post.id] ||= contacts_in_stream.find{|contact| contact.person_id == post.author.id}.present?
- @can_comment_cache[post.id] ||= (user.person.id == post.author.id)
+ @can_comment_cache[post.id] ||= (user.person_id == post.author_id)
@can_comment_cache[post.id]
end
end
View
2 spec/presenters/post_presenter_spec.rb
@@ -75,7 +75,7 @@
context 'with posts without text' do
it ' displays a messaage with the post class' do
- @sm = stub(:text => "", :author => bob.person)
+ @sm = stub(:text => "", :author => bob.person, :author_name => bob.person.name)
@presenter.post = @sm
@presenter.title.should == "A post from #{@sm.author.name}"
end

0 comments on commit 06d9ff2

Please sign in to comment.
Something went wrong with that request. Please try again.