Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
03638ee68e
14 changed files with 89 additions and 72 deletions
|
|
@ -10,10 +10,7 @@ class PhotosController < ApplicationController
|
|||
respond_to :json, :only => :show
|
||||
|
||||
def create
|
||||
|
||||
album = Album.find_by_id params[:album_id]
|
||||
puts params
|
||||
|
||||
begin
|
||||
|
||||
######################## dealing with local files #############
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ module RequestsHelper
|
|||
def relationship_flow(identifier)
|
||||
action = :none
|
||||
person = nil
|
||||
puts identifier
|
||||
person = Person.by_webfinger identifier
|
||||
if person
|
||||
action = (person == current_user.person ? :none : :friend)
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ class User
|
|||
key :visible_post_ids, Array
|
||||
key :visible_person_ids, Array
|
||||
|
||||
key :url, String
|
||||
|
||||
one :person, :class_name => 'Person', :foreign_key => :owner_id
|
||||
|
||||
many :friends, :in => :friend_ids, :class_name => 'Person'
|
||||
|
|
@ -97,7 +95,6 @@ class User
|
|||
|
||||
######## Posting ########
|
||||
def post(class_name, options = {})
|
||||
|
||||
if class_name == :photo
|
||||
raise ArgumentError.new("No album_id given") unless options[:album_id]
|
||||
aspect_ids = aspects_with_post( options[:album_id] )
|
||||
|
|
@ -242,11 +239,8 @@ class User
|
|||
|
||||
###Helpers############
|
||||
def self.instantiate!( opts = {} )
|
||||
hostname = opts[:url].gsub(/(https?:|www\.)\/\//, '')
|
||||
hostname.chop! if hostname[-1, 1] == '/'
|
||||
|
||||
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{hostname}"
|
||||
puts opts[:person][:diaspora_handle]
|
||||
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{terse_url}"
|
||||
opts[:person][:url] = APP_CONFIG[:pod_url]
|
||||
opts[:person][:serialized_key] = generate_key
|
||||
User.create(opts)
|
||||
end
|
||||
|
|
@ -257,7 +251,7 @@ class User
|
|||
end
|
||||
|
||||
def terse_url
|
||||
terse = self.url.gsub(/(https?:|www\.)\/\//, '')
|
||||
terse = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '')
|
||||
terse = terse.chop! if terse[-1, 1] == '/'
|
||||
terse
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
= f.label :username
|
||||
= f.text_field :username
|
||||
%p.user_network
|
||||
="@#{request.host}"
|
||||
="@#{APP_CONFIG[:pod_url]}"
|
||||
|
||||
%p
|
||||
= f.label :password
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
|
||||
= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f|
|
||||
= f.hidden_field :url, :value => request.host
|
||||
%p
|
||||
= f.label :username
|
||||
= f.text_field :username
|
||||
|
|
@ -17,8 +16,6 @@
|
|||
= f.password_field :password_confirmation
|
||||
|
||||
= f.fields_for :person do |p|
|
||||
= p.hidden_field :url, :value => request.host
|
||||
|
||||
= p.fields_for :profile do |pr|
|
||||
%p
|
||||
= pr.label :first_name
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@
|
|||
|
||||
%h3 Picture
|
||||
%div#image_picker
|
||||
= p.hidden_field :image_url, :value => (@profile.image_url.sub(@user.url,'/') if @profile.image_url), :id => 'image_url_field'
|
||||
= p.hidden_field :image_url, :value => (@profile.image_url.sub(APP_CONFIG[:pod_url],'/') if @profile.image_url), :id => 'image_url_field'
|
||||
|
||||
- unless @photos.nil? || @photos.empty?
|
||||
- for photo in @photos
|
||||
- if @profile.image_url && (photo.url(:thumb_medium) == @profile.image_url.sub(@user.url,'/'))
|
||||
- if @profile.image_url && (photo.url(:thumb_medium) == @profile.image_url.sub(APP_CONFIG[:pod_url],'/'))
|
||||
%div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'}
|
||||
= check_box_tag 'checked_photo', true, true
|
||||
= link_to image_tag(photo.url(:thumb_medium)), "#"
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
|
||||
|
||||
development:
|
||||
default:
|
||||
pod_url: "http://example.org/"
|
||||
debug: false
|
||||
socket_debug : false
|
||||
socket_host: 0.0.0.0
|
||||
|
|
@ -14,20 +14,10 @@ development:
|
|||
mongo_host: 'localhost'
|
||||
mongo_post: 27017
|
||||
|
||||
development:
|
||||
|
||||
test:
|
||||
debug: false
|
||||
socket_debug : false
|
||||
socket_host: 0.0.0.0
|
||||
pod_url: "http://example.org/"
|
||||
socket_port: 8081
|
||||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||
mongo_host: 'localhost'
|
||||
mongo_post: 27017
|
||||
|
||||
production:
|
||||
debug: false
|
||||
socket_debug : false
|
||||
socket_host: 0.0.0.0
|
||||
socket_port: 8080
|
||||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||
mongo_host: 'localhost'
|
||||
mongo_post: 27017
|
||||
|
|
|
|||
|
|
@ -2,6 +2,12 @@
|
|||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
|
||||
raw_config = File.read("#{Rails.root}/config/app_config.yml")
|
||||
APP_CONFIG = YAML.load(raw_config)[Rails.env].symbolize_keys
|
||||
all_envs = YAML.load(raw_config)
|
||||
if all_envs[Rails.env]
|
||||
APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env]).symbolize_keys
|
||||
else
|
||||
APP_CONFIG = all_envs['default'].symbolize_keys
|
||||
end
|
||||
|
||||
puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:pod_url] == "http://example.org/" && Rails.env != :test
|
||||
|
|
|
|||
|
|
@ -15,25 +15,38 @@
|
|||
require 'config/environment'
|
||||
|
||||
def create
|
||||
|
||||
|
||||
config = YAML.load_file(File.dirname(__FILE__) + '/../../config/deploy_config.yml')
|
||||
backer_info = config['servers']['backer']
|
||||
|
||||
backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i
|
||||
# Create seed user
|
||||
|
||||
#set pod url
|
||||
username = backer_info[backer_number]['username'].gsub(/ /,'').downcase
|
||||
set_app_config username
|
||||
require 'config/initializers/_load_app_config.rb'
|
||||
|
||||
# Create seed user
|
||||
user = User.instantiate!(:email => "#{username}@#{username}.joindiaspora.com",
|
||||
:username => username,
|
||||
:password => "#{username+backer_info[backer_number]['pin'].to_s}",
|
||||
:password_confirmation => "#{username+backer_info[backer_number]['pin'].to_s}",
|
||||
:url=> "http://#{username}.joindiaspora.com/",
|
||||
:person => Person.new(
|
||||
:diaspora_handle => "#{username}@#{username}.joindiaspora.com",
|
||||
:profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'],
|
||||
:image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg"),
|
||||
:url=> "http://#{username}.joindiaspora.com/")
|
||||
)
|
||||
:image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg")
|
||||
))
|
||||
user.person.save!
|
||||
|
||||
user.aspect(:name => "Presidents")
|
||||
end
|
||||
|
||||
def set_app_config username
|
||||
current_config = YAML.load(Rails.root.join('config', 'app_config.yml')).symbolize_keys
|
||||
current_config[Rails.env] ||= {}
|
||||
current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com"
|
||||
current_config[:default][:pod_url] = "#{username}.joindiaspora.com"
|
||||
file = File.new(Rails.root.join('config','app_config.yml'),'w')
|
||||
file.write(current_config.to_yaml)
|
||||
file.close
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,31 +6,23 @@
|
|||
|
||||
require 'config/environment'
|
||||
|
||||
host = "localhost:3000"
|
||||
url = "http://#{host}/"
|
||||
username = "tom"
|
||||
# Create seed user
|
||||
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
||||
:username => "tom",
|
||||
:password => "evankorth",
|
||||
:password_confirmation => "evankorth",
|
||||
:url=> "http://#{username}.joindiaspora.com/"
|
||||
:person => Person.new(
|
||||
:diaspora_handle => "tom@tom.joindiaspora.com",
|
||||
:url => url,
|
||||
:profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" ))
|
||||
)
|
||||
user.person.save!
|
||||
|
||||
user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
|
||||
:username => "korth",
|
||||
:url=> "http://#{username}.joindiaspora.com/"
|
||||
:password => "evankorth",
|
||||
:password_confirmation => "evankorth",
|
||||
:person => Person.new( :diaspora_handle => "korth@tom.joindiaspora.com",
|
||||
:url => url,
|
||||
:profile => Profile.new( :first_name => "Evan",
|
||||
:last_name => "Korth")))
|
||||
:person => Person.new(
|
||||
:profile => Profile.new( :first_name => "Evan", :last_name => "Korth")))
|
||||
|
||||
user2.person.save!
|
||||
|
||||
|
|
|
|||
|
|
@ -6,17 +6,26 @@
|
|||
|
||||
require 'config/environment'
|
||||
|
||||
remote_url = "http://tom.joindiaspora.com/"
|
||||
#remote_url = "http://localhost:3000/"
|
||||
def set_app_config username
|
||||
current_config = YAML.load(Rails.root.join('config', 'app_config.yml')).symbolize_keys
|
||||
current_config[Rails.env] ||= {}
|
||||
current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com"
|
||||
current_config[:default][:pod_url] = "#{username}.joindiaspora.com"
|
||||
file = File.new(Rails.root.join('config','app_config.yml'),'w')
|
||||
file.write(current_config.to_yaml)
|
||||
file.close
|
||||
end
|
||||
|
||||
set_app_config "tom"
|
||||
require 'config/initializers/_load_app_config.rb'
|
||||
|
||||
|
||||
# Create seed user
|
||||
user = User.instantiate!( :email => "tom@tom.joindiaspora.com",
|
||||
:username => "tom",
|
||||
:password => "evankorth",
|
||||
:password_confirmation => "evankorth",
|
||||
:url => remote_url,
|
||||
:person => {
|
||||
:diaspora_handle => "tom@tom.joindiaspora.com",
|
||||
:url => remote_url,
|
||||
:profile => { :first_name => "Alexander", :last_name => "Hamiltom",
|
||||
:image_url => "http://tom.joindiaspora.com/images/user/tom.jpg"}}
|
||||
)
|
||||
|
|
@ -26,11 +35,7 @@ user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com",
|
|||
:password => "evankorth",
|
||||
:password_confirmation => "evankorth",
|
||||
:username => "korth",
|
||||
:url => remote_url,
|
||||
:person => { :diaspora_handle => "korth@tom.joindiaspora.com",
|
||||
:url => remote_url,
|
||||
:profile => { :first_name => "Evan",
|
||||
:last_name => "Korth",
|
||||
:person => {:profile => { :first_name => "Evan", :last_name => "Korth",
|
||||
:image_url => "http://tom.joindiaspora.com/images/user/korth.jpg"}})
|
||||
|
||||
user2.person.save!
|
||||
|
|
@ -41,3 +46,5 @@ request = user.send_friend_request_to(user2, aspect)
|
|||
reversed_request = user2.accept_friend_request( request.id, user2.aspect(:name => "presidents").id )
|
||||
user.receive reversed_request.to_diaspora_xml
|
||||
user.aspect(:name => "Presidents")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,10 @@ Factory.define :user do |u|
|
|||
u.sequence(:email) {|n| "bob#{n}@pivotallabs.com"}
|
||||
u.password "bluepin7"
|
||||
u.password_confirmation "bluepin7"
|
||||
u.person { |a| Factory.create(:person_with_user, :owner_id => a._id)}
|
||||
u.person { |a| Factory.create(:person_with_user,
|
||||
:owner_id => a._id,
|
||||
:diaspora_handle => "#{a.username}@#{APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '').chop!}")
|
||||
}
|
||||
end
|
||||
|
||||
Factory.define :status_message do |m|
|
||||
|
|
|
|||
|
|
@ -15,6 +15,20 @@ describe Person do
|
|||
@aspect2 = @user2.aspect(:name => "Abscence of Babes")
|
||||
end
|
||||
|
||||
describe '#diaspora_handle' do
|
||||
context 'local people' do
|
||||
it 'uses the pod config url to set the diaspora_handle' do
|
||||
@user.person.diaspora_handle.should == @user.username + "@example.org"
|
||||
end
|
||||
end
|
||||
|
||||
context 'remote people' do
|
||||
it 'stores the diaspora_handle in the database' do
|
||||
@person.diaspora_handle.include?(@user.terse_url).should be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'should not allow two people with the same diaspora_handle' do
|
||||
person_two = Factory.build(:person, :url => @person.diaspora_handle)
|
||||
person_two.valid?.should == false
|
||||
|
|
@ -148,13 +162,11 @@ describe Person do
|
|||
end
|
||||
|
||||
it 'should search by diaspora_handle exactly' do
|
||||
|
||||
stub_success("tom@tom.joindiaspora.com")
|
||||
Person.by_webfinger(@friend_one.diaspora_handle).should == @friend_one
|
||||
end
|
||||
|
||||
it 'should create a stub for a remote user' do
|
||||
|
||||
stub_success("tom@tom.joindiaspora.com")
|
||||
tom = Person.by_webfinger('tom@tom.joindiaspora.com')
|
||||
tom.real_name.include?("Hamiltom").should be true
|
||||
|
|
|
|||
|
|
@ -12,6 +12,13 @@ describe User do
|
|||
@aspect = @user.aspect(:name => 'heroes')
|
||||
end
|
||||
|
||||
describe '#diaspora_handle' do
|
||||
it 'uses the pod config url to set the diaspora_handle' do
|
||||
@user.diaspora_handle.should == @user.username + "@example.org"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
describe 'profiles' do
|
||||
it 'should be able to update their profile and send it to their friends' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue