Merge branch 'master' of github.com:diaspora/diaspora_rails into pivots
Conflicts: app/models/user.rb app/views/groups/index.html.haml config/deploy_config.yml
This commit is contained in:
commit
61c906a9d3
17 changed files with 145 additions and 67 deletions
|
|
@ -18,7 +18,6 @@ class ApplicationController < ActionController::Base
|
||||||
if current_user
|
if current_user
|
||||||
@groups = current_user.groups
|
@groups = current_user.groups
|
||||||
@friends = current_user.friends
|
@friends = current_user.friends
|
||||||
@latest_status_message = StatusMessage.newest_for(current_user.person)
|
|
||||||
@group = params[:group] ? current_user.group_by_id(params[:group]) : current_user.groups.first
|
@group = params[:group] ? current_user.group_by_id(params[:group]) : current_user.groups.first
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,15 @@ class PublicsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def receive
|
def receive
|
||||||
@user = Person.first(:id => params[:id]).owner
|
render :nothing => true
|
||||||
|
begin
|
||||||
|
@user = Person.first(:id => params[:id]).owner
|
||||||
|
rescue NoMethodError => e
|
||||||
|
Rails.logger.error("Received post #{params[:xml]} for nonexistent person #{params[:id]}")
|
||||||
|
return
|
||||||
|
end
|
||||||
Rails.logger.debug "PublicsController has received: #{params[:xml]}"
|
Rails.logger.debug "PublicsController has received: #{params[:xml]}"
|
||||||
@user.receive params[:xml] if params[:xml]
|
@user.receive params[:xml] if params[:xml]
|
||||||
render :nothing => true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,9 @@ class StatusMessagesController < ApplicationController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@status_messages = StatusMessage.paginate :page => params[:page], :order => 'created_at DESC'
|
@status_messages = StatusMessage.paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
|
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ class Album
|
||||||
|
|
||||||
def self.mine_or_friends(friend_param, current_user)
|
def self.mine_or_friends(friend_param, current_user)
|
||||||
if friend_param
|
if friend_param
|
||||||
|
puts "i am working"
|
||||||
Album.find_all_by_person_id(current_user.friend_ids)
|
Album.find_all_by_person_id(current_user.friend_ids)
|
||||||
else
|
else
|
||||||
current_user.person.albums
|
current_user.person.albums
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,15 @@ class Group
|
||||||
include MongoMapper::Document
|
include MongoMapper::Document
|
||||||
|
|
||||||
key :name, String
|
key :name, String
|
||||||
|
validates_presence_of :name
|
||||||
|
|
||||||
key :person_ids, Array
|
key :person_ids, Array
|
||||||
key :request_ids, Array
|
key :request_ids, Array
|
||||||
|
key :post_ids, Array
|
||||||
|
|
||||||
many :people, :in => :person_ids, :class_name => 'Person'
|
many :people, :in => :person_ids, :class_name => 'Person'
|
||||||
many :requests, :in => :request_ids, :class_name => 'Request'
|
many :requests, :in => :request_ids, :class_name => 'Request'
|
||||||
|
many :posts, :in => :post_ids, :class_name => 'Post'
|
||||||
|
|
||||||
belongs_to :user, :class_name => 'User'
|
belongs_to :user, :class_name => 'User'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,10 @@ class User
|
||||||
######## Posting ########
|
######## Posting ########
|
||||||
def post(class_name, options = {})
|
def post(class_name, options = {})
|
||||||
options[:person] = self.person
|
options[:person] = self.person
|
||||||
|
|
||||||
|
group_id = options[:group_id]
|
||||||
|
options.delete(:group_id)
|
||||||
|
|
||||||
model_class = class_name.to_s.camelize.constantize
|
model_class = class_name.to_s.camelize.constantize
|
||||||
post = model_class.instantiate(options)
|
post = model_class.instantiate(options)
|
||||||
post.creator_signature = post.sign_with_key(encryption_key)
|
post.creator_signature = post.sign_with_key(encryption_key)
|
||||||
|
|
@ -62,6 +66,12 @@ class User
|
||||||
|
|
||||||
self.raw_visible_posts << post
|
self.raw_visible_posts << post
|
||||||
self.save
|
self.save
|
||||||
|
|
||||||
|
if group_id
|
||||||
|
group = self.groups.find_by_id(group_id)
|
||||||
|
group.posts << post
|
||||||
|
group.save
|
||||||
|
end
|
||||||
|
|
||||||
post
|
post
|
||||||
end
|
end
|
||||||
|
|
@ -69,7 +79,7 @@ class User
|
||||||
def visible_posts( opts = {} )
|
def visible_posts( opts = {} )
|
||||||
if opts[:by_members_of]
|
if opts[:by_members_of]
|
||||||
group = self.groups.find_by_id( opts[:by_members_of].id )
|
group = self.groups.find_by_id( opts[:by_members_of].id )
|
||||||
self.raw_visible_posts.find_all_by_person_id( (group.person_ids + [self.person.id] ), :order => "created_at desc")
|
group.posts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -260,7 +270,7 @@ class User
|
||||||
person.save
|
person.save
|
||||||
|
|
||||||
elsif object.is_a?(Comment)
|
elsif object.is_a?(Comment)
|
||||||
dispatch_comment object unless owns?(object)
|
dispatch_comment object unless owns?(object)
|
||||||
else
|
else
|
||||||
Rails.logger.debug("Saving object: #{object}")
|
Rails.logger.debug("Saving object: #{object}")
|
||||||
object.user_refs += 1
|
object.user_refs += 1
|
||||||
|
|
@ -269,13 +279,18 @@ class User
|
||||||
self.raw_visible_posts << object
|
self.raw_visible_posts << object
|
||||||
self.save
|
self.save
|
||||||
|
|
||||||
groups = groups_with_person(object.person)
|
groups = self.groups_with_person(object.person)
|
||||||
object.socket_to_uid(id, :group_id => group.id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
groups.each{ |group|
|
||||||
|
group.posts << object
|
||||||
|
group.save
|
||||||
|
object.socket_to_uid(id, :group_id => group.id) if (object.respond_to?(:socket_to_uid) && !self.owns?(object))
|
||||||
|
}
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
###Helpers############
|
###Helpers############
|
||||||
|
|
||||||
def terse_url
|
def terse_url
|
||||||
terse= self.url.gsub(/https?:\/\//, '')
|
terse= self.url.gsub(/https?:\/\//, '')
|
||||||
terse.gsub!(/www\./, '')
|
terse.gsub!(/www\./, '')
|
||||||
|
|
@ -312,7 +327,8 @@ class User
|
||||||
end
|
end
|
||||||
|
|
||||||
def groups_with_person person
|
def groups_with_person person
|
||||||
groups.select {|group| group.person_ids.include? person.id}
|
id = ensure_bson person.id
|
||||||
|
groups.select {|group| group.person_ids.include? id}
|
||||||
end
|
end
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
= render "shared/publisher"
|
= render "shared/publisher", :group_id => @group.id
|
||||||
|
|
||||||
%ul#stream
|
%ul#stream
|
||||||
- for post in @posts
|
- for post in @posts
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
= render "shared/publisher"
|
= render "shared/publisher", :group_id => @group.id
|
||||||
%ul#stream
|
%ul#stream
|
||||||
- for post in @posts
|
- for post in @posts
|
||||||
= render type_partial(post), :post => post
|
= render type_partial(post), :post => post
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,12 @@
|
||||||
#friend_pictures
|
#friend_pictures
|
||||||
- for friend in @group.people
|
- for friend in @group.people
|
||||||
= person_image_link(friend)
|
= person_image_link(friend)
|
||||||
= link_to "+", "#add_request_pane", :id => 'add_request_button', :class => "add_new"
|
= link_to (image_tag 'add_friend_button.png'), "#add_request_pane", :id => 'add_request_button'
|
||||||
|
|
||||||
|
- if @group.people.count == 0
|
||||||
|
%span.add_new_description
|
||||||
|
<< click the plus to add friends to this group
|
||||||
|
|
||||||
|
|
||||||
.yo{:style => 'display:none'}
|
.yo{:style => 'display:none'}
|
||||||
#add_request_pane
|
#add_request_pane
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
#publisher_form
|
#publisher_form
|
||||||
= form_for StatusMessage.new, :remote => true do |f|
|
= form_for StatusMessage.new, :remote => true do |f|
|
||||||
= f.error_messages
|
= f.error_messages
|
||||||
|
|
||||||
|
= f.hidden_field :group_id, :value => group_id
|
||||||
|
|
||||||
%p
|
%p
|
||||||
%label{:for => "status_message_message"} Message
|
%label{:for => "status_message_message"} Message
|
||||||
= f.text_area :message, :rows => 2
|
= f.text_area :message, :rows => 2
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,28 @@
|
||||||
# This file should contain all the record creation needed to seed the database with its default values.
|
|
||||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
#
|
|
||||||
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
|
||||||
# Mayor.create(:name => 'Daley', :city => citie
|
|
||||||
|
|
||||||
require 'config/environment'
|
require 'config/environment'
|
||||||
|
|
||||||
|
host = "localhost:3000"
|
||||||
|
url = "http://#{host}/"
|
||||||
# Create seed user
|
# Create seed user
|
||||||
user = User.create( :email => "robert@joindiaspora.com",
|
user = User.create!( :email => "tom@tom.joindiaspora.com",
|
||||||
:password => "evankorth",
|
:password => "evankorth",
|
||||||
:person => Person.new(
|
:person => Person.new(
|
||||||
:email => "robert@joindiaspora.com",
|
:email => "tom@tom.joindiaspora.com",
|
||||||
:url => "http://localhost:3000/",
|
:url => url,
|
||||||
:profile => Profile.new(
|
:profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
|
||||||
:first_name => "bobert",
|
)
|
||||||
:last_name => "brin" )))
|
user.person.save!
|
||||||
|
|
||||||
puts user.save
|
user2 = User.create!( :email => "korth@tom.joindiaspora.com",
|
||||||
puts user.person.save!
|
:password => "evankorth",
|
||||||
puts user.save!
|
:person => Person.new( :email => "korth@tom.joindiaspora.com",
|
||||||
puts user.person.inspect
|
:url => url,
|
||||||
puts user.inspect
|
:profile => Profile.new( :first_name => "Evan",
|
||||||
|
:last_name => "Korth")))
|
||||||
|
|
||||||
|
user2.person.save!
|
||||||
|
|
||||||
|
# friending users
|
||||||
|
group = user.group(:name => "other dudes")
|
||||||
|
request = user.send_friend_request_to(user2.receive_url, group.id)
|
||||||
|
reversed_request = user2.accept_friend_request( request.id, user2.group(:name => "presidents").id )
|
||||||
|
user.receive reversed_request.to_diaspora_xml
|
||||||
|
|
|
||||||
BIN
public/images/add_friend_button.png
Normal file
BIN
public/images/add_friend_button.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 288 B |
|
|
@ -430,24 +430,21 @@ h1.big_text {
|
||||||
#group ul > li.selected, #group ul > li.selected a {
|
#group ul > li.selected, #group ul > li.selected a {
|
||||||
color: white;
|
color: white;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 18px;
|
font-size: 18px; }
|
||||||
text-shadow: 0 2px 0px black; }
|
|
||||||
#group a {
|
#group a {
|
||||||
color: #aaaaaa;
|
color: #aaaaaa;
|
||||||
font-weight: normal; }
|
font-weight: normal; }
|
||||||
#group #friend_pictures .add_new {
|
#group #friend_pictures .add_new_description {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
|
||||||
height: 40px;
|
height: 40px;
|
||||||
width: 40px;
|
display: inline-block;
|
||||||
background-color: black;
|
background-color: #222222;
|
||||||
text-align: center;
|
color: #999999;
|
||||||
font-size: 40px;
|
top: -16px;
|
||||||
line-height: 40px;
|
line-height: 40px;
|
||||||
top: -6px; }
|
padding: 0 1em;
|
||||||
#group #friend_pictures .add_new:hover {
|
margin-bottom: -20px;
|
||||||
background: #999999;
|
font-style: italic; }
|
||||||
color: black; }
|
|
||||||
#group #friend_pictures img {
|
#group #friend_pictures img {
|
||||||
height: 40px; }
|
height: 40px; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -546,21 +546,22 @@ h1.big_text
|
||||||
:weight normal
|
:weight normal
|
||||||
|
|
||||||
#friend_pictures
|
#friend_pictures
|
||||||
.add_new
|
|
||||||
:position relative
|
|
||||||
:display inline-block
|
|
||||||
:height 40px
|
|
||||||
:width 40px
|
|
||||||
:background
|
|
||||||
:color #000
|
|
||||||
:text-align center
|
|
||||||
:font-size 40px
|
|
||||||
:line-height 40px
|
|
||||||
:top -6px
|
|
||||||
|
|
||||||
&:hover
|
.add_new_description
|
||||||
:background #999
|
:position relative
|
||||||
:color #000
|
:height 40px
|
||||||
|
:display inline-block
|
||||||
|
:background
|
||||||
|
:color #222
|
||||||
|
:color #999
|
||||||
|
:top -16px
|
||||||
|
:line
|
||||||
|
:height 40px
|
||||||
|
:padding 0 1em
|
||||||
|
:margin
|
||||||
|
:bottom -20px
|
||||||
|
:font
|
||||||
|
:style italic
|
||||||
|
|
||||||
img
|
img
|
||||||
:height 40px
|
:height 40px
|
||||||
|
|
|
||||||
|
|
@ -88,8 +88,5 @@ describe Album do
|
||||||
it 'should have an id' do
|
it 'should have an id' do
|
||||||
@xml.include?(@album.id.to_s).should be true
|
@xml.include?(@album.id.to_s).should be true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -33,12 +33,15 @@ describe Group do
|
||||||
group.people.include?(@friend_2).should be true
|
group.people.include?(@friend_2).should be true
|
||||||
group.people.size.should == 2
|
group.people.size.should == 2
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'querying' do
|
describe 'querying' do
|
||||||
before do
|
before do
|
||||||
@group = @user.group(:name => 'losers', :people => [@friend])
|
@group = @user.group(:name => 'losers')
|
||||||
|
@user.activate_friend(@friend, @group)
|
||||||
|
@group2 = @user2.group(:name => 'failures')
|
||||||
|
friend_users(@user, @group, @user2, @group2)
|
||||||
|
@group.reload
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'belong to a user' do
|
it 'belong to a user' do
|
||||||
|
|
@ -49,7 +52,43 @@ describe Group do
|
||||||
|
|
||||||
it 'should have people' do
|
it 'should have people' do
|
||||||
@group.people.all.include?(@friend).should be true
|
@group.people.all.include?(@friend).should be true
|
||||||
@group.people.size.should == 1
|
@group.people.size.should == 2
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should be accessible through the user' do
|
||||||
|
groups = @user.groups_with_person(@friend)
|
||||||
|
groups.size.should == 1
|
||||||
|
groups.first.id.should == @group.id
|
||||||
|
groups.first.people.size.should == 2
|
||||||
|
groups.first.people.include?(@friend).should be true
|
||||||
|
groups.first.people.include?(@user2.person).should be true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'posting' do
|
||||||
|
|
||||||
|
it 'should add post to group via post method' do
|
||||||
|
@group = @user.group(:name => 'losers', :people => [@friend])
|
||||||
|
|
||||||
|
status_message = @user.post( :status_message, :message => "hey", :group_id => @group.id )
|
||||||
|
|
||||||
|
@group.reload
|
||||||
|
@group.posts.include?(status_message).should be true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should add post to group via receive method' do
|
||||||
|
group = @user.group(:name => 'losers')
|
||||||
|
group2 = @user2.group(:name => 'winners')
|
||||||
|
friend_users(@user, group, @user2, group2)
|
||||||
|
|
||||||
|
message = @user2.post(:status_message, :message => "Hey Dude")
|
||||||
|
|
||||||
|
@user.receive message.to_diaspora_xml
|
||||||
|
|
||||||
|
group.reload
|
||||||
|
group.posts.include?(message).should be true
|
||||||
|
@user.visible_posts(:by_members_of => group).include?(message).should be true
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,18 @@ describe User do
|
||||||
Post.all(:person_id => person.id).first.message.should == 'store this!'
|
Post.all(:person_id => person.id).first.message.should == 'store this!'
|
||||||
StatusMessage.all.size.should == 1
|
StatusMessage.all.size.should == 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should not create new groups on message receive' do
|
||||||
|
num_groups = @user.groups.size
|
||||||
|
|
||||||
|
(0..5).each{ |n|
|
||||||
|
status_message = @user2.post :status_message, :message => "store this #{n}!"
|
||||||
|
xml = status_message.to_diaspora_xml
|
||||||
|
@user.receive( xml )
|
||||||
|
}
|
||||||
|
|
||||||
|
@user.groups.size.should == num_groups
|
||||||
|
end
|
||||||
|
|
||||||
describe 'post refs' do
|
describe 'post refs' do
|
||||||
before do
|
before do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue