Merge branch 'master' of github.com:diaspora/diaspora into pivots

Conflicts:
	app/views/groups/index.html.haml
	config/deploy_config.yml
This commit is contained in:
Raphael 2010-08-18 20:50:28 -07:00
commit 701bec670f
37 changed files with 130 additions and 155 deletions

12
Gemfile
View file

@ -1,16 +1,16 @@
source 'http://rubygems.org'
#gem 'rails', '3.0.0.rc'
#gem 'bundler', '1.0.0.rc.1'
gem 'rails', '3.0.0.beta4'
gem 'bundler', '0.9.26'
gem 'rails', '3.0.0.rc'
gem 'bundler', '1.0.0.rc.5'
#gem 'rails', '3.0.0.beta4'
#gem 'bundler', '0.9.26'
#Security
gem 'gpgme'
gem 'devise', :git => 'http://github.com/BadMinus/devise.git'
#Mongo
gem 'mongo_mapper', :git => 'http://github.com/BadMinus/mongomapper.git'
#gem 'mongo_mapper', :git => 'http://github.com/jnunemaker/mongomapper.git'
gem 'jnunemaker-validatable', :git => 'http://github.com/BadMinus/validatable.git'
gem 'mongo_ext'
gem 'bson_ext'
@ -28,7 +28,7 @@ gem 'pubsubhubbub'
gem 'redfinger'
#EventMachine
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :ref => 'c6c494c514291f686cf6', :require => 'em-http'
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'
gem 'em-websocket'
gem 'thin'

View file

@ -4,4 +4,4 @@
require File.expand_path('../config/application', __FILE__)
require 'rake'
ENV['GNUPGHOME'] = File.expand_path("../../gpg/diaspora-#{Rails.env}/", __FILE__)
Rails::Application.load_tasks
Diaspora::Application.load_tasks

View file

@ -14,13 +14,4 @@ module AlbumsHelper
'Your Albums'
end
end
def album_person(album)
person = album.person
if album.person_id == current_user.id
link_to "you", user_path(current_user)
else
link_to person.real_name, person_path(person)
end
end
end

View file

@ -1,16 +1,8 @@
class Album
require 'lib/diaspora/webhooks'
include MongoMapper::Document
include ROXML
include Diaspora::Webhooks
include Encryptable
class Album < Post
xml_reader :name
xml_reader :person, :as => Person
xml_reader :_id
key :name, String
belongs_to :person, :class_name => 'Person'
many :photos, :class_name => 'Photo', :foreign_key => :album_id
timestamps!
@ -18,16 +10,10 @@ class Album
validates_presence_of :name, :person
before_destroy :destroy_photos
after_save :notify_people
before_destroy :propagate_retraction
def self.instantiate params
self.create params
end
def self.mine_or_friends(friend_param, current_user)
if friend_param
puts "i am working"
Album.find_all_by_person_id(current_user.friend_ids)
else
current_user.person.albums
@ -44,30 +30,9 @@ class Album
p_photo ? p_photo : self.photos.sort(:created_at.desc).last
end
#ENCRYPTION
xml_accessor :creator_signature
key :creator_signature, String
def signable_accessors
accessors = self.class.roxml_attrs.collect{|definition|
definition.accessor}
accessors.delete 'person'
accessors.delete 'creator_signature'
accessors
end
def signable_string
signable_accessors.collect{|accessor|
(self.send accessor.to_sym).to_s}.join ';'
end
protected
def destroy_photos
photos.each{|p| p.destroy}
self.photos.each{|p| p.destroy}
end
def propagate_retraction
self.person.owner.retract(self)
end
end

View file

@ -55,15 +55,6 @@ class Person
encryption_key.public_key.export
end
##profile
def update_profile(params)
if self.update_attributes(params)
self.profile.notify_people!
true
else
false
end
end
def owns?(post)
self.id == post.person.id

View file

@ -30,20 +30,30 @@ class Photo < Post
validates_true_for :album_id, :logic => lambda {self.validate_album_person}
before_destroy :ensure_user_picture
key :remote_photo_path
key :remote_photo_name
def validate_album_person
album.person_id == person_id
end
def remote_photo
@remote_photo ||= self.person.url.chop + image.url
image.url.nil? ? (remote_photo_path + '/' + remote_photo_name) : image.url
end
def remote_photo= remote_path
@remote_photo = remote_path
image.download! remote_path
image.store!
name_start = remote_path.rindex '/'
self.remote_photo_path = remote_path.slice(0, name_start )
self.remote_photo_name = remote_path.slice(name_start + 1, remote_path.length)
end
def url(name = nil)
if remote_photo_path
name = name.to_s + "_" if name
person.url.chop + remote_photo_path + "/" + name.to_s + remote_photo_name
else
image.url name
end
end
def ensure_user_picture

