Merge branch 'master' of github.com:diaspora/diaspora into production
Conflicts: app/models/user.rb
This commit is contained in:
commit
e94b48e19a
8 changed files with 38 additions and 29 deletions
22
README.md
22
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.
|
||||
|
|
@ -109,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)
|
||||
|
|
@ -124,15 +129,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.
|
||||
|
|
|
|||
|
|
@ -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) ||
|
||||
|
|
|
|||
|
|
@ -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,8 @@ class User
|
|||
|
||||
many :aspects, :class_name => 'Aspect'
|
||||
|
||||
after_validation_on_create :setup_person
|
||||
before_create :setup_person
|
||||
after_create :set_diaspora_handle
|
||||
after_create :seed_aspects
|
||||
|
||||
before_validation :do_bad_things
|
||||
|
|
@ -287,9 +290,18 @@ else
|
|||
def self.instantiate!( opts = {} )
|
||||
opts[:person][:diaspora_handle] = opts[:email]
|
||||
opts[:person][:serialized_key] = generate_key
|
||||
User.create!( opts)
|
||||
User.create!(opts)
|
||||
end
|
||||
|
||||
|
||||
def seed_aspects
|
||||
aspect(:name => "Family")
|
||||
aspect(:name => "Work")
|
||||
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] == '/'
|
||||
|
|
@ -314,9 +326,12 @@ else
|
|||
|
||||
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!
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -21,16 +21,17 @@ 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/",
|
||||
:person => Person.new(
|
||||
:diaspora_handle => "#{username}@#{username}.joindiaspora.com",
|
||||
:profile => Profile.new( :first_name => backer_info[backer_number]['given_name'], :last_name => backer_info[backer_number]['family_name'],
|
||||
:image_url => "http://#{username}.joindiaspora.com/images/user/#{username}.jpg"),
|
||||
:url=> "http://#{username}.joindiaspora.com/")
|
||||
)
|
||||
user.person.save
|
||||
user.person.save!
|
||||
|
||||
user.aspect(:name => "Presidents")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ remote_url = "http://localhost:3000/"
|
|||
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,
|
||||
|
|
@ -23,6 +24,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",
|
||||
|
|
|
|||
|
|
@ -25,7 +25,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
|
||||
|
|
|
|||
Loading…
Reference in a new issue