From dc0a08172d8daee7e487e51c62580258092deb39 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 16:23:42 -0700 Subject: [PATCH 01/15] syntax error in seed script --- db/seeds/backer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index d39ce490c..277615323 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -35,7 +35,7 @@ def create :person => Person.new( :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") - ) + )) user.person.save! user.aspect(:name => "Presidents") From c8e52526d9c8b4af5b29a36056e70c6ce990563d Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 16:31:27 -0700 Subject: [PATCH 02/15] another silly mistake, need to symbolize keys in deploy scripts --- db/seeds/backer.rb | 2 +- db/seeds/tom.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 277615323..9ebe1248f 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -42,7 +42,7 @@ def create end def set_app_config username - current_config = YAML.load(Rails.root.join('config', 'app_config.yml')) + 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" diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index b81d10827..c35058bf7 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -7,7 +7,7 @@ require 'config/environment' def set_app_config username - current_config = YAML.load(Rails.root.join('config', 'app_config.yml')) + 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" From 107c05ef6f89c99d41fa65a0703b7d63cdc96618 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 21 Sep 2010 16:35:18 -0700 Subject: [PATCH 03/15] DG MS; validate_aspect_permissions broken out of post method --- app/models/user.rb | 28 +++++++++++++++++++++++----- spec/models/user/posting_spec.rb | 25 +++++++++++++++++++++---- 2 files changed, 44 insertions(+), 9 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 4e2e642e3..91d84340d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -106,11 +106,7 @@ class User aspect_ids = options.delete(:to) end - aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId - - raise ArgumentError.new("You must post to someone.") if aspect_ids.nil? || aspect_ids.empty? - aspect_ids.each{ |aspect_id| - raise ArgumentError.new("Cannot post to an aspect you do not own.") unless aspect_id == "all" || self.aspects.find(aspect_id) } + aspect_ids = validate_aspect_permissions(aspect_ids) post = build_post(class_name, options) @@ -120,6 +116,28 @@ class User post end + def repost( post, options = {} ) + aspect_ids = validate_aspect_permissions(options[:to]) + push_to_aspects(post, aspect_ids) + post + end + + def validate_aspect_permissions(aspect_ids) + aspect_ids = [aspect_ids.to_s] if aspect_ids.is_a? BSON::ObjectId + + if aspect_ids.nil? || aspect_ids.empty? + raise ArgumentError.new("You must post to someone.") + end + + aspect_ids.each do |aspect_id| + unless aspect_id == "all" || self.aspects.find(aspect_id) + raise ArgumentError.new("Cannot post to an aspect you do not own.") + end + end + + aspect_ids + end + def build_post( class_name, options = {}) options[:person] = self.person model_class = class_name.to_s.camelize.constantize diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 1f24f3fed..da52ed849 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -26,15 +26,22 @@ describe User do end context 'posting' do - describe '#post' do + + describe '#validate_aspect_permissions' do it 'should not be able to post without a aspect' do - proc {user.post(:status_message, :message => "heyheyhey")}.should raise_error /You must post to someone/ + proc { + user.validate_aspect_permissions([]) + }.should raise_error /You must post to someone/ end it 'should not be able to post to someone elses aspect' do - proc {user.post(:status_message, :message => "heyheyhey", :to => aspect2.id)}.should raise_error /Cannot post to an aspect you do not own./ + proc { + user.validate_aspect_permissions(aspect2.id) + }.should raise_error /Cannot post to an aspect you do not own./ end - + end + + describe '#post' do it 'should put the post in the aspect post array' do post = user.post(:status_message, :message => "hey", :to => aspect.id) aspect.reload @@ -47,6 +54,16 @@ describe User do aspect.posts.should include album end end + + describe '#repost' do + let!(:status_message) { user.post(:status_message, :message => "hello", :to => aspect.id) } + + it 'should make the post visible in another aspect' do + user.repost( status_message, :to => aspect1.id ) + aspect1.reload + aspect1.posts.count.should be 1 + end + end end context 'dispatching' do From 020ff603bdbbea476483a70c0aad764de646893a Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 16:59:06 -0700 Subject: [PATCH 04/15] terse_url in user, db seeds are fixed, config/app_config.yml is now in gitignore, copy over config/app_config_example.yml. --- .gitignore | 1 + app/models/user.rb | 3 +++ config/app_config.yml | 34 ++++++++++++++-------------------- config/app_config_example.yml | 23 +++++++++++++++++++++++ db/seeds/backer.rb | 8 ++++---- db/seeds/dev.rb | 12 ++++++++++++ db/seeds/tom.rb | 8 ++++---- 7 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 config/app_config_example.yml diff --git a/.gitignore b/.gitignore index 89b33da60..0025a86f5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ gpg/diaspora-production/*.gpg gpg/*/random_seed public/uploads/* .rvmrc +config/app_config.yml diff --git a/app/models/user.rb b/app/models/user.rb index 4e9e968ca..a98217b4e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -221,6 +221,9 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) + terse_url = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '') + terse_url.chop! if terse_url[-1, 1] == '/' + opts[:person][:diaspora_handle] = "#{opts[:username]}@#{terse_url}" opts[:person][:url] = APP_CONFIG[:pod_url] opts[:person][:serialized_key] = generate_key diff --git a/config/app_config.yml b/config/app_config.yml index 5ee07c405..bd306725e 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -1,23 +1,17 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3. See -# the COPYRIGHT file. - - -default: - pod_url: "http://example.org/" - debug: false - socket_debug : false +--- +default: socket_host: 0.0.0.0 - socket_port: 8080 - socket_collection_name: 'websocket' - pubsub_server: 'https://pubsubhubbub.appspot.com/' - mongo_host: 'localhost' + socket_debug: false + pod_url: tom.joindiaspora.com mongo_post: 27017 - -development: - -test: - pod_url: "http://example.org/" + socket_collection_name: websocket + socket_port: 8080 + pubsub_server: https://pubsubhubbub.appspot.com/ + mongo_host: localhost + debug: false +production: +development: + pod_url: tom.joindiaspora.com +test: + pod_url: http://example.org/ socket_port: 8081 - -production: diff --git a/config/app_config_example.yml b/config/app_config_example.yml new file mode 100644 index 000000000..5ee07c405 --- /dev/null +++ b/config/app_config_example.yml @@ -0,0 +1,23 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3. See +# the COPYRIGHT file. + + +default: + pod_url: "http://example.org/" + debug: false + socket_debug : false + socket_host: 0.0.0.0 + socket_port: 8080 + socket_collection_name: 'websocket' + pubsub_server: 'https://pubsubhubbub.appspot.com/' + mongo_host: 'localhost' + mongo_post: 27017 + +development: + +test: + pod_url: "http://example.org/" + socket_port: 8081 + +production: diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 9ebe1248f..700839f62 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -42,10 +42,10 @@ def create 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" + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config[Rails.env.to_s] ||= {} + current_config[Rails.env.to_s]['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 diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index ef9dddecf..4ffa947e7 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -6,7 +6,19 @@ require 'config/environment' +def set_app_config username + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config[Rails.env.to_s] ||= {} + current_config[Rails.env.to_s]['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 + username = "tom" +set_app_config username + # Create seed user user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index c35058bf7..cf6a1ed0c 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -7,10 +7,10 @@ require 'config/environment' 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" + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config[Rails.env.to_s] ||= {} + current_config[Rails.env.to_s]['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 From e3d52bb467bd8f45d380a8715c80799065ccb036 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 17:39:44 -0700 Subject: [PATCH 05/15] putting the config file in a shared directory for in the deploy scripts --- config/deploy.rb | 7 ++++++- db/seeds/backer.rb | 2 +- db/seeds/tom.rb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index c84d25556..478736392 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -53,6 +53,11 @@ namespace :deploy do run "ln -s -f #{shared_path}/bundle #{current_path}/vendor/bundle" end + task :symlink_config do + run "touch #{shared_path}/app_config.yml" + run "ln -s -f #{shared_path}/app_config.yml #{current_path}/config/app_config.yml" + end + task :start do start_mongo start_thin @@ -150,4 +155,4 @@ namespace :db do end -after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle" +after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config" diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 700839f62..1730ee202 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -46,7 +46,7 @@ def set_app_config username current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['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 = File.new(Rails.root.join('..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index cf6a1ed0c..d8152a33b 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -11,7 +11,7 @@ def set_app_config username current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['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 = File.new(Rails.root.join('..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end From 74a92a26374cebd9adbf236c47f148d85dd307ce Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 17:40:43 -0700 Subject: [PATCH 06/15] tiny typo --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index 478736392..2f8065134 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -155,4 +155,4 @@ namespace :db do end -after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config" +after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config' From 4a3bfea1ba1f13d8f03fe1c478cd50d6ba433b66 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 21 Sep 2010 17:43:46 -0700 Subject: [PATCH 07/15] DG MS; cleaned spec --- lib/diaspora/user/querying.rb | 5 - spec/models/user/visible_posts_spec.rb | 131 ++++++++++++------------- 2 files changed, 64 insertions(+), 72 deletions(-) diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index 00ae27735..bd4174c76 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -35,11 +35,6 @@ module Diaspora aspects.detect{|x| x.id == id } end - def album_by_id( id ) - id = id.to_id - albums.detect{|x| x.id == id } - end - def aspects_with_post( id ) self.aspects.find_all_by_post_ids( id.to_id ) end diff --git a/spec/models/user/visible_posts_spec.rb b/spec/models/user/visible_posts_spec.rb index 5c44a2ce8..bcab473bc 100644 --- a/spec/models/user/visible_posts_spec.rb +++ b/spec/models/user/visible_posts_spec.rb @@ -7,83 +7,80 @@ require File.dirname(__FILE__) + '/../../spec_helper' describe User do - before do - @user = Factory.create(:user) - @aspect = @user.aspect(:name => 'heroes') - @aspect2 = @user.aspect(:name => 'losers') + let(:user) { Factory(:user) } - @user2 = Factory.create :user - @user2_aspect = @user2.aspect(:name => 'dudes') + let(:user2) { Factory(:user) } + let(:user3) { Factory(:user) } + let(:user4) { Factory(:user) } - friend_users(@user, @aspect, @user2, @user2_aspect) + let!(:aspect) { user.aspect(:name => 'heroes') } + let!(:aspect2) { user.aspect(:name => 'losers') } - @user3 = Factory.create :user - @user3_aspect = @user3.aspect(:name => 'dudes') - friend_users(@user, @aspect2, @user3, @user3_aspect) + let!(:user2_aspect) { user2.aspect(:name => 'dudes') } + let!(:user3_aspect) { user3.aspect(:name => 'dudes') } + let!(:user4_aspect) { user4.aspect(:name => 'dudes') } - @user4 = Factory.create :user - @user4_aspect = @user4.aspect(:name => 'dudes') - friend_users(@user, @aspect2, @user4, @user4_aspect) - end + let(:status_message1) { user2.post :status_message, :message => "hi", :to => user2_aspect.id } + let(:status_message2) { user3.post :status_message, :message => "heyyyy", :to => user3_aspect.id } + let(:status_message3) { user4.post :status_message, :message => "yooo", :to => user4_aspect.id } - it 'should generate a valid stream for a aspect of people' do - status_message1 = @user2.post :status_message, :message => "hi", :to => @user2_aspect.id - status_message2 = @user3.post :status_message, :message => "heyyyy", :to => @user3_aspect.id - status_message3 = @user4.post :status_message, :message => "yooo", :to => @user4_aspect.id + before do + friend_users(user, aspect, user2, user2_aspect) + friend_users(user, aspect2, user3, user3_aspect) + friend_users(user, aspect2, user4, user4_aspect) + end - @user.receive status_message1.to_diaspora_xml - @user.receive status_message2.to_diaspora_xml - @user.receive status_message3.to_diaspora_xml - @user.reload + it 'should generate a valid stream for a aspect of people' do + (1..3).each{ |n| + eval("user.receive status_message#{n}.to_diaspora_xml") + } - @user.visible_posts(:by_members_of => @aspect).include?(status_message1).should be true - @user.visible_posts(:by_members_of => @aspect).include?(status_message2).should be false - @user.visible_posts(:by_members_of => @aspect).include?(status_message3).should be false + user.visible_posts(:by_members_of => aspect).should include status_message1 + user.visible_posts(:by_members_of => aspect).should_not include status_message2 + user.visible_posts(:by_members_of => aspect).should_not include status_message3 - @user.visible_posts(:by_members_of => @aspect2).include?(status_message1).should be false - @user.visible_posts(:by_members_of => @aspect2).include?(status_message2).should be true - @user.visible_posts(:by_members_of => @aspect2).include?(status_message3).should be true - end + user.visible_posts(:by_members_of => aspect2).should_not include status_message1 + user.visible_posts(:by_members_of => aspect2).should include status_message2 + user.visible_posts(:by_members_of => aspect2).should include status_message3 + end - describe 'querying' do - - it 'should find a visible post by id' do - status_message1 = @user.post :status_message, :message => "hi", :to => @aspect.id - status_message2 = @user2.post :status_message, :message => "heyyyy", :to => @user2_aspect.id - status_message3 = @user3.post :status_message, :message => "yooo", :to => @user3_aspect.id - - @user.find_visible_post_by_id(status_message1.id).should == status_message1 - @user2.find_visible_post_by_id(status_message1.id).should == nil - end - - end - - describe 'albums' do - before do - @album = @user.post :album, :name => "Georges", :to => @aspect.id - @aspect.reload - @aspect2.reload - @user.reload - - @album2 = @user.post :album, :name => "Borges", :to => @aspect.id - @aspect.reload - @aspect2.reload - @user.reload - - @user.post :album, :name => "Luises", :to => @aspect2.id - @aspect.reload - @aspect2.reload - @user.reload - end - - it 'should find all albums if passed :all' do - @user.albums_by_aspect(:all).size.should == 3 - end - - it 'should return the right number of albums' do - @user.albums_by_aspect(@aspect).size.should == 2 - @user.albums_by_aspect(@aspect2).size.should == 1 + context 'querying' do + describe '#find_visible_post_by_id' do + it 'should query' do + user2.find_visible_post_by_id(status_message1.id).should == status_message1 + user.find_visible_post_by_id(status_message1.id).should == nil end end + end + + context 'albums' do + + + before do + @album = user.post :album, :name => "Georges", :to => aspect.id + aspect.reload + aspect2.reload + user.reload + + @album2 = user.post :album, :name => "Borges", :to => aspect.id + aspect.reload + aspect2.reload + user.reload + + user.post :album, :name => "Luises", :to => aspect2.id + aspect.reload + aspect2.reload + user.reload + end + + it 'should find all albums if passed :all' do + user.albums_by_aspect(:all).should have(3).albums + end + + it 'should return the right number of albums' do + user.albums_by_aspect(aspect).should have(2).albums + user.albums_by_aspect(aspect2).should have(1).album + end + end end From b01928af4bdfb43201ec8abda59b4f4eb92869b7 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 17:52:11 -0700 Subject: [PATCH 08/15] RS IZ if yaml fails to load (empty config) file load the example --- config/initializers/_load_app_config.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index ac14c97d8..034a62f24 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -4,6 +4,12 @@ raw_config = File.read("#{Rails.root}/config/app_config.yml") all_envs = YAML.load(raw_config) + +unless all_envs + raw_config = File.read("#{Rails.root}/config/app_config_example.yml") + all_envs = YAML.load(raw_config) +end + if all_envs[Rails.env] APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env]).symbolize_keys else From 96aaf3093cb99d383fbdbfb6ebfa778207f20ee7 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 18:04:36 -0700 Subject: [PATCH 09/15] Make load_app_config more robust, point to the right folder in db seed --- config/initializers/_load_app_config.rb | 20 ++++++++++++-------- db/seeds/backer.rb | 2 +- db/seeds/tom.rb | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index 034a62f24..33f7b183b 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -2,16 +2,20 @@ # licensed under the Affero General Public License version 3. See # the COPYRIGHT file. -raw_config = File.read("#{Rails.root}/config/app_config.yml") -all_envs = YAML.load(raw_config) - -unless all_envs - raw_config = File.read("#{Rails.root}/config/app_config_example.yml") - all_envs = YAML.load(raw_config) +def load_config_yaml filename + YAML.load(File.read(filename)) end -if all_envs[Rails.env] - APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env]).symbolize_keys +if File.exist? "#{Rails.root}/config/app_config.yml" + all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml" + all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml" unless all_envs +else + puts "WARNING: No config/app_config.yml found! Look at config/app_config_example.yml for help." + all_envs = load_config_yaml "#{Rails.root}/config/app_config_example.yml" +end + +if all_envs[Rails.env.to_s] + APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env.to_s]).symbolize_keys else APP_CONFIG = all_envs['default'].symbolize_keys end diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 1730ee202..8fa72f23d 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -46,7 +46,7 @@ def set_app_config username current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" - file = File.new(Rails.root.join('..','shared','app_config.yml'),'w') + file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index d8152a33b..50d41eb91 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -11,7 +11,7 @@ def set_app_config username current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" - file = File.new(Rails.root.join('..','shared','app_config.yml'),'w') + file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end From d60dc03d35e6b918b069d1447f5b1dcd8ec42740 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 18:10:26 -0700 Subject: [PATCH 10/15] removed app_config from repo --- config/app_config.yml | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 config/app_config.yml diff --git a/config/app_config.yml b/config/app_config.yml deleted file mode 100644 index bd306725e..000000000 --- a/config/app_config.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -default: - socket_host: 0.0.0.0 - socket_debug: false - pod_url: tom.joindiaspora.com - mongo_post: 27017 - socket_collection_name: websocket - socket_port: 8080 - pubsub_server: https://pubsubhubbub.appspot.com/ - mongo_host: localhost - debug: false -production: -development: - pod_url: tom.joindiaspora.com -test: - pod_url: http://example.org/ - socket_port: 8081 From df5b7d6d848bbcad04ecb9b58fb23a8c4d8be38e Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 21 Sep 2010 18:14:46 -0700 Subject: [PATCH 11/15] DG MS; new function in post --- app/models/user.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 928a02173..2277f1583 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -105,12 +105,15 @@ class User aspect_ids = validate_aspect_permissions(aspect_ids) - post = build_post(class_name, options) + intitial_post(class_name, aspect_ids, options) + end + + def intitial_post(class_name, aspect_ids, options = {}) + post = build_post(class_name, options) post.socket_to_uid(id, :aspect_ids => aspect_ids) if post.respond_to?(:socket_to_uid) push_to_aspects(post, aspect_ids) - - post + post end def repost( post, options = {} ) From 6d6ca3d8bca9707b302e051b3bd936e29b524cc2 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 20:01:56 -0700 Subject: [PATCH 12/15] added terse_pod_url to the APP_CONFIG hash --- app/models/user.rb | 7 ++----- config/initializers/_load_app_config.rb | 5 ++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 928a02173..c68cbb6dc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -239,11 +239,8 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) - terse_url = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '') - terse_url.chop! if terse_url[-1, 1] == '/' - - opts[:person][:diaspora_handle] = "#{opts[:username]}@#{terse_url}" - opts[:person][:url] = APP_CONFIG[:pod_url] + opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}" + pts[:person][:url] = APP_CONFIG[:pod_url] opts[:person][:serialized_key] = generate_key User.create(opts) end diff --git a/config/initializers/_load_app_config.rb b/config/initializers/_load_app_config.rb index 33f7b183b..521f9f0a0 100644 --- a/config/initializers/_load_app_config.rb +++ b/config/initializers/_load_app_config.rb @@ -20,4 +20,7 @@ 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 +APP_CONFIG[:terse_pod_url] = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '') +APP_CONFIG[:terse_pod_url].chop! if APP_CONFIG[:terse_pod_url][-1, 1] == '/' + +puts "WARNING: Please modify your app_config.yml to have a proper pod_url!" if APP_CONFIG[:terse_pod_url] == "example.org" && Rails.env != :test From 6bd22034b7978b090cdf9bbc9cf3d4824f2f189a Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 21:45:29 -0700 Subject: [PATCH 13/15] typo in user --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index 99230b8f6..06652a494 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -243,7 +243,7 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}" - pts[:person][:url] = APP_CONFIG[:pod_url] + opts[:person][:url] = APP_CONFIG[:pod_url] opts[:person][:serialized_key] = generate_key User.create(opts) end From c87ad060abc0ae4919fa41761f0ee7ed590a1413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Di=C3=B3genes?= Date: Wed, 22 Sep 2010 20:34:43 +0800 Subject: [PATCH 14/15] Add translation (from English locale) to Brazilian Portuguese --- config/locales/pt-BR.yml | 135 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 134 insertions(+), 1 deletion(-) diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 67c077090..10425864b 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -7,4 +7,137 @@ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. pt-BR: - hello: "Olá Mundo" + hello: "Olá mundo" + layouts: + application: + edit_profile: "editar perfil" + logout: "sair" + shared: + aspect_nav: + all_aspects: "Todos Aspectos" + manage: "Gerenciar" + manage_your_aspects: "Gerencie seus Aspectos" + sub_header: + all_aspects: "Todos Aspectos" + manage_aspects: "Gerenciar Aspectos" + publisher: + share: "Compartilhar" + aspect_friends: + add_friends: "adicionar amigos" + albums: + album: + you: "você" + new_album: + create: "criar" + add_a_new_album: "Adicionar novo álbum" + show: + edit_album: "Editar Álbum" + albums: "álbuns" + updated: "atualizado" + by: "por" + edit: + editing: "Editando" + updated: "atualizado" + are_you_sure: "Tem certeza?" + delete_album: "Excluir Álbum" + cancel: "Cancelar" + index: + home: "home" + new_album: "Novo Álbum" + create: + success: "Você criou com sucesso um álbum chamado %{name}." + update: + success: "O álbum %{name} foi editado com sucesso." + failure: "Erro ao editar o álbum %{name}." + destroy: + success: "O álbum %{name} foi excluído com sucesso." + aspects: + index: + photos: "photos" + show: + photos: "photos" + manage: + add_a_new_aspect: "Adicionar um novo aspecto" + add_a_new_friend: "Adicionar um novo amigo" + show: "Exibir" + update_aspects: "Atualizar Aspectos" + requests: "Solicitações" + ignore_remove: "Ignorar/Excluir" + new_aspect: + add_a_new_aspect: "Adicionar um novo aspecto" + create: "Criar" + create: + success:"Clique no mais(+) do lado esquerdo para dizer ao Diaspora quem pode ver seu novo aspecto." + users: + edit: + cancel: "Cancelar" + update_profile: "Atualizar Perfil" + home: "Home" + diaspora_username: "USUÁRIO DIASPORA" + info: "Informações" + picture: "Imagem" + editing_profile: "Editando perfil" + albums: "Álbuns" + you_dont_have_any_photos: "Você não possui nenhuma photo! Vá para" + page_to_upload_some: "para fazer o upload de alguma." + comments: + comment: + ago: "atrás" + new_comment: + comment: "Comentário" + photos: + show: + prev: "anterior" + full_size: "tamanho máximo" + next: "próxima" + edit_photo: "Editar Foto" + delete_photo: "Excluir Foto" + are_you_sure: "Tem certeza?" + comments: "comentários" + edit: + editing: "Editando" + are_you_sure: "Tem certeza?" + delete_photo: "Excluir Foto" + photo: + show_comments: "exibir comentários" + posted_a_new_photo_to: "enviada um nova foto para" + new: + new_photo: "Nova Foto" + back_to_list: "Voltar para a Lista" + post_it: "enviar!" + registrations: + new: + sign_up: "Cadastro" + status_messages: + new_status_message: + tell_me_something_good: "diga-me qualquer coisa legal" + oh_yeah: "É isso aí!" + status_message: + show_comments: "exibir comentários" + delete: "Excluir" + are_you_sure: "Tem certeza?" + show: + status_message: "Mensagem de Status" + comments: "comentários" + are_you_sure: "Tem certeza?" + destroy: "Excluir" + view_all: "Exibir Todas" + message: "Mensagem" + owner: "Pertence a" + people: + index: + add_friend: "adicionar amigo(a)" + real_name: "nome real" + diaspora_handle: "diaspora handle" + thats_you: "esse é você!" + friend_request_pending: "pedido de amizade pendente" + you_have_a_friend_request_from_this_person: "você possui um pedido de amizade dessa pessoa" + new: + new_person: "Nova Pessoa" + back_to_list: "Voltar para a Lista" + show: + last_seen: "visto pela última vez a: %{how_long_ago}" + friends_since: "amigos desde: %{how_long_ago}" + save: "salvar" + are_you_sure: "Tem certeza?" + remove_friend: "excluir amigo" From 7049cb3ca49f1f1a2208eaf616120c633272f0c1 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 22 Sep 2010 10:31:40 -0700 Subject: [PATCH 15/15] A less efficient, but simpler way of checking whether the photo is the profile photo --- app/views/users/edit.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 880d25ef4..cb578c590 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -17,11 +17,11 @@ %h3 Picture %div#image_picker - = p.hidden_field :image_url, :value => (@profile.image_url.sub(APP_CONFIG[:pod_url],'/') if @profile.image_url), :id => 'image_url_field' + = p.hidden_field :image_url, :value => (@profile.image_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(APP_CONFIG[:pod_url],'/')) + - if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium)) %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)), "#"