View file

@ -1,5 +1,4 @@
class StatusMessage < Post
#include StatusMessagesHelper
xml_name :status_message
xml_accessor :message

View file

@ -60,19 +60,21 @@ class User
post = model_class.instantiate(options)
post.creator_signature = post.sign_with_key(encryption_key)
post.save
post.notify_people
if group_id
group = self.groups.find_by_id(group_id)
group.posts << post
group.save
post.push_to( group.people.all )
else
post.push_to( self.friends.all )
end
post.socket_to_uid(id) if post.respond_to?(:socket_to_uid)
self.raw_visible_posts << post
self.save
if group_id
group = self.groups.find_by_id(group_id)
group.posts << post
group.save
end
post
end
@ -115,10 +117,20 @@ class User
post.unsocket_from_uid(self.id) if post.respond_to? :unsocket_from_uid
retraction = Retraction.for(post)
retraction.creator_signature = retraction.sign_with_key( encryption_key )
retraction.notify_people
retraction.push_to( self.friends.all )
retraction
end
########### Profile ######################
def update_profile(params)
if self.person.update_attributes(params)
self.profile.push_to( self.friends.all )
true
else
false
end
end
######### Friend Requesting ###########
def send_friend_request_to(friend_url, group_id)
unless self.friends.detect{ |x| x.receive_url == friend_url}
@ -254,6 +266,10 @@ class User
else
object.perform self.id
groups = self.groups_with_person(object.person)
groups.each{ |group| group.post_ids.delete(ensure_bson(object.post_id))
group.save
}
end
elsif object.is_a? Request
person = Diaspora::Parser.get_or_create_person_object_from_xml( xml )

View file

@ -1,10 +1,10 @@
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :grid_fs
storage :file
def store_dir
"files"
"uploads/images"
end
def extension_white_list

View file

@ -5,11 +5,11 @@
%div.time
by
= album_person(post)
= link_to ((current_user.person == post.person)? 'you' : post.person.real_name), person_path(post.person)
%br
= link_to(how_long_ago(post), object_path(post))
%div.image_cycle
- for photo in post.photos[0..3]
= link_to (image_tag photo.image.url(:thumb_large)), album_path(post)
= link_to (image_tag photo.url(:thumb_large)), album_path(post)

View file

@ -13,7 +13,7 @@
%ul
- for photo in @album.photos
%li.photo_edit_block= image_tag photo.image.url(:thumb_large)
%li.photo_edit_block= image_tag photo.url(:thumb_large)
#submit_block
= link_to "Cancel", root_path

View file

@ -22,7 +22,7 @@
#thumbnails
- for photo in @album_photos
.image_thumb
= link_to (image_tag photo.image.url(:thumb_medium)), object_path(photo)
= link_to (image_tag photo.url(:thumb_medium)), object_path(photo)
#content_bottom
.back

View file

@ -1,4 +1,10 @@
= render "shared/publisher", :group_id => @group.id
%h1
welcome,
= current_user.profile.first_name
- @group.nil? ? group_id = nil : group_id = @group.id
= render "shared/publisher", :group_id => group_id
%ul#stream
- for post in @posts

View file

@ -24,8 +24,6 @@
= csrf_meta_tag
= yield(:head)
/= javascript_include_tag 'satisfaction' , 'satisfaction-display'
= javascript_include_tag 'jquery.html5_upload'
%body

View file

@ -8,7 +8,7 @@
= link_to post.album.name, object_path(post.album)
%br
= link_to (image_tag post.image.url(:thumb_large)), object_path(post)
= link_to (image_tag post.url(:thumb_large)), object_path(post)
%div.time
= link_to(how_long_ago(post), photo_path(post))

View file

@ -8,7 +8,7 @@
.sub_header
= link_to_prev @photo, @album
|
= link_to "full size", @photo.image.url
= link_to "full size", @photo.url
|
= link_to_next @photo, @album

View file

@ -1,6 +1,6 @@
#debug_info
%h5 DEBUG INFO
#debug_more{ :style => "display:none;" }
#debug_more
%ul
%li
%b params

