From 56c497eb2a2971427cbe3be166d83dda010632c4 Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 11:13:45 -0700 Subject: [PATCH 01/31] commit guidelines in readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 772bf7504..bad60e429 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,14 @@ Once mongo is running and bundler has finished, run `bundle exec thin start` fro Diaspora's test suite uses [rspec](http://rspec.info/), a behavior driven testing framework. In order to run the tests, run `bundle exec rspec spec`. +## Commit Guidlines +You are welcome to contribute, add and extend Diaspora however you see fit. We will do our best to incorporate everything that meets our guidelines. + +All commits must be tested, and after each commit, all tests should be green before a pull request is sent. Please write your tests in Rspec or Test-Unit, (depending on the functionality) so we can minimize diaspora’s requirements. + +GEMS: if you are adding to diaspora, and want to maximize the speed of getting pulled back in, please use the libraries we are already using in the application ie: Nokogiri for XML parsing, MongoMapper for database querying, EM:HttpRequest for http requests etc etc. We currently have a few duplicate libraries which we used for the sake of “making it green”, but this duplication is high on our “wanted refactors” list. + + ## Resources We are maintaining a [public tracker project](http://www.pivotaltracker.com/projects/61641) and a [wishlist](#). From ea3e37247419400a933b87209bfef64698516b84 Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 11:24:23 -0700 Subject: [PATCH 02/31] fixed 500 error with @photos --- app/views/users/edit.html.haml | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index bd786505e..3086eb999 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -17,18 +17,28 @@ %h3 Picture %div#image_picker - = p.hidden_field :image_url, :value => @profile.image_url.sub(@user.url,'/'), :id => 'image_url_field' - - for photo in @photos - - if photo.url(:thumb_medium) == @profile.image_url.sub(@user.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)), "#" - - else - %div.small_photo{:id => photo.url(:thumb_medium)} - = check_box_tag 'checked_photo' - = link_to image_tag(photo.url(:thumb_medium)), "#" + = p.hidden_field :image_url, :value => (@profile.image_url.sub(@user.url,'/') if @profile.image_url), :id => 'image_url_field' + + - unless @photos.nil? || @photos.empty? + - for photo in @photos + - if photo.url(:thumb_medium) == @profile.image_url.sub(@user.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)), "#" + - else + %div.small_photo{:id => photo.url(:thumb_medium)} + = check_box_tag 'checked_photo' + = link_to image_tag(photo.url(:thumb_medium)), "#" + + - else + You don't have any photos! Go to the + = link_to "albums", albums_path + page to upload some. + =will_paginate @photos + %br + %h3 Info %p From ac7fb673c5d1035b03e4a5fb1a2767193fec57b3 Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 11:25:39 -0700 Subject: [PATCH 03/31] show add new friend links on aspect manage page --- public/stylesheets/application.css | 2 +- public/stylesheets/sass/application.sass | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index b93d5ec04..9b7605ccf 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -520,7 +520,7 @@ h1.big_text { position: absolute; top: 10px; right: 0; - display: none; } + display: inline; } .aspect .aspect_name:hover .tools, .requests .aspect_name:hover .tools, .remove .aspect_name:hover .tools { diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index f11249346..ab97b351b 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -682,7 +682,7 @@ h1.big_text :position absolute :top 10px :right 0 - :display none + :display inline &:hover .tools From 1f27c863e4b2124962f95e1bde86805977109a47 Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 11:29:22 -0700 Subject: [PATCH 04/31] correct roadmap link & added bug tracker link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bad60e429..0cbe5a459 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ GEMS: if you are adding to diaspora, and want to maximize the speed of getting ## Resources -We are maintaining a [public tracker project](http://www.pivotaltracker.com/projects/61641) and a [wishlist](#). +We are maintaining a [public tracker project](http://www.pivotaltracker.com/projects/61641) and a [roadmap](https://github.com/diaspora/diaspora/wiki/Roadmap). Also, you can file [bug reports](https://github.com/diaspora/diaspora/issues) right here on github. Ongoing discussion: From fe35d60b130c8b611bc8731e2f27f67d1207916a Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 11:44:56 -0700 Subject: [PATCH 05/31] hack on aspect nav for ff & chrome compatability --- app/views/shared/_aspect_nav.haml | 2 +- public/stylesheets/application.css | 9 ++++----- public/stylesheets/sass/application.sass | 10 +++++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/views/shared/_aspect_nav.haml b/app/views/shared/_aspect_nav.haml index 97f19aae0..67f0bc6a0 100644 --- a/app/views/shared/_aspect_nav.haml +++ b/app/views/shared/_aspect_nav.haml @@ -9,7 +9,7 @@ %li{:id => aspect.id, :class => ("selected" if current_aspect?(aspect))} = link_for_aspect aspect - %ul{ :style => "position:absolute;right:0;bottom:0;"} + %ul{ :style => "position:absolute;right:0;bottom:0.01em;"} %li{:class => ("selected" if @aspect == :all)} = link_to "All Aspects", root_url diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 9b7605ccf..fdef9e4b9 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -442,8 +442,6 @@ h1.big_text { display: none; } #aspect_nav { - z-index: 4; - position: relative; color: black; margin-top: 8px; margin-bottom: 1px; } @@ -460,10 +458,11 @@ h1.big_text { display: inline; margin-right: 0.5em; } #aspect_nav ul > li a { + line-height: 22px; background-color: #444444; border: 1px solid #555555; padding: 3px 8px; - padding-bottom: 2px; + padding-bottom: 3px; color: #999999; } #aspect_nav ul > li a:hover { background-color: #4e4e4e; @@ -471,12 +470,12 @@ h1.big_text { #aspect_nav ul > li.selected a { text-shadow: 0 2px 0 white; padding-top: 4px; - padding-bottom: 4px; + padding-bottom: 5px; line-height: 18px; font-weight: bold; background-color: #eeeeee; border: 1px solid white; - border-bottom: none; + border-bottom: 1px solid #eeeeee; color: black; } #aspect_nav ul > li.selected a:hover { background-color: #efefef; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index ab97b351b..02943e0cf 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -578,8 +578,6 @@ h1.big_text :display none #aspect_nav - :z-index 4 - :position relative :color #000 :margin :top 8px @@ -606,12 +604,14 @@ h1.big_text :right 0.5em a + :line + :height 22px :background :color #444 :border 1px solid #555 :padding 3px 8px - :bottom 2px + :bottom 3px :color #999 &:hover @@ -623,7 +623,7 @@ h1.big_text :text-shadow 0 2px 0 #fff :padding :top 4px - :bottom 4px + :bottom 5px :line :height 18px :font @@ -631,7 +631,7 @@ h1.big_text :background :color #eee :border 1px solid #fff - :bottom none + :bottom 1px solid #eee :color #000 &:hover :background From deac53f178f61ed98d7e8f9f32f7490d63d7bdbf Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 11:59:39 -0700 Subject: [PATCH 06/31] see yourself in aspect sidebar, because you're going to post to yourself anyway --- app/views/shared/_aspect_friends.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/shared/_aspect_friends.haml b/app/views/shared/_aspect_friends.haml index 3df030a64..c649415d6 100644 --- a/app/views/shared/_aspect_friends.haml +++ b/app/views/shared/_aspect_friends.haml @@ -4,6 +4,7 @@ #friend_pictures + = owner_image_link - for friend in @friends = person_image_link(friend) From 57bd052c5baf3553f92f1085b328b4075ade5a52 Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 12:22:03 -0700 Subject: [PATCH 07/31] user edit bug --- app/views/users/edit.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 3086eb999..3756060e8 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -21,7 +21,7 @@ - unless @photos.nil? || @photos.empty? - for photo in @photos - - if photo.url(:thumb_medium) == @profile.image_url.sub(@user.url,'/') + - if @profile.image_url && (photo.url(:thumb_medium) == @profile.image_url.sub(@user.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)), "#" From a925c14310391020feea3e1497a4cb55e0d3a18f Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 12:35:23 -0700 Subject: [PATCH 08/31] fixing webfinger/salmon --- lib/salmon/salmon.rb | 2 +- spec/lib/salmon_salmon_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/salmon/salmon.rb b/lib/salmon/salmon.rb index d1a4d7a1f..8b01fd787 100644 --- a/lib/salmon/salmon.rb +++ b/lib/salmon/salmon.rb @@ -82,7 +82,7 @@ module Salmon #{@author.real_name} - acct:#{@author.email} + acct:#{@author.owner.diaspora_handle} #{@magic_sig.to_xml} diff --git a/spec/lib/salmon_salmon_spec.rb b/spec/lib/salmon_salmon_spec.rb index 4beb87866..63f7d5cb4 100644 --- a/spec/lib/salmon_salmon_spec.rb +++ b/spec/lib/salmon_salmon_spec.rb @@ -36,7 +36,7 @@ describe Salmon do end it 'should parse out the author email' do - @parsed_salmon.author_email.should == @user.person.email + @parsed_salmon.author_email.should == @user.diaspora_handle end it 'should reference a local author' do From 84c60e5f2e484a30133999a9e5d1644c3349ef5d Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 13:28:06 -0700 Subject: [PATCH 09/31] DG MS fixing webfinger, i hope to goodness --- README.md | 2 +- app/models/person.rb | 15 ++++++++------- app/models/user.rb | 2 +- app/views/people/index.html.haml | 6 +++--- app/views/people/new.html.haml | 4 ++-- app/views/publics/webfinger.erb | 2 +- lib/salmon/salmon.rb | 2 +- spec/controllers/publics_controller_spec.rb | 2 +- spec/factories.rb | 2 +- spec/fixtures/msg.xml.clear.asc | 2 +- spec/lib/diaspora_parser_spec.rb | 6 +++--- spec/lib/salmon_salmon_spec.rb | 4 ++-- spec/models/person_spec.rb | 8 ++++---- spec/models/post_spec.rb | 2 +- spec/models/request_spec.rb | 4 ++-- spec/user_encryption_spec.rb | 4 ++-- 16 files changed, 34 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 0cbe5a459..85e52b7c8 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ The privacy aware, personally controlled, do-it-all, open source social network. **DISCLAIMER: THIS IS PRE-ALPHA SOFTWARE AND SHOULD BE TREATED ACCORDINGLY.** -These instructions are for machines running [Ubuntu](http://www.ubuntu.com/) or Mac OS X. +These instructions are for machines running [Ubuntu](http://www.ubuntu.com/) or Mac OS X. We are developing Diaspora for the latest and greatest browsers, so please update your Firefox, Chrome or Safari to the latest and greatest. ## Preparing your system In order to run Diaspora, you will need to download the following dependencies (specific instructions follow): diff --git a/app/models/person.rb b/app/models/person.rb index 836a810ec..b1aa8641d 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -11,13 +11,13 @@ class Person include Encryptor::Public xml_accessor :_id - xml_accessor :email + xml_accessor :diaspora_handle xml_accessor :url xml_accessor :profile, :as => Profile xml_reader :exported_key key :url, String - key :email, String, :unique => true + key :diaspora_handle, String, :unique => true key :serialized_key, String key :owner_id, ObjectId @@ -30,13 +30,13 @@ class Person before_destroy :remove_all_traces before_validation :clean_url - validates_presence_of :email, :url, :profile, :serialized_key + validates_presence_of :diaspora_handle, :url, :profile, :serialized_key validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix def self.search(query) - Person.all('$where' => "function() { return this.email.match(/^#{query}/i) || + Person.all('$where' => "function() { return this.diaspora_handle.match(/^#{query}/i) || this.profile.first_name.match(/^#{query}/i) || this.profile.last_name.match(/^#{query}/i); }") end @@ -79,7 +79,8 @@ class Person end def self.by_webfinger( identifier ) - local_person = Person.first(:email => identifier.gsub('acct:', '')) + local_person = Person.first(:diaspora_handle => identifier.gsub('acct:', '')) + if local_person local_person elsif !identifier.include?("localhost") @@ -102,7 +103,7 @@ class Person guid = profile.links.select{|x| x.rel == 'http://joindiaspora.com/guid'}.first.href new_person.id = guid - new_person.email = identifier + new_person.diaspora_handle = identifier hcard = HCard.find profile.hcard.first[:href] @@ -124,7 +125,7 @@ class Person :person => { :id => self.id, :name => self.real_name, - :email => self.email, + :diaspora_handle => self.diaspora_handle, :url => self.url, :exported_key => exported_key } diff --git a/app/models/user.rb b/app/models/user.rb index 185c5ea55..9eb33f2d7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -305,7 +305,7 @@ class User def setup_person self.person.serialized_key ||= User.generate_key.export - self.person.email ||= email + self.person.diaspora_handle ||= self.diaspora_handle self.person.save! end diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml index 88dfef672..b495aef30 100644 --- a/app/views/people/index.html.haml +++ b/app/views/people/index.html.haml @@ -18,7 +18,7 @@ %table %tr %th real name - %th email + %th diaspora handle %th url - for person in @people %tr @@ -27,7 +27,7 @@ - else %td= person.real_name - %td= person.email + %td= person.diaspora_handle %td= person.url -if current_user.friends.include? person @@ -46,5 +46,5 @@ %td = form_for Request.new do |f| = f.select(:aspect_id, @aspects_dropdown_array) - = f.hidden_field :destination_url, :value => person.email + = f.hidden_field :destination_url, :value => person.diaspora_handle = f.submit "add friend" diff --git a/app/views/people/new.html.haml b/app/views/people/new.html.haml index 933c26778..66d70882a 100644 --- a/app/views/people/new.html.haml +++ b/app/views/people/new.html.haml @@ -8,9 +8,9 @@ = form_for @person do |f| = f.error_messages %p - = f.label :email + = f.label :diaspora_handle %br - = f.text_field :email + = f.text_field :diaspora_handle %p = f.label :url %br diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb index f695c4c97..47b76e6e6 100644 --- a/app/views/publics/webfinger.erb +++ b/app/views/publics/webfinger.erb @@ -1,6 +1,6 @@ - acct:<%=@person.email%> + acct:<%=@person.diaspora_handle%> "<%= @person.url %>" diff --git a/lib/salmon/salmon.rb b/lib/salmon/salmon.rb index d1a4d7a1f..ea25b9f9d 100644 --- a/lib/salmon/salmon.rb +++ b/lib/salmon/salmon.rb @@ -82,7 +82,7 @@ module Salmon #{@author.real_name} - acct:#{@author.email} + acct:#{@author.diaspora_handle} #{@magic_sig.to_xml} diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb index a49aaf6f4..ab7d5a602 100644 --- a/spec/controllers/publics_controller_spec.rb +++ b/spec/controllers/publics_controller_spec.rb @@ -60,7 +60,7 @@ describe PublicsController do end it 'should add the pending request to the right user if the target person does not exist locally' do - Person.should_receive(:by_webfinger).with(@user2.person.email).and_return(@user2.person) + Person.should_receive(:by_webfinger).with(@user2.person.diaspora_handle).and_return(@user2.person) @user2.person.delete @user2.delete post :receive, :id => @user.person.id, :xml => @xml diff --git a/spec/factories.rb b/spec/factories.rb index 2fc272c5f..374c6c76b 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -15,7 +15,7 @@ Factory.define :profile do |p| end Factory.define :person do |p| - p.sequence(:email) {|n| "bob-person-#{n}@aol.com"} + p.sequence(:diaspora_handle) {|n| "bob-person-#{n}@aol.com"} p.sequence(:url) {|n| "http://google-#{n}.com/"} p.profile Factory.create(:profile) diff --git a/spec/fixtures/msg.xml.clear.asc b/spec/fixtures/msg.xml.clear.asc index e80a6a26f..cf14e109b 100644 --- a/spec/fixtures/msg.xml.clear.asc +++ b/spec/fixtures/msg.xml.clear.asc @@ -5,7 +5,7 @@ Hash: SHA1 jimmy's 1 whales <_id>4c3b7cf9312f91367f000004 - bob1@aol.com + bob1@aol.com http://www.example.com/ <_id>4c3b7c64312f913664000005 0264242496D4B585297BF236BEEFE6DEBE3407AA diff --git a/spec/lib/diaspora_parser_spec.rb b/spec/lib/diaspora_parser_spec.rb index d4cf63442..5fa064958 100644 --- a/spec/lib/diaspora_parser_spec.rb +++ b/spec/lib/diaspora_parser_spec.rb @@ -15,7 +15,7 @@ describe Diaspora::Parser do before do @user = Factory.create(:user, :email => "bob@aol.com") @aspect = @user.aspect(:name => 'spies') - @person = Factory.create(:person_with_private_key, :email => "bill@gates.com") + @person = Factory.create(:person_with_private_key, :diaspora_handle => "bill@gates.com") @user2 = Factory.create(:user) end @@ -25,7 +25,7 @@ describe Diaspora::Parser do end it 'should be able to correctly handle comments with person in db' do - person = Factory.create(:person, :email => "test@testing.com") + person = Factory.create(:person, :diaspora_handle => "test@testing.com") post = Factory.create(:status_message, :person => @user.person) comment = Factory.build(:comment, :post => post, :person => person, :text => "Freedom!") xml = comment.to_diaspora_xml @@ -49,7 +49,7 @@ describe Diaspora::Parser do parsed_person = Diaspora::Parser::parse_or_find_person_from_xml(xml) parsed_person.save.should be true - parsed_person.email.should == commenter.person.email + parsed_person.diaspora_handle.should == commenter.person.diaspora_handle parsed_person.profile.should_not be_nil end diff --git a/spec/lib/salmon_salmon_spec.rb b/spec/lib/salmon_salmon_spec.rb index 4beb87866..18854391e 100644 --- a/spec/lib/salmon_salmon_spec.rb +++ b/spec/lib/salmon_salmon_spec.rb @@ -35,8 +35,8 @@ describe Salmon do @parsed_salmon.data.should == xml end - it 'should parse out the author email' do - @parsed_salmon.author_email.should == @user.person.email + it 'should parse out the authors diaspora_handle' do + @parsed_salmon.author_email.should == @user.person.diaspora_handle end it 'should reference a local author' do diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 05bb0a716..98f1c3b73 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -15,8 +15,8 @@ describe Person do @aspect2 = @user2.aspect(:name => "Abscence of Babes") end - it 'should not allow two people with the same email' do - person_two = Factory.build(:person, :url => @person.email) + 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 end @@ -147,10 +147,10 @@ describe Person do people.include?(@friend_three).should == false end - it 'should search by email exactly' do + it 'should search by diaspora_handle exactly' do stub_success("tom@tom.joindiaspora.com") - Person.by_webfinger(@friend_one.email).should == @friend_one + Person.by_webfinger(@friend_one.diaspora_handle).should == @friend_one end it 'should create a stub for a remote user' do diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index 2cb428a94..9fe37b98e 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -18,7 +18,7 @@ describe Post do end it 'should serialize to xml with its person' do - @message.to_xml.to_s.include?(@user.person.email).should == true + @message.to_xml.to_s.include?(@user.person.diaspora_handle).should == true end end diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index dda6a0669..12b781b0f 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -25,14 +25,14 @@ describe Request do xml = request.to_xml.to_s - xml.include?(@user.person.email).should be true + xml.include?(@user.person.diaspora_handle).should be true xml.include?(@user.url).should be true xml.include?(@user.profile.first_name).should be true xml.include?(@user.profile.last_name).should be true end it 'should allow me to see only friend requests sent to me' do - remote_person = Factory.build(:person, :email => "robert@grimm.com", :url => "http://king.com/") + remote_person = Factory.build(:person, :diaspora_handle => "robert@grimm.com", :url => "http://king.com/") Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save Request.instantiate(:into => @aspect.id, :from => @user.person, :to => remote_person.receive_url).save diff --git a/spec/user_encryption_spec.rb b/spec/user_encryption_spec.rb index 70cdb5683..08e69e561 100644 --- a/spec/user_encryption_spec.rb +++ b/spec/user_encryption_spec.rb @@ -16,12 +16,12 @@ describe 'user encryption' do @person = Factory.create(:person_with_private_key, :profile => Profile.new(:first_name => 'Remote', :last_name => 'Friend'), - :email => 'somewhere@else.com', + :diaspora_handle => 'somewhere@else.com', :url => 'http://distant-example.com/') @person2 = Factory.create(:person_with_private_key, :profile => Profile.new(:first_name => 'Second', :last_name => 'Friend'), - :email => 'elsewhere@else.com', + :diaspora_handle => 'elsewhere@else.com', :url => 'http://distanter-example.com/') end From 78cc51efb40ba335bc2cc403d0e365be4e6d9f45 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 13:34:06 -0700 Subject: [PATCH 10/31] MS DG more emails for person in the seedfile --- db/seeds/backer.rb | 2 +- db/seeds/dev.rb | 4 ++-- db/seeds/tom.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 48da28143..152b8113a 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -25,7 +25,7 @@ def create :username => username, :password => "#{username+backer_info[backer_number]['pin'].to_s}", :person => Person.new( - :email => "#{username}@#{username}.joindiaspora.com", + :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/") diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index 41543e012..b7b655952 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -13,7 +13,7 @@ user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", :password => "evankorth", :person => Person.new( - :email => "tom@tom.joindiaspora.com", + :diaspora_handle => "tom@tom.joindiaspora.com", :url => url, :profile => Profile.new( :first_name => "Alexander", :last_name => "Hamiltom" )) ) @@ -22,7 +22,7 @@ user.person.save! user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", :username => "korth", :password => "evankorth", - :person => Person.new( :email => "korth@tom.joindiaspora.com", + :person => Person.new( :diaspora_handle => "korth@tom.joindiaspora.com", :url => url, :profile => Profile.new( :first_name => "Evan", :last_name => "Korth"))) diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index ee781a5e1..46e6d6300 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -12,7 +12,7 @@ user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", :password => "evankorth", :person => { - :email => "tom@tom.joindiaspora.com", + :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"}} @@ -22,7 +22,7 @@ user.person.save! user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", :password => "evankorth", :username => "korth", - :person => { :email => "korth@tom.joindiaspora.com", + :person => { :diaspora_handle => "korth@tom.joindiaspora.com", :url => remote_url, :profile => { :first_name => "Evan", :last_name => "Korth", From b68ec3a5b820d5f46acbbb1a742aa11f61720a4b Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 13:53:36 -0700 Subject: [PATCH 11/31] MS DG setting diaspora handle in a unclean way --- app/models/person.rb | 10 +++++++++- app/models/user.rb | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index b1aa8641d..6cc255e8b 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -30,11 +30,19 @@ class Person before_destroy :remove_all_traces before_validation :clean_url - validates_presence_of :diaspora_handle, :url, :profile, :serialized_key + after_create :ensure_diaspora_handle + validates_presence_of :url, :profile, :serialized_key validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix + def ensure_diaspora_handle + if self.owner? + self.diaspora_handle = self.owner.diaspora_handle + self.save + end + end + def self.search(query) Person.all('$where' => "function() { return this.diaspora_handle.match(/^#{query}/i) || this.profile.first_name.match(/^#{query}/i) || diff --git a/app/models/user.rb b/app/models/user.rb index 9eb33f2d7..caf39d2f7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -284,7 +284,7 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) - opts[:person][:email] = opts[:email] + opts[:person][:diaspora_handle] = opts[:email] opts[:person][:serialized_key] = generate_key User.create!( opts) end @@ -305,7 +305,7 @@ class User def setup_person self.person.serialized_key ||= User.generate_key.export - self.person.diaspora_handle ||= self.diaspora_handle + #self.person.diaspora_handle ||= self.diaspora_handle self.person.save! end From 55c1530c9f19d83bd032c6e5ec10ad4acdf92beb Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 14:09:05 -0700 Subject: [PATCH 12/31] MS DG fixing an edit profile bug --- app/views/users/edit.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 3756060e8..ce0b822a7 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -32,7 +32,7 @@ - else You don't have any photos! Go to the - = link_to "albums", albums_path + = link_to "albums", albums_path(:aspect => 'all') page to upload some. =will_paginate @photos From 8828707c45e3daf02cd336c55a0b8b4195232c04 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 15:15:15 -0700 Subject: [PATCH 13/31] MS fixed the login bug, deploying to master --- app/models/person.rb | 8 -------- app/models/user.rb | 20 +++++++++++++++----- app/views/devise/registrations/new.html.haml | 1 + spec/models/request_spec.rb | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index 6cc255e8b..8bd8aaa73 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -30,19 +30,11 @@ class Person before_destroy :remove_all_traces before_validation :clean_url - after_create :ensure_diaspora_handle validates_presence_of :url, :profile, :serialized_key validates_format_of :url, :with => /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix - def ensure_diaspora_handle - if self.owner? - self.diaspora_handle = self.owner.diaspora_handle - self.save - end - end - def self.search(query) Person.all('$where' => "function() { return this.diaspora_handle.match(/^#{query}/i) || this.profile.first_name.match(/^#{query}/i) || diff --git a/app/models/user.rb b/app/models/user.rb index caf39d2f7..01c1b78f6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -22,7 +22,9 @@ class User key :pending_request_ids, Array 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' @@ -32,7 +34,11 @@ class User many :aspects, :class_name => 'Aspect' - before_validation_on_create :setup_person + + after_create :setup_person + after_create :seed_aspects + + before_validation :do_bad_things before_save :downcase_username @@ -286,9 +292,13 @@ class User def self.instantiate!( opts = {} ) opts[:person][:diaspora_handle] = opts[:email] opts[:person][:serialized_key] = generate_key - User.create!( opts) + User.create!(opts) end - + + def self.create(opts ={}) + puts opts.inspect + end + def terse_url terse = self.url.gsub(/(https?:|www\.)\/\//, '') terse = terse.chop! if terse[-1, 1] == '/' @@ -305,7 +315,7 @@ class User def setup_person self.person.serialized_key ||= User.generate_key.export - #self.person.diaspora_handle ||= self.diaspora_handle + self.person.diaspora_handle ||= self.diaspora_handle self.person.save! end diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 4b461fa01..212818f41 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -3,6 +3,7 @@ = form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| = devise_error_messages! + = f.hidden_field :url, :value => request.host %p = f.label :username = f.text_field :username diff --git a/spec/models/request_spec.rb b/spec/models/request_spec.rb index 12b781b0f..715a310b9 100644 --- a/spec/models/request_spec.rb +++ b/spec/models/request_spec.rb @@ -26,7 +26,7 @@ describe Request do xml = request.to_xml.to_s xml.include?(@user.person.diaspora_handle).should be true - xml.include?(@user.url).should be true + xml.include?(@user.person.url).should be true xml.include?(@user.profile.first_name).should be true xml.include?(@user.profile.last_name).should be true end From e375af352c4d4b86977fbf185bb7ab5f0cb14e23 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 15:21:52 -0700 Subject: [PATCH 14/31] added url to backer script --- db/seeds/backer.rb | 1 + db/seeds/dev.rb | 2 ++ db/seeds/tom.rb | 2 ++ 3 files changed, 5 insertions(+) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 152b8113a..4fd3a26e4 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -24,6 +24,7 @@ def create user = User.create( :email => "#{username}@#{username}.joindiaspora.com", :username => username, :password => "#{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'], diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index b7b655952..3c3cd3c45 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -12,6 +12,7 @@ url = "http://#{host}/" user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", :password => "evankorth", + :url=> "http://#{username}.joindiaspora.com/" :person => Person.new( :diaspora_handle => "tom@tom.joindiaspora.com", :url => url, @@ -21,6 +22,7 @@ user.person.save! user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", :username => "korth", + :url=> "http://#{username}.joindiaspora.com/" :password => "evankorth", :person => Person.new( :diaspora_handle => "korth@tom.joindiaspora.com", :url => url, diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 46e6d6300..0adc3df7b 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -11,6 +11,7 @@ remote_url = "http://tom.joindiaspora.com/" user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", :password => "evankorth", + :url=> "http://#{username}.joindiaspora.com/" :person => { :diaspora_handle => "tom@tom.joindiaspora.com", :url => remote_url, @@ -22,6 +23,7 @@ user.person.save! user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", :password => "evankorth", :username => "korth", + :url=> "http://#{username}.joindiaspora.com/" :person => { :diaspora_handle => "korth@tom.joindiaspora.com", :url => remote_url, :profile => { :first_name => "Evan", From 89f2cddde921b658ed36a0d3044e18214feb7efc Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 15 Sep 2010 15:23:53 -0700 Subject: [PATCH 15/31] adjusting readme --- README.md | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 85e52b7c8..734c67c92 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,10 @@ +## Commit Guidlines +You are welcome to contribute, add and extend Diaspora however you see fit. We will do our best to incorporate everything that meets our guidelines. + +All commits must be tested, and after each commit, all tests should be green before a pull request is sent. Please write your tests in Rspec or Test-Unit. + +GEMS: We would like to keep external dependencies unduplicated. We're using Nokogiri, and Mongomapper, and EM::HttpRequest as much as possible. We have a few gems in the project we'd rather not use, but if you can, use dependencies we already have. + # Diaspora The privacy aware, personally controlled, do-it-all, open source social network. @@ -124,15 +131,6 @@ Once mongo is running and bundler has finished, run `bundle exec thin start` fro ### Testing Diaspora's test suite uses [rspec](http://rspec.info/), a behavior driven testing framework. In order to run the tests, run `bundle exec rspec spec`. - -## Commit Guidlines -You are welcome to contribute, add and extend Diaspora however you see fit. We will do our best to incorporate everything that meets our guidelines. - -All commits must be tested, and after each commit, all tests should be green before a pull request is sent. Please write your tests in Rspec or Test-Unit, (depending on the functionality) so we can minimize diaspora’s requirements. - -GEMS: if you are adding to diaspora, and want to maximize the speed of getting pulled back in, please use the libraries we are already using in the application ie: Nokogiri for XML parsing, MongoMapper for database querying, EM:HttpRequest for http requests etc etc. We currently have a few duplicate libraries which we used for the sake of “making it green”, but this duplication is high on our “wanted refactors” list. - - ## Resources We are maintaining a [public tracker project](http://www.pivotaltracker.com/projects/61641) and a [roadmap](https://github.com/diaspora/diaspora/wiki/Roadmap). Also, you can file [bug reports](https://github.com/diaspora/diaspora/issues) right here on github. From 7741951a42415021012b10efad571a04f959f636 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 15:26:06 -0700 Subject: [PATCH 16/31] MS removing production stuff from master... yowch --- app/models/user.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 01c1b78f6..639a55cc5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -36,8 +36,6 @@ class User after_create :setup_person - after_create :seed_aspects - before_validation :do_bad_things before_save :downcase_username From 16625f4ee9b2a96a15ff1132e64d0935105ea06c Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 15:31:53 -0700 Subject: [PATCH 17/31] MS removing production stuff from master... yowch --- 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 4fd3a26e4..72aecaeff 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -31,7 +31,7 @@ def create :image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg"), :url=> "http://#{username}.joindiaspora.com/") ) - user.person.save + user.person.save! user.aspect(:name => "Presidents") end From dece993db9d8b3f45acd46f1469c0b3f058c4abe Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 15 Sep 2010 15:35:05 -0700 Subject: [PATCH 18/31] Adjusting readme --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 734c67c92..2c8668b95 100644 --- a/README.md +++ b/README.md @@ -116,14 +116,12 @@ If you have never used github before, their [help desk](http://help.github.com/) ## Running Diaspora ### Install required gems -To start the app server for the **first time**, Bundler needs to grab Diaspora's gem depencencies. To allow this, run `bundle install` from Diaspora's root directory. - -It is important to run a bundle install every so often, in the event of a new gem dependency. We will make sure to make an announcement in the event of a gem change. +To start the app server for the first time, you need to use Bundler to install Diaspora's gem depencencies. Run `bundle install` from Diaspora's root directory. Bundler will also warn you if there is a new dependency and you need to bundle install again. ### Start Mongo After installing the above, run `sudo mongod` from where mongo is installed to start mongo. -Diaspora will **not run** unless mongo is running. Mongo will not run by default, and will need to be started every time you wish to use or run the test suite for Diaspora. +Diaspora will not run unless mongo is running. Mongo will not run by default, and will need to be started every time you wish to use or run the test suite for Diaspora. ### Run the app server Once mongo is running and bundler has finished, run `bundle exec thin start` from the root Diaspora directory. This will start the app server in development mode[.](http://bit.ly/9mwtUw) From b2b2748fea3dfd1d94f0d39b0eb6a5ebf61b0493 Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 15:39:04 -0700 Subject: [PATCH 19/31] seed aspects on user create --- app/models/user.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 639a55cc5..229637b66 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -36,6 +36,7 @@ class User after_create :setup_person + after_create :seed_aspects before_validation :do_bad_things before_save :downcase_username @@ -292,6 +293,11 @@ class User opts[:person][:serialized_key] = generate_key User.create!(opts) end + + def seed_aspects + aspect(:name => "Family") + aspect(:name => "Work") + end def self.create(opts ={}) puts opts.inspect From 3a4eb294f86c6f85d884e613a3208642974590f4 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 15:45:26 -0700 Subject: [PATCH 20/31] MS made it two callbacks for handles and keys --- app/models/user.rb | 8 ++++++-- db/seeds/backer.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 639a55cc5..20c26359e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,7 +35,8 @@ class User many :aspects, :class_name => 'Aspect' - after_create :setup_person + before_create :setup_person + after_create :set_diaspora_handle before_validation :do_bad_things before_save :downcase_username @@ -313,9 +314,12 @@ class User def setup_person self.person.serialized_key ||= User.generate_key.export - self.person.diaspora_handle ||= self.diaspora_handle self.person.save! end + + def set_diaspora_handle + self.person.diaspora_handle ||= self.diaspora_handle + end def downcase_username username.downcase! diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 72aecaeff..1deb18f74 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -21,7 +21,7 @@ def create backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i # Create seed user username = backer_info[backer_number]['username'].gsub(/ /,'').downcase - user = User.create( :email => "#{username}@#{username}.joindiaspora.com", + user = User.create(:email => "#{username}@#{username}.joindiaspora.com", :username => username, :password => "#{username+backer_info[backer_number]['pin'].to_s}", :url=> "http://#{username}.joindiaspora.com/", From 12f6872484297f3dd92c1153d5407821682b091f Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 15:49:16 -0700 Subject: [PATCH 21/31] commas in seed script --- db/seeds/tom.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 0adc3df7b..28245d737 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -11,7 +11,7 @@ remote_url = "http://tom.joindiaspora.com/" user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", :password => "evankorth", - :url=> "http://#{username}.joindiaspora.com/" + :url=> "http://#{username}.joindiaspora.com/", :person => { :diaspora_handle => "tom@tom.joindiaspora.com", :url => remote_url, @@ -23,7 +23,7 @@ user.person.save! user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", :password => "evankorth", :username => "korth", - :url=> "http://#{username}.joindiaspora.com/" + :url=> "http://#{username}.joindiaspora.com/", :person => { :diaspora_handle => "korth@tom.joindiaspora.com", :url => remote_url, :profile => { :first_name => "Evan", From 77bd68e7c75dbe76a4bee4d8f309c8524ca094ea Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 15:55:26 -0700 Subject: [PATCH 22/31] MS the deploy config is wrong --- app/models/user.rb | 2 +- db/seeds/tom.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 2318ce0f6..fec003a40 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -290,7 +290,7 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) - opts[:person][:diaspora_handle] = opts[:email] + #opts[:person][:diaspora_handle] = opts[:email] opts[:person][:serialized_key] = generate_key User.create!(opts) end diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 28245d737..928cffb4c 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -11,7 +11,7 @@ remote_url = "http://tom.joindiaspora.com/" user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", :password => "evankorth", - :url=> "http://#{username}.joindiaspora.com/", + :url => remote_url, :person => { :diaspora_handle => "tom@tom.joindiaspora.com", :url => remote_url, @@ -23,7 +23,7 @@ user.person.save! user2 = User.instantiate!( :email => "korth@tom.joindiaspora.com", :password => "evankorth", :username => "korth", - :url=> "http://#{username}.joindiaspora.com/", + :url => remote_url, :person => { :diaspora_handle => "korth@tom.joindiaspora.com", :url => remote_url, :profile => { :first_name => "Evan", From b8bbc58d30d3ce152688745d30b669ad1c86bfd9 Mon Sep 17 00:00:00 2001 From: maxwell Date: Wed, 15 Sep 2010 16:02:23 -0700 Subject: [PATCH 23/31] save person after changing handle --- app/models/user.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/user.rb b/app/models/user.rb index fec003a40..5f9bfb604 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -325,6 +325,7 @@ class User def set_diaspora_handle self.person.diaspora_handle ||= self.diaspora_handle + self.person.save end def downcase_username From ee89bfaf8f1681716a1f038e1d513b21c4ec6ca9 Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 16:16:44 -0700 Subject: [PATCH 24/31] removed do bad things --- app/models/user.rb | 5 ----- db/seeds/backer.rb | 1 + db/seeds/dev.rb | 2 ++ db/seeds/tom.rb | 2 ++ spec/models/aspect_spec.rb | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 5f9bfb604..42bf732a6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -39,7 +39,6 @@ class User after_create :set_diaspora_handle after_create :seed_aspects - before_validation :do_bad_things before_save :downcase_username def self.find_for_authentication(conditions={}) @@ -314,10 +313,6 @@ class User "#{self.username}@#{self.terse_url}" end - def do_bad_things - self.password_confirmation = self.password - end - def setup_person self.person.serialized_key ||= User.generate_key.export self.person.save! diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 1deb18f74..56781ca3d 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -24,6 +24,7 @@ def create user = User.create(: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", diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index 3c3cd3c45..483ae7556 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -12,6 +12,7 @@ url = "http://#{host}/" 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", @@ -24,6 +25,7 @@ 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", diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index 928cffb4c..685cc35a6 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -11,6 +11,7 @@ remote_url = "http://tom.joindiaspora.com/" 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", @@ -22,6 +23,7 @@ user.person.save! 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", diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index 4e6a5aea8..6bdbf8c1c 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -52,7 +52,7 @@ describe Aspect do it 'belong to a user' do @aspect.user.id.should == @user.id - @user.aspects.size.should == 1 + @user.aspects.size.should == 3 @user.aspects.first.id.should == @aspect.id end From e0ffc8bba0e29448c4b18eb890ff81e71eb9c6a4 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 15 Sep 2010 16:40:03 -0700 Subject: [PATCH 25/31] First pass at having a custom registrationsController --- app/controllers/registrations_controller.rb | 18 ++++++++++++++++++ app/models/user.rb | 18 +++--------------- .../{devise => }/registrations/edit.html.haml | 0 .../{devise => }/registrations/new.html.haml | 0 config/routes.rb | 4 ++-- db/seeds/dev.rb | 1 + 6 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 app/controllers/registrations_controller.rb rename app/views/{devise => }/registrations/edit.html.haml (100%) rename app/views/{devise => }/registrations/new.html.haml (100%) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb new file mode 100644 index 000000000..c75ff09a1 --- /dev/null +++ b/app/controllers/registrations_controller.rb @@ -0,0 +1,18 @@ +# Copyright (c) 2010, Disapora Inc. This file is +# licensed under the Affero General Public License version 3. See +# the COPYRIGHT file. + +class RegistrationsController < Devise::RegistrationsController + def new + super + end + + def create + User.instantiate!(params[:user]) + redirect_to root_url + end + + def update + super + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 42bf732a6..ec313fe8b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -35,8 +35,6 @@ class User many :aspects, :class_name => 'Aspect' - before_create :setup_person - after_create :set_diaspora_handle after_create :seed_aspects before_save :downcase_username @@ -288,10 +286,10 @@ class User end ###Helpers############ - def self.instantiate!( opts = {} ) - #opts[:person][:diaspora_handle] = opts[:email] + def self.instantiate( opts = {} ) + opts[:person][:diaspora_handle] = "#{opts[:username]}@#{opts[:url]}" opts[:person][:serialized_key] = generate_key - User.create!(opts) + User.create(opts) end def seed_aspects @@ -313,16 +311,6 @@ class User "#{self.username}@#{self.terse_url}" end - def setup_person - self.person.serialized_key ||= User.generate_key.export - self.person.save! - end - - def set_diaspora_handle - self.person.diaspora_handle ||= self.diaspora_handle - self.person.save - end - def downcase_username username.downcase! end diff --git a/app/views/devise/registrations/edit.html.haml b/app/views/registrations/edit.html.haml similarity index 100% rename from app/views/devise/registrations/edit.html.haml rename to app/views/registrations/edit.html.haml diff --git a/app/views/devise/registrations/new.html.haml b/app/views/registrations/new.html.haml similarity index 100% rename from app/views/devise/registrations/new.html.haml rename to app/views/registrations/new.html.haml diff --git a/config/routes.rb b/config/routes.rb index 213e090a1..c3205ed25 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,10 +26,10 @@ Diaspora::Application.routes.draw do #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file - devise_for :users + devise_for :users, :controllers => {:registrations => "registrations"} match 'login', :to => 'devise/sessions#new', :as => "new_user_session" match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" - match 'get_to_the_choppa', :to => 'devise/registrations#new', :as => "new_user_registration" + match 'get_to_the_choppa', :to => 'registrations#new', :as => "new_user_registration" #public routes # diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index 483ae7556..116a55929 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -8,6 +8,7 @@ require 'config/environment' host = "localhost:3000" url = "http://#{host}/" +username = "tom" # Create seed user user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", From 3681ae62c7e9e2bb519e97f0946115064f2022cc Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 16:43:38 -0700 Subject: [PATCH 26/31] remove google analytics --- app/views/layouts/session_wall.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/session_wall.html.haml b/app/views/layouts/session_wall.html.haml index 2b2828a4a..39e11b160 100644 --- a/app/views/layouts/session_wall.html.haml +++ b/app/views/layouts/session_wall.html.haml @@ -13,7 +13,7 @@ = stylesheet_link_tag "sessions" /= javascript_include_tag"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" - = javascript_include_tag 'jquery142', 'google' + = javascript_include_tag 'jquery142' = javascript_include_tag 'jquery.infieldlabel' :javascript From c1414c52075840e2e36e0bc4cee7aad4c3ac99e4 Mon Sep 17 00:00:00 2001 From: Daniel Vincent Grippi Date: Wed, 15 Sep 2010 16:59:44 -0700 Subject: [PATCH 27/31] flash messages are now colored on session wall --- public/stylesheets/sass/sessions.sass | 50 +++++++++++++++++++++++++++ public/stylesheets/sessions.css | 43 +++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/public/stylesheets/sass/sessions.sass b/public/stylesheets/sass/sessions.sass index 7f917b6f1..2602c3183 100644 --- a/public/stylesheets/sass/sessions.sass +++ b/public/stylesheets/sass/sessions.sass @@ -12,6 +12,56 @@ :weight normal :style normal +#flash_notice, +#flash_error, +#flash_alert + :z-index 100 + :top 32px + :position absolute + :color #000 + :width 400px + :margin 0 0 0 -200px + :left 50% + :text + :align center + :font + :size 14px + :padding 3px 0 + +#flash_notice + :background-color #CFC + :border solid 1px #6C6 + +#flash_error, +#flash_alert + :background-color #FCC + :border solid 1px #C66 + +.fieldWithErrors + :display inline + +.error_messages + :width 400px + :border 2px solid #CF0000 + :padding 0 + :padding-bottom 12px + :margin-bottom 20px + :background-color #f0f0f0 + :font + :size 12px + h2 + :text-align left + :padding 5px 5px 5px 15px + :margin 0 + :font + :weight bold + :size 12px + :background-color #c00 + p + :margin 8px 10px + ul + :margin 0 + /* via blueprint */ html :font diff --git a/public/stylesheets/sessions.css b/public/stylesheets/sessions.css index f4e585c62..3a59e54af 100644 --- a/public/stylesheets/sessions.css +++ b/public/stylesheets/sessions.css @@ -6,6 +6,49 @@ weight: normal; style: normal; } } +#flash_notice, +#flash_error, +#flash_alert { + z-index: 100; + top: 32px; + color: black; + width: 400px; + text-align: center; + font-size: 14px; + padding: 3px 0; } + +#flash_notice { + background-color: #ccffcc; + border: solid 1px #66cc66; } + +#flash_error, +#flash_alert { + background-color: #ffcccc; + border: solid 1px #cc6666; } + +.fieldWithErrors { + display: inline; } + +.error_messages { + width: 400px; + border: 2px solid #cf0000; + padding: 0; + padding-bottom: 12px; + margin-bottom: 20px; + background-color: #f0f0f0; + font-size: 12px; } + .error_messages h2 { + text-align: left; + padding: 5px 5px 5px 15px; + margin: 0; + font-weight: bold; + font-size: 12px; + background-color: #cc0000; } + .error_messages p { + margin: 8px 10px; } + .error_messages ul { + margin: 0; } + /* via blueprint */ html { font-size: 100.01%; } From 01d26f6d0ed3360312d0f9b60e21198f640c6376 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 15 Sep 2010 17:05:21 -0700 Subject: [PATCH 28/31] Using custom registrations controller --- app/controllers/registrations_controller.rb | 17 +++++++++++++++-- app/models/user.rb | 2 +- app/views/registrations/new.html.haml | 1 - spec/models/aspect_spec.rb | 1 - 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index c75ff09a1..96dc54bc9 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -8,8 +8,21 @@ class RegistrationsController < Devise::RegistrationsController end def create - User.instantiate!(params[:user]) - redirect_to root_url + begin + user = User.instantiate(params[:user]) + rescue MongoMapper::DocumentNotValid => e + user = nil + flash[:error] = e.message + end + puts user + if user + #set_flash_message :notice, :signed_up + flash[:notice] = "You've joined Diaspora!" + #redirect_to root_url + sign_in_and_redirect(:user, user) + else + redirect_to "/get_to_the_choppa" + end end def update diff --git a/app/models/user.rb b/app/models/user.rb index ec313fe8b..625b54875 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -289,7 +289,7 @@ class User def self.instantiate( opts = {} ) opts[:person][:diaspora_handle] = "#{opts[:username]}@#{opts[:url]}" opts[:person][:serialized_key] = generate_key - User.create(opts) + User.create!(opts) end def seed_aspects diff --git a/app/views/registrations/new.html.haml b/app/views/registrations/new.html.haml index 212818f41..eefa94519 100644 --- a/app/views/registrations/new.html.haml +++ b/app/views/registrations/new.html.haml @@ -2,7 +2,6 @@ = form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| - = devise_error_messages! = f.hidden_field :url, :value => request.host %p = f.label :username diff --git a/spec/models/aspect_spec.rb b/spec/models/aspect_spec.rb index 6bdbf8c1c..d07d917f5 100644 --- a/spec/models/aspect_spec.rb +++ b/spec/models/aspect_spec.rb @@ -53,7 +53,6 @@ describe Aspect do it 'belong to a user' do @aspect.user.id.should == @user.id @user.aspects.size.should == 3 - @user.aspects.first.id.should == @aspect.id end it 'should have people' do From 02dda4f0a7d830663651e2e3494bfcc0c3ad1fae Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 15 Sep 2010 17:08:56 -0700 Subject: [PATCH 29/31] change the name of instantiate back --- app/controllers/registrations_controller.rb | 2 +- app/models/user.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 96dc54bc9..48468fb1e 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -9,7 +9,7 @@ class RegistrationsController < Devise::RegistrationsController def create begin - user = User.instantiate(params[:user]) + user = User.instantiate!(params[:user]) rescue MongoMapper::DocumentNotValid => e user = nil flash[:error] = e.message diff --git a/app/models/user.rb b/app/models/user.rb index 625b54875..f71fdf428 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -286,7 +286,7 @@ class User end ###Helpers############ - def self.instantiate( opts = {} ) + def self.instantiate!( opts = {} ) opts[:person][:diaspora_handle] = "#{opts[:username]}@#{opts[:url]}" opts[:person][:serialized_key] = generate_key User.create!(opts) From bf33313bf92687ec4ea129bee0460250dcc1dfc7 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 15 Sep 2010 17:13:17 -0700 Subject: [PATCH 30/31] take out index, change backer seed, no puts --- app/controllers/registrations_controller.rb | 1 - app/models/user.rb | 1 - db/seeds/backer.rb | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 48468fb1e..c8122e8d6 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -14,7 +14,6 @@ class RegistrationsController < Devise::RegistrationsController user = nil flash[:error] = e.message end - puts user if user #set_flash_message :notice, :signed_up flash[:notice] = "You've joined Diaspora!" diff --git a/app/models/user.rb b/app/models/user.rb index f71fdf428..eeab16653 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -50,7 +50,6 @@ class User ######## Making things work ######## key :email, String - ensure_index :email def method_missing(method, *args) self.person.send(method, *args) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 56781ca3d..f3be616c7 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -21,7 +21,7 @@ def create backer_number = YAML.load_file(Rails.root.join('config','backer_number.yml'))[:seed_number].to_i # Create seed user username = backer_info[backer_number]['username'].gsub(/ /,'').downcase - user = User.create(:email => "#{username}@#{username}.joindiaspora.com", + 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}", From 0e0df7fb22874a389016374f79785edc5eee9bc2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Wed, 15 Sep 2010 17:21:23 -0700 Subject: [PATCH 31/31] downcase before validation --- 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 eeab16653..8dcca73ae 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -37,7 +37,7 @@ class User after_create :seed_aspects - before_save :downcase_username + before_validation_on_create :downcase_username def self.find_for_authentication(conditions={}) if conditions[:username] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i # email regex