View file

@ -4,7 +4,8 @@
= form_for StatusMessage.new, :remote => true do |f|
= f.error_messages
= f.hidden_field :group_id, :value => group_id
-if group_id
= f.hidden_field :group_id, :value => group_id
%p
%label{:for => "status_message_message"} Message

View file

@ -15,14 +15,14 @@
%div#image_picker
= p.hidden_field :image_url, :value => @profile.image_url, :id => 'image_url_field'
- for photo in @photos
- if photo.image.url(:thumb_medium) == @profile.image_url
- if photo.url(:thumb_medium) == @profile.image_url
%div.small_photo{:id => photo.image.thumb_medium.url, :class=>'selected'}
= check_box_tag 'checked_photo', true, true
= link_to image_tag(photo.image.url(:thumb_medium)), "#"
= link_to image_tag(photo.url(:thumb_medium)), "#"
- else
%div.small_photo{:id => photo.image.thumb_medium.url}
= check_box_tag 'checked_photo'
= link_to image_tag(photo.image.url(:thumb_medium)), "#"
= link_to image_tag(photo.url(:thumb_medium)), "#"
=will_paginate @photos

View file

@ -15,8 +15,8 @@ module Diaspora
# -- all .rb files in that directory are automatically loaded.
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{config.root}/extras )
config.autoload_paths += %W(#{config.root}/lib)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]

View file

@ -24,6 +24,7 @@ Diaspora::Application.configure do
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
config.active_support.deprecation = :stderr
config.threadsafe!

View file

@ -1,7 +1,3 @@
CarrierWave.configure do |config|
config.grid_fs_database = MongoMapper::database.name
config.grid_fs_host = MongoMapper::connection.host
config.grid_fs_access_url = "/images"
config.storage = :grid_fs
#config.storage = :file
config.storage = :file
end

View file

@ -8,8 +8,6 @@ Diaspora::Application.routes.draw do |map|
resources :albums
resources :groups
match "/images/files/*path" => "gridfs#serve"
match 'warzombie', :to => "dev_utilities#warzombie"
match 'zombiefriends', :to => "dev_utilities#zombiefriends"
match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept"

View file

@ -6,16 +6,6 @@ module Diaspora
@@queue = MessageHandler.new
def notify_people
unless self.person.owner.nil?
push_to(people_with_permissions)
end
end
def notify_people!
push_to(people_with_permissions)
end
def push_to(recipients)
unless recipients.empty?
recipients.map!{|x| x = x.receive_url }

View file

@ -1074,4 +1074,4 @@
fancybox_init();
});
})(jQuery);
})(jQuery);

View file

@ -1,10 +0,0 @@
var feedback_widget_options = {};
feedback_widget_options.display = "overlay";
feedback_widget_options.company = "diaspora";
feedback_widget_options.placement = "right";
feedback_widget_options.color = "#222";
feedback_widget_options.style = "idea";
var feedback_widget = new GSFN.feedback_widget(feedback_widget_options);

View file

@ -1,3 +0,0 @@
var is_ssl = ("https:" == document.location.protocol);
var asset_host = is_ssl ? "https://s3.amazonaws.com/getsatisfaction.com/" : "http://s3.amazonaws.com/getsatisfaction.com/";
document.write(unescape("%3Cscript src='" + asset_host + "javascripts/feedback-v2.js' type='text/javascript'%3E%3C/script%3E"));

View file

@ -85,7 +85,7 @@ $(document).ready(function(){
$("#add_album_button").fancybox();
$("#add_group_button").fancybox();
$("#add_request_button").fancybox();
$("#add_request_button").fancybox({ 'titleShow': false });
$("#add_photo_button").fancybox();
//pane_toggler_button("photo");

View file

@ -49,7 +49,7 @@ Factory.define :post do |p|
end
Factory.define :photo do |p|
p.image File.open( File.dirname(__FILE__) + '/fixtures/bp.jpeg')
p.image File.open( File.dirname(__FILE__) + '/fixtures/button.png')
end

BIN
spec/fixtures/bp.jpeg vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 261 KiB

BIN
spec/fixtures/button.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

View file

@ -17,20 +17,7 @@ describe Diaspora do
end
it "should add the following methods to Post on inclusion" do
@post.respond_to?(:notify_people).should be true
@post.respond_to?(:to_diaspora_xml).should be true
@post.respond_to?(:people_with_permissions).should be true
end
it "should retrieve all valid person endpoints" do
@user.friends << Factory.create(:person, :url => "http://www.bob.com/")
@user.friends << Factory.create(:person, :url => "http://www.alice.com/")
@user.friends << Factory.create(:person, :url => "http://www.jane.com/")
@user.save
@post.person.owner.reload
@post.people_with_permissions.should == @user.friends
end
it "should send an owners post to their people" do

View file

@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
describe Album do
before do
@fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg'
@fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png'
@user = Factory.create(:user)
@user.person.save
@album = Album.new(:name => "test collection", :person => @user.person)

View file

@ -52,7 +52,7 @@ describe Comment do
end
it 'should send a user comment on his own post to lots of people' do
allowed_urls = @user_status.people_with_permissions.map{|x| x = x.receive_url}
allowed_urls = @user.friends.map!{ |x| x = x.receive_url }
message_queue.should_receive(:add_post_request).with(allowed_urls, anything)
@user.comment "yo", :on => @user_status
end

View file

@ -68,16 +68,16 @@ describe Group do
describe 'posting' do
it 'should add post to group via post method' do
@group = @user.group(:name => 'losers', :people => [@friend])
group = @user.group(:name => 'losers', :people => [@friend])
status_message = @user.post( :status_message, :message => "hey", :group_id => @group.id )
status_message = @user.post( :status_message, :message => "hey", :group_id => group.id )
@group.reload
@group.posts.include?(status_message).should be true
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')
group = @user.group(:name => 'losers')
group2 = @user2.group(:name => 'winners')
friend_users(@user, group, @user2, group2)
@ -90,5 +90,24 @@ describe Group do
@user.visible_posts(:by_members_of => group).include?(message).should be true
end
it 'should retract the post from the groups as well' 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.post_ids.include?(message.id).should be true
retraction = @user2.retract(message)
@user.receive retraction.to_diaspora_xml
group.reload
group.post_ids.include?(message.id).should be false
end
end
end

View file

@ -5,8 +5,8 @@ describe Photo do
@user = Factory.create(:user)
@user.person.save
@fixture_filename = 'bp.jpeg'
@fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg'
@fixture_filename = 'button.png'
@fixture_name = File.dirname(__FILE__) + '/../fixtures/button.png'
@fail_fixture_name = File.dirname(__FILE__) + '/../fixtures/msg.xml'
@album = Album.create(:name => "foo", :person => @user.person)
@photo = Photo.new(:person => @user.person, :album => @album)
@ -19,7 +19,7 @@ describe Photo do
photo.image.read.nil?.should be false
end
it 'should save a photo to GridFS' do
it 'should save a photo' do
@photo.image.store! File.open(@fixture_name)
@photo.save.should == true
binary = @photo.image.read
@ -58,7 +58,6 @@ describe Photo do
end
it 'should not use the imported filename as the url' do
pending "Until this passes, duplicate photos will cause errors"
@photo.image.store! File.open(@fixture_name)
@photo.image.url.include?(@fixture_filename).should be false
@photo.image.url(:thumb_medium).include?("/" + @fixture_filename).should be false
@ -85,7 +84,7 @@ describe Photo do
stub_signature_verification
end
it 'should save a signed photo to GridFS' do
it 'should save a signed photo' do
photo = @user.post(:photo, :album => @album, :user_file => [File.open(@fixture_name)])
photo.save.should == true
photo.signature_valid?.should be true
@ -109,5 +108,26 @@ describe Photo do
xml = @photo.to_xml.to_s
xml.include?(@photo.album_id.to_s).should be true
end
it 'should set the remote_photo on marshalling' do
@photo.image.store! File.open(@fixture_name)
@photo.save
@photo.reload
url = @photo.url
thumb_url = @photo.url :thumb_medium
xml = @photo.to_diaspora_xml
id = @photo.id
@photo.destroy
@user.receive xml
new_photo = Photo.first(:id => id)
new_photo.url.nil?.should be false
new_photo.url.include?(url).should be true
new_photo.url(:thumb_medium).include?(thumb_url).should be true
end
end
end

View file

@ -14,7 +14,7 @@ describe User do
message_queue.should_receive(:process)
@user.person.update_profile(updated_profile).should == true
@user.update_profile(updated_profile).should == true
@user.profile.image_url.should == "http://clown.com"
end
end