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

This commit is contained in:
ilya 2010-10-11 14:58:22 -07:00
commit bb7e2a9918
44 changed files with 738 additions and 318 deletions

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
.DS_Store .DS_Store
.idea .idea
.rvmrc .rvmrc
.stgit*
*.swap *.swap
*.swo *.swo
*.swp *.swp

View file

@ -4,9 +4,9 @@ gem 'rails', '3.0.0'
gem 'bundler', '>= 1.0.0' gem 'bundler', '>= 1.0.0'
#Security #Security
gem 'devise', '1.1.2' gem 'devise', '1.1.3'
gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper' gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper'
gem 'devise_invitable', '~> 0.3.4'
#Mongo #Mongo
gem 'mongo_mapper', :branch => 'rails3', :git => 'http://github.com/jnunemaker/mongomapper.git' gem 'mongo_mapper', :branch => 'rails3', :git => 'http://github.com/jnunemaker/mongomapper.git'
gem 'bson_ext', '1.1' gem 'bson_ext', '1.1'

View file

@ -49,21 +49,22 @@ GIT
GIT GIT
remote: http://github.com/dcu/magent.git remote: http://github.com/dcu/magent.git
revision: 06513f3dac812469a55f2e365c349af4d2abc92a revision: 5d664351b305141158fc69fc495456414821adb3
specs: specs:
magent (0.4.2) magent (1.0.0)
mongo (>= 0.1.0) em-websocket
uuidtools (>= 2.0.0) mongo
uuidtools
GIT GIT
remote: http://github.com/jnunemaker/mongomapper.git remote: http://github.com/jnunemaker/mongomapper.git
revision: 5a3328244b641fa4f6a3743e9e0b4dd6a1ac2700 revision: fd59b0ab068be7321f8e84b9dc12fb4fa6b8535d
branch: rails3 branch: rails3
specs: specs:
mongo_mapper (0.8.4) mongo_mapper (0.8.4)
activemodel (~> 3.0.0) activemodel (~> 3.0.0)
activesupport (~> 3.0.0) activesupport (~> 3.0.0)
plucky (~> 0.3.5) plucky (~> 0.3.6)
GEM GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
@ -119,6 +120,8 @@ GEM
rack (>= 1.0.0) rack (>= 1.0.0)
rack-test (>= 0.5.4) rack-test (>= 0.5.4)
selenium-webdriver (>= 0.0.3) selenium-webdriver (>= 0.0.3)
childprocess (0.0.7)
ffi (~> 0.6.3)
columnize (0.3.1) columnize (0.3.1)
crack (0.1.8) crack (0.1.8)
cucumber (0.9.2) cucumber (0.9.2)
@ -132,9 +135,11 @@ GEM
culerity (0.2.12) culerity (0.2.12)
daemons (1.1.0) daemons (1.1.0)
database_cleaner (0.5.2) database_cleaner (0.5.2)
devise (1.1.2) devise (1.1.3)
bcrypt-ruby (~> 2.1.2) bcrypt-ruby (~> 2.1.2)
warden (~> 0.10.7) warden (~> 0.10.7)
devise_invitable (0.3.4)
devise (~> 1.1.0)
diff-lcs (1.1.2) diff-lcs (1.1.2)
em-websocket (0.1.4) em-websocket (0.1.4)
addressable (>= 2.1.1) addressable (>= 2.1.1)
@ -171,7 +176,7 @@ GEM
subexec (~> 0.0.4) subexec (~> 0.0.4)
mocha (0.9.8) mocha (0.9.8)
rake rake
mongo (1.0.9) mongo (1.1)
bson (>= 1.0.5) bson (>= 1.0.5)
net-scp (1.0.4) net-scp (1.0.4)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
@ -181,8 +186,8 @@ GEM
net-ssh-gateway (1.0.1) net-ssh-gateway (1.0.1)
net-ssh (>= 1.99.1) net-ssh (>= 1.99.1)
nokogiri (1.4.3.1) nokogiri (1.4.3.1)
plucky (0.3.5) plucky (0.3.6)
mongo (~> 1.0.8) mongo (~> 1.1)
polyglot (0.3.1) polyglot (0.3.1)
pubsubhubbub (0.1.1) pubsubhubbub (0.1.1)
em-http-request (>= 0.1.5) em-http-request (>= 0.1.5)
@ -208,16 +213,16 @@ GEM
rake (0.8.7) rake (0.8.7)
rest-client (1.6.1) rest-client (1.6.1)
mime-types (>= 1.16) mime-types (>= 1.16)
rspec (2.0.0.rc) rspec (2.0.0)
rspec-core (= 2.0.0.rc) rspec-core (= 2.0.0)
rspec-expectations (= 2.0.0.rc) rspec-expectations (= 2.0.0)
rspec-mocks (= 2.0.0.rc) rspec-mocks (= 2.0.0)
rspec-core (2.0.0.rc) rspec-core (2.0.0)
rspec-expectations (2.0.0.rc) rspec-expectations (2.0.0)
diff-lcs (>= 1.1.2) diff-lcs (>= 1.1.2)
rspec-mocks (2.0.0.rc) rspec-mocks (2.0.0)
rspec-core (= 2.0.0.rc) rspec-core (= 2.0.0)
rspec-expectations (= 2.0.0.rc) rspec-expectations (= 2.0.0)
rspec-rails (2.0.0.beta.17) rspec-rails (2.0.0.beta.17)
rspec (>= 2.0.0.beta.14) rspec (>= 2.0.0.beta.14)
webrat (>= 0.7.0) webrat (>= 0.7.0)
@ -227,8 +232,9 @@ GEM
ruby-debug-base (0.10.3) ruby-debug-base (0.10.3)
linecache (>= 0.3) linecache (>= 0.3)
rubyzip (0.9.4) rubyzip (0.9.4)
selenium-webdriver (0.0.28) selenium-webdriver (0.0.29)
ffi (>= 0.6.1) childprocess (>= 0.0.7)
ffi (~> 0.6.3)
json_pure json_pure
rubyzip rubyzip
subexec (0.0.4) subexec (0.0.4)
@ -267,8 +273,9 @@ DEPENDENCIES
carrierwave! carrierwave!
cucumber-rails (= 0.3.2) cucumber-rails (= 0.3.2)
database_cleaner database_cleaner
devise (= 1.1.2) devise (= 1.1.3)
devise-mongo_mapper! devise-mongo_mapper!
devise_invitable (~> 0.3.4)
em-http-request! em-http-request!
em-websocket em-websocket
factory_girl_rails factory_girl_rails

View file

@ -11,21 +11,22 @@ Initial installation instructions are [here](http://github.com/diaspora/diaspora
We are continuing to build features and improve the code base. We are continuing to build features and improve the code base.
When we think it is ready for general use, we will post more final When we think it is ready for general use, we will post more final
instructions. instructions. Issue tracking is at [bugs.joindiaspora.com](bugs.joindiaspora.com).
## Commit Guidelines ## Commit Guidelines
You are welcome to contribute, add to and extend Diaspora however you see fit. We You are welcome to contribute, add to and extend Diaspora however you see fit. We
will do our best to incorporate everything that meets our guidelines. will do our best to incorporate everything that meets our guidelines.
Please make your changes on a topic branch in your repo and submit your pull request You can find an introduction to the source code [here](http://github.com/diaspora/diaspora/wiki/An-Introduction-to-the-Diaspora-Source). For an idea of where to start, look at our [issue tracker](bugs.joindiaspora.com).
from there, so that commits you don't want to submit aren't included.
Make a topic branch. By making your changes in a topic branch, you ensure that new commits to your master are not included in the pull request, and it's easier for us to merge your commits.
Please do not rebase our tree into yours. Please do not rebase our tree into yours.
See [here](http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html) See [here](http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg39091.html)
for when to rebase. for when to rebase.
All commits must be tested, and all your tests should be green Patches must be tested, and all your tests should be green
before a pull request is sent. Please write your tests in Rspec. before a pull request is sent. Please write your tests in Rspec.
GEMS: We would like to keep external dependencies unduplicated. We're using GEMS: We would like to keep external dependencies unduplicated. We're using

View file

@ -37,9 +37,13 @@ class AlbumsController < ApplicationController
def show def show
@photo = Photo.new @photo = Photo.new
@album = current_user.find_visible_post_by_id( params[:id] ) @album = current_user.find_visible_post_by_id( params[:id] )
unless @album
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
else
@album_photos = @album.photos @album_photos = @album.photos
respond_with @album respond_with @album
end end
end
def edit def edit
@album = current_user.find_visible_post_by_id params[:id] @album = current_user.find_visible_post_by_id params[:id]

View file

@ -42,10 +42,14 @@ class AspectsController < ApplicationController
def show def show
@aspect = current_user.aspect_by_id params[:id] @aspect = current_user.aspect_by_id params[:id]
unless @aspect
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
else
@friends = @aspect.people @friends = @aspect.people
@posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC' @posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC'
respond_with @aspect respond_with @aspect
end end
end
def public def public
# @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", # @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create",

View file

@ -0,0 +1,21 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class InvitationsController < Devise::InvitationsController
def update
begin
user = User.find_by_invitation_token(params["user"]["invitation_token"])
user.accept_invitation!(params["user"])
rescue MongoMapper::DocumentNotValid => e
user = nil
flash[:error] = e.message
end
if user
flash[:notice] = I18n.t 'registrations.create.success'
sign_in_and_redirect(:user, user)
else
redirect_to new_user_registration_path
end
end
end

View file

@ -17,19 +17,10 @@ class PeopleController < ApplicationController
end end
def show def show
begin
@person = current_user.visible_person_by_id(params[:id]) @person = current_user.visible_person_by_id(params[:id])
rescue BSON::InvalidObjectId
flash[:error] = "Person not found."
redirect_to people_path
return
end
unless @person unless @person
flash[:error] = "Person not found." render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
redirect_to people_path else
return
end
@profile = @person.profile @profile = @person.profile
@aspects_with_person = current_user.aspects_with_person(@person) @aspects_with_person = current_user.aspects_with_person(@person)
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]} @aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
@ -38,6 +29,7 @@ class PeopleController < ApplicationController
@post_count = @posts.count @post_count = @posts.count
respond_with @person respond_with @person
end end
end
def destroy def destroy
current_user.unfriend(current_user.visible_person_by_id(params[:id])) current_user.unfriend(current_user.visible_person_by_id(params[:id]))

View file

@ -76,9 +76,13 @@ class PhotosController < ApplicationController
def show def show
@photo = current_user.find_visible_post_by_id params[:id] @photo = current_user.find_visible_post_by_id params[:id]
unless @photo
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
else
@album = @photo.album @album = @photo.album
respond_with @photo, @album respond_with @photo, @album
end end
end
def edit def edit
@photo = current_user.find_visible_post_by_id params[:id] @photo = current_user.find_visible_post_by_id params[:id]

View file

@ -33,8 +33,12 @@ class StatusMessagesController < ApplicationController
def show def show
@status_message = current_user.find_visible_post_by_id params[:id] @status_message = current_user.find_visible_post_by_id params[:id]
unless @status_message
render :status => 404
else
respond_with @status_message respond_with @status_message
end end
end
private private
def clean_hash(params) def clean_hash(params)

View file

@ -78,6 +78,10 @@ class UsersController < ApplicationController
send_data( File.open(tar_path).read, :filename => "#{current_user.id}.tar" ) send_data( File.open(tar_path).read, :filename => "#{current_user.id}.tar" )
end end
def invite
User.invite!(:email => params[:email])
end
private private
def prep_image_url(params) def prep_image_url(params)
url = APP_CONFIG[:pod_url].chop if APP_CONFIG[:pod_url][-1,1] == '/' url = APP_CONFIG[:pod_url].chop if APP_CONFIG[:pod_url][-1,1] == '/'

View file

@ -34,8 +34,21 @@ class Person
/^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix /^(https?):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*(\.[a-z]{2,5})?(:[0-9]{1,5})?(\/.*)?$/ix
def self.search(query) def self.search(query)
query = Regexp.escape( query.to_s.strip ) qTokens = query.to_s.strip.split(" ")
Person.all('profile.first_name' => /^#{query}/i) | Person.all('profile.last_name' => /^#{query}/i) fullQueryText = Regexp.escape( query.to_s.strip )
p = []
qTokens.each {
|token|
q = Regexp.escape( token.to_s.strip )
p = Person.all('profile.first_name' => /^#{q}/i) \
| Person.all('profile.last_name' => /^#{q}/i) \
| p
}
return p
end end
def real_name def real_name

View file

@ -7,6 +7,16 @@ require File.join(Rails.root, 'lib/diaspora/user/querying')
require File.join(Rails.root, 'lib/diaspora/user/receiving') require File.join(Rails.root, 'lib/diaspora/user/receiving')
require File.join(Rails.root, 'lib/salmon/salmon') require File.join(Rails.root, 'lib/salmon/salmon')
class InvitedUserValidator < ActiveModel::Validator
def validate(document)
unless document.invitation_token
unless document.person
document.errors[:base] << "Unless you are being invited, you must have a person"
end
end
end
end
class User class User
include MongoMapper::Document include MongoMapper::Document
plugin MongoMapper::Devise plugin MongoMapper::Devise
@ -16,11 +26,13 @@ class User
include Encryptor::Private include Encryptor::Private
QUEUE = MessageHandler.new QUEUE = MessageHandler.new
devise :database_authenticatable, :registerable, devise :invitable, :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable :recoverable, :rememberable, :trackable, :validatable
key :username, :unique => true key :username, :unique => true
key :serialized_private_key, String key :serialized_private_key, String
key :invitation_token, String
key :invitation_sent_at, DateTime
key :friend_ids, Array key :friend_ids, Array
key :pending_request_ids, Array key :pending_request_ids, Array
key :visible_post_ids, Array key :visible_post_ids, Array
@ -38,6 +50,7 @@ class User
after_create :seed_aspects after_create :seed_aspects
before_validation :downcase_username, :on => :create before_validation :downcase_username, :on => :create
validates_with InvitedUserValidator
before_destroy :unfriend_everyone, :remove_person before_destroy :unfriend_everyone, :remove_person
@ -254,6 +267,27 @@ class User
end end
###Helpers############ ###Helpers############
def accept_invitation!( opts = {} )
if self.invited?
self.username = opts[:username]
self.password = opts[:password]
self.password_confirmation = opts[:password_confirmation]
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}"
opts[:person][:url] = APP_CONFIG[:pod_url]
opts[:serialized_private_key] = User.generate_key
self.serialized_private_key = opts[:serialized_private_key]
opts[:person][:serialized_public_key] = opts[:serialized_private_key].public_key
person_hash = opts.delete(:person)
self.person = Person.create(person_hash)
self.person.save
self.save
self
end
end
def self.instantiate!( opts = {} ) def self.instantiate!( opts = {} )
opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}" opts[:person][:diaspora_handle] = "#{opts[:username]}@#{APP_CONFIG[:terse_pod_url]}"
opts[:person][:url] = APP_CONFIG[:pod_url] opts[:person][:url] = APP_CONFIG[:pod_url]

View file

@ -21,13 +21,20 @@
= request.person.real_name = request.person.real_name
%h3=t('.ignore_remove') %h3=t('.ignore_remove')
%li.remove .remove
%ul.dropzone %ul.dropzone
%li.grey Drag to ignore/remove %li.grey Drag to ignore/remove
%h3= link_to "Invite a friend!", "#invite_user_pane", :id => "invite_user_button", :class => "invite_user_button", :title => "Invite a friend"
.yo{ :style => "display:none;"}
#invite_user_pane
= render "invitations/new"
- content_for :publish do - content_for :publish do
= link_to(t('.add_a_new_aspect'), "#add_aspect_pane", :id => "add_aspect_button", :class => "new_aspect button", :title => t('.add_a_new_aspect')) = link_to(t('.add_a_new_aspect'), "#add_aspect_pane", :id => "add_aspect_button", :class => "new_aspect button", :title => t('.add_a_new_aspect'))
%ul#aspect_list %ul#aspect_list
- for aspect in @aspects - for aspect in @aspects
%li.aspect %li.aspect

View file

@ -0,0 +1,8 @@
%h2 Send invitation
= form_for User.new, :url => invitation_path(User) do |f|
/= devise_error_messages!
%p
= f.label :email
= f.text_field :email
%p= f.submit "Send an invitation"
/= link_to "Home", after_sign_in_path_for(resource_name)

View file

@ -0,0 +1,25 @@
= image_tag "http://needcoffee.cachefly.net/needcoffee/uploads/2009/02/predator-arnold-schwarzenegger.jpg"
= form_for(resource, :as => resource_name, :url => invitation_path(resource_name), :html => {:method => :put }) do |f|
%p
= f.label :username
= f.text_field :username
%p
= f.label :password
= f.password_field :password
%p
= f.label :password_confirmation
= f.password_field :password_confirmation
= f.fields_for :person do |p|
= p.fields_for :profile do |pr|
%p
= pr.label :first_name
= pr.text_field :first_name
%p
= pr.label :last_name
= pr.text_field :last_name
= f.hidden_field :invitation_token
= f.submit 'sign_up'
= render :partial => "devise/shared/links"

View file

@ -0,0 +1,8 @@
%h2 Send invitation
= form_for User.new, :url => invitation_path(User) do |f|
= devise_error_messages!
%p
= f.label :email
= f.text_field :email
%p= f.submit "Send an invitation"
/= link_to "Home", after_sign_in_path_for(resource_name)

View file

@ -22,6 +22,5 @@
%p %p
= pr.label :last_name = pr.label :last_name
= pr.text_field :last_name = pr.text_field :last_name
= f.submit t('.sign_up') = f.submit t('.sign_up')
= render :partial => "devise/shared/links" = render :partial => "devise/shared/links"

View file

@ -19,5 +19,11 @@
= render "requests/new_request", :aspect => @aspect = render "requests/new_request", :aspect => @aspect
-else -else
.clear .clear
%br
= link_to t('.add_friends'), aspects_manage_path = link_to t('.add_friends'), aspects_manage_path
%br
= link_to "Invite a friend!", "#invite_user_pane", :id => "invite_user_button", :class => "invite_user_button", :title => "Invite a friend"
.yo{ :style => "display:none;"}
#invite_user_pane
= render "invitations/new"

View file

@ -21,7 +21,10 @@
= f.hidden_field( :public, :value => false ) = f.hidden_field( :public, :value => false )
.buttons .buttons
= f.submit t('.share') - if @aspect == :all
= f.submit t('.share'), :title => "Share with all aspects"
- else
= f.submit t('.share'), :title => "Share with #{@aspect.name}"
- if defined? broadcast - if defined? broadcast
= f.submit "Broadcast", :class => "broadcast", :name => "broadcast" = f.submit "Broadcast", :class => "broadcast", :name => "broadcast", :title => "Publish to Diaspora and Facebook"

View file

@ -4,6 +4,7 @@
%h2 Profile %h2 Profile
= link_to new_user_invitation_path(current_user)
= form_for @user do |f| = form_for @user do |f|
= f.error_messages = f.error_messages

View file

@ -0,0 +1,9 @@
%p
Hello #{@resource.email}!
%p
Someone has invited you to #{root_url}, you can accept it through the link below.
%p= link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token)
%p
If you don't want to accept the invitation, please ignore this email.
%br/
Your account won't be created until you access the link above and set your password.

View file

@ -44,6 +44,11 @@ Devise.setup do |config|
# Setup a pepper to generate the encrypted password. # Setup a pepper to generate the encrypted password.
config.pepper = "065eb8798b181ff0ea2c5c16aee0ff8b70e04e2ee6bd6e08b49da46924223e39127d5335e466207d42bf2a045c12be5f90e92012a4f05f7fc6d9f3c875f4c95b" config.pepper = "065eb8798b181ff0ea2c5c16aee0ff8b70e04e2ee6bd6e08b49da46924223e39127d5335e466207d42bf2a045c12be5f90e92012a4f05f7fc6d9f3c875f4c95b"
# ==> Configuration for :invitable
# Time interval where the invitation token is valid (default: 0).
# If invite_for is 0 or nil, the invitation will never expire.
# config.invite_for = 2.weeks
# ==> Configuration for :confirmable # ==> Configuration for :confirmable
# The time you want to give your user to confirm his account. During this time # The time you want to give your user to confirm his account. During this time
# he will be able to access your application without confirming. Default is nil. # he will be able to access your application without confirming. Default is nil.

View file

@ -2,4 +2,22 @@
# licensed under the Affero General Public License version 3 or later. See # licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file. # the COPYRIGHT file.
GIT_INFO = `git show --name-only` s = `git show --name-only 2>/dev/null || :`
if (s.nil? or s.empty?)
path = File.expand_path("config/gitversion")
begin
if (File.exists?( path))
s = ''
f = File.open( path)
f.each_line do |line|
s += line
end
f.close
end
rescue
s = ""
end
end
GIT_INFO = s
# What's the scope of this s? Leave to GC just in case...
s = nil

View file

@ -0,0 +1,46 @@
en:
errors:
messages:
not_found: "not found"
already_confirmed: "was already confirmed"
not_locked: "was not locked"
devise:
failure:
unauthenticated: 'You need to sign in or sign up before continuing.'
unconfirmed: 'You have to confirm your account before continuing.'
locked: 'Your account is locked.'
invalid: 'Invalid email or password.'
invalid_token: 'Invalid authentication token.'
timeout: 'Your session expired, please sign in again to continue.'
inactive: 'Your account was not activated yet.'
sessions:
signed_in: 'Signed in successfully.'
signed_out: 'Signed out successfully.'
passwords:
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
updated: 'Your password was changed successfully. You are now signed in.'
confirmations:
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
confirmed: 'Your account was successfully confirmed. You are now signed in.'
registrations:
signed_up: 'You have signed up successfully. If enabled, a confirmation was sent to your e-mail.'
updated: 'You updated your account successfully.'
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
unlocks:
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
unlocked: 'Your account was successfully unlocked. You are now signed in.'
invitations:
send_instructions: 'Your invitation has been sent.'
invitation_token_invalid: 'The invitation token provided is not valid!'
updated: 'Your password was set successfully. You are now signed in.'
mailer:
confirmation_instructions:
subject: 'Confirmation instructions'
reset_password_instructions:
subject: 'Reset password instructions'
unlock_instructions:
subject: 'Unlock Instructions'
invitation:
subject: 'A friend wants you to join Diaspora!'

View file

@ -11,7 +11,8 @@ Diaspora::Application.routes.draw do
resources :albums resources :albums
devise_for :users, :controllers => {:registrations => "registrations", devise_for :users, :controllers => {:registrations => "registrations",
:password => "devise/passwords"} :password => "devise/passwords",
:invitations => "invitations"}
# added public route to user # added public route to user
match 'public/:username', :to => 'users#public' match 'public/:username', :to => 'users#public'
match 'users/export', :to => 'users#export' match 'users/export', :to => 'users#export'

View file

@ -7,7 +7,7 @@ module Diaspora
module Querying module Querying
def find_visible_post_by_id( id ) def find_visible_post_by_id( id )
self.raw_visible_posts.find id self.raw_visible_posts.find id.to_id
end end
def visible_posts( opts = {} ) def visible_posts( opts = {} )
@ -44,11 +44,9 @@ module Diaspora
end end
def people_in_aspects aspects def people_in_aspects aspects
people = [] aspects.inject([]) do |found_people,aspect|
aspects.each{ |aspect| found_people | aspect.people
people = people | aspect.people end
}
people
end end
def all_aspect_ids def all_aspect_ids

View file

@ -4,7 +4,11 @@
class String class String
def to_id def to_id
begin
BSON::ObjectId self BSON::ObjectId self
rescue
nil
end
end end
end end
class BSON::ObjectId class BSON::ObjectId

View file

@ -1,2 +1,3 @@
TODO TODO
dist dist
.stgit*

View file

@ -1,12 +1,13 @@
## Diaspora RPM tools ## Diaspora RPM tools
Creates RPM packages from diaspora git repository. Creates diaspora source tarballs and RPM packages
An alternative to the capistrano system, providing classic, binary RPM An alternative to the capistrano system, providing classic, binary RPM
packages for deployment on Fedora 13. packages for deployment on Fedora 13 and OS-independent source tarballs
aimed for packaging purposes.
#### Synopsis: #### Fedora RPM synopsis
*Prerequisites*: ruby-1.8, rubygem and other packages as described in *Prerequisites*: ruby-1.8, rubygem and other packages as described in
http://github.com/diaspora/diaspora/wiki/Rpm-installation-on-fedora http://github.com/diaspora/diaspora/wiki/Rpm-installation-on-fedora
@ -17,8 +18,8 @@ and dist/diaspora-bundle-0.0-1010041233_fade4231.tar.gz:
% ./make-dist.sh source % ./make-dist.sh source
% ./make-dist.sh bundle % ./make-dist.sh bundle
Setup links to tarballs from RPM source directory: Setup links to tarballs from RPM source directory and create spec files:
% ./make-dist.sh links % ./make-dist.sh prepare
Build rpms: Build rpms:
rpmbuild -ba dist/diaspora.spec rpmbuild -ba dist/diaspora.spec
@ -39,46 +40,73 @@ Start development server:
See http://github.com/diaspora/diaspora/wiki/Using-apache for See http://github.com/diaspora/diaspora/wiki/Using-apache for
apache/passenger setup. After configuration, start with: apache/passenger setup. After configuration, start with:
/sbin/service diaspora-ws start /sbin/service diaspora-wsd start
/sbin/service httpd restart /sbin/service httpd restart
#### Generic source synopsis
Generate source tarball:
% ./make-dist.sh source
Using repo: http://github.com/diaspora/diaspora.git
Commit id: 1010092232_b313272
Source: dist/diaspora-0.0-1010092232_b313272.tar.gz
Required bundle: 1010081636_d1a4ee0
%
The source tarball could be used as-is, by unpacking add making a
*bundle install*. An alternative is to generate a canned bundle like:
% ./make-dist.sh bundle
[ lot's of output...]
Bundle: dist/diaspora-bundle-0.0-1010081636_d1a4ee0.tar.gz
%
This file can be installed anywhere. To use it, add a symlink from vendor/bundle
to the bundle's master directory. Reasonable defaults are to install
diaspora in /var/diaspora and bundle in /usr/lib/diaspora-bundle. With these,
the link is
% rm -rf /var/diaspora/master/vendor/bundle
% ln -sf /usr/lib/diaspora-bundle/master/bundle \
> /var/diaspora/master/vendor
%
The directories tmp, log, and public/uploads needs to be writable. If using
apache passenger, read the docs on uid used and file ownership.
Note that the bundle version required is printed each time a new source
is generated.
#### Notes #### Notes
The source tarball is as retrieved from diaspora with following differences:
- The .git directories are removed (freeing more than 50% of the size).
- A new file /master/config/gitversion is created.
- The file public/source.tar is generated.
- The file .bundle/config is patched. Remove before doing
*bundle install*
Routines uses last available version from master branch at github. The Routines uses last available version from master branch at github. The
version contains a time stamp and an abbreviated git commit id. If listed version contains a time stamp and an abbreviated git commit id.
in filename order, like ls does, latest version will be the last one.
Using -c, a specific commit can be used for source build. Using -c, a specific commit can be used for source build.
*make-dist links* creates links also for all files listed in SOURCES. *make-dist prepare* creates links also for all files listed in SOURCES.
Typically, this is secondary sources. *make-dist.sh sources* Typically, this is secondary sources. *make-dist.sh sources*
applies all patches named *.patch in this directory after checking out applies all patches named *.patch in this directory after checking out
source from git. source from git.
The spec-files in dist/ are patched by ./make-dist.sh source to reference The spec-files in dist/ are patched by *./make-dist.sh prepare* to reference
correct versions of diaspora and diaspora-bundle. The diaspora-bundle correct versions of diaspora and diaspora-bundle. The diaspora-bundle
is only updated if Gemfile is updated, upgrading diaspora doesn't is only updated if Gemfile is updated, upgrading diaspora doesn't
always require a new diaspora-bundle. Editing spec files should be done always require a new diaspora-bundle. Editing spec files should be done
in this directory, changes in dist/ are lost when doing ./make-dist source. in this directory, changes in dist/ are lost when doing *./make-dist prepare*.
The topmost comment's version is patched to reflect the complete version The topmost comment's version is patched to reflect the complete version
of current specfile by 'make-dist source'. WRite the comment in this of current specfile by *make-dist source*. Write the comment in this
directory, copy-paste previous version nr. It will be updated. directory, copy-paste previous version nr. It will be updated.
rpmlint shows many errors, most of which related to that the server
won't start if the .git directories are not included. Needs investigation.
This has been confirmed to start up and provide basic functionality both using This has been confirmed to start up and provide basic functionality both using
the thin webserver and apache passenger, and on 32/64 bit systems. the thin webserver and apache passenger, on 32/64 bit systems and in the
mock build environment.
#### Bugs
As of now, diaspora fails if it not owns all file under /usr/share/diaspora.
I guess this means diaspora writes some stuff somewhere. In the long run,
this should be located and symlinked to /var,leaving the rest of the files
owned by root. FTM, all files in /usr/share/diaspore are owned by
diaspora
#### Implementation #### Implementation
@ -92,16 +120,17 @@ patches, the content of diaspora-bundle.
Here is also support for running the diaspora websocket service as a system Here is also support for running the diaspora websocket service as a system
service through /sbin/service and some install scripts. service through /sbin/service and some install scripts.
Diaspora files are stored in /usr/share/diaspora, and owned by diaspora. The Diaspora files are stored in /usr/share/diaspora, and owned by root. The
bundle, containing some C extensions, is architecture-dependent and lives bundle, containing some C extensions, is architecture-dependent and lives
in /usr/lib[64]/diaspora. Log files are in /var/log/diaspora. Symlinks in in /usr/lib[64]/diaspora. Log files are in /var/log/diaspora. Symlinks in
/usr/share diaspora makes log and bundle available as expected by diaspora app. /usr/share diaspora makes log, bundle and tmp dir available as expected by
This is more or less as mandated by LSB and Fedora packaging rules. diaspora app. This is more or less as mandated by LSB and Fedora packaging rules.
find /usr/share/diaspora/ -type l -exec ls -l {} \; | awk '{print $9, $10, $11}' find . -type l -exec ls -l {} \; | awk '{print $9, $10, $11}'
/usr/share/diaspora/master/public/uploads -> /var/lib/diaspora/uploads ./public/uploads -> /var/lib/diaspora/uploads
/usr/share/diaspora/master/log -> /var/log/diaspora ./log -> /var/log/diaspora
/usr/share/diaspora/master/vendor/bundle -> /usr/lib/diaspora-bundle/master/vendor/bundle ./tmp -> /var/lib/diaspora/tmp
./vendor/bundle -> /usr/lib/diaspora-bundle/master/vendor/bundle
#### Discussion #### Discussion
@ -119,8 +148,8 @@ original README.md:
not 777. not 777.
- Splitting in two packages makes sense IMHO. The bundle is not changed that often, - Splitting in two packages makes sense IMHO. The bundle is not changed that often,
but is quite bug: ~18M without test packages (the default) or ~55M with test but is quite big: ~30M without test packages (the default) or ~55M with test
packages. The application is just ~7.5M, and is fast to deploy even with these packages. The application is just ~3M, and is fast to deploy even with these
tools (yes, I know, capistrano is much faster...) tools (yes, I know, capistrano is much faster...)
- Many, roughly 50% of the packages in the bundle are already packaged for Fedora - Many, roughly 50% of the packages in the bundle are already packaged for Fedora

View file

@ -1,3 +1,5 @@
# These files will be linked to %_sourcedir by 'make-dist links' # These files will be linked to %_sourcedir by 'make-dist links'
diaspora-setup diaspora-setup
diaspora-ws diaspora-wsd
diaspora.logconf
make_rel_symlink.py

View file

@ -17,9 +17,9 @@ URL: http://www.joindiaspora.com/
Vendor: joindiaspora.com Vendor: joindiaspora.com
Source: %{name}-%{version}-%{git_release}.tar.gz Source: %{name}-%{version}-%{git_release}.tar.gz
Prefix: %{_prefix} Prefix: %{_prefix}
BuildRoot: %{_rmpdir}/not-used-in-fedora/
Requires(pre): shadow-utils Requires(pre): shadow-utils
BuildRequires: git
Requires: ruby(abi) = 1.8 Requires: ruby(abi) = 1.8
%description %description
@ -37,6 +37,8 @@ Source file usede to compile native libraries in diaspora-bundle.
%prep %prep
%setup -q -n %{name}-%{version}-%{git_release} %setup -q -n %{name}-%{version}-%{git_release}
find . -name .git* -print | xargs rm -rf
pushd bundle/ruby/1.8/ pushd bundle/ruby/1.8/
find . -name \*.css -exec chmod 644 {} \; find . -name \*.css -exec chmod 644 {} \;
find . -name \*.js -exec chmod 644 {} \; find . -name \*.js -exec chmod 644 {} \;
@ -82,7 +84,7 @@ pushd bundle/ruby/1.8/
# In repo (2.2.4) # In repo (2.2.4)
test -d gems/gherkin-*/ext && { test -d gems/gherkin-*/ext && {
pushd gems/gherkin-*/ext pushd gems/gherkin-*/ext
# Recompile all shared libraries using -O2 optimalization flagcd # Recompile all shared libraries using -O2 flag
for lexer_dir in */ ; do for lexer_dir in */ ; do
pushd $lexer_dir pushd $lexer_dir
sed -i 's/ -O0 / -O2 /' extconf.rb sed -i 's/ -O0 / -O2 /' extconf.rb
@ -144,6 +146,7 @@ pushd bundle/ruby/1.8/
ln -sf ../../ext/nokogiri/nokogiri.so . ln -sf ../../ext/nokogiri/nokogiri.so .
popd popd
# in repo (rawhide)
pushd gems/json-1.4.6/ext/json/ext/json/ext pushd gems/json-1.4.6/ext/json/ext/json/ext
rm generator.so rm generator.so
ln -s ../../generator/generator.so ln -s ../../generator/generator.so
@ -199,8 +202,8 @@ popd
} }
mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle/master/vendor mkdir -p $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle/master/vendor
cp -ar bundle $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle/master/vendor cp -ar bundle $RPM_BUILD_ROOT/%{_libdir}/diaspora-bundle/master/vendor
find %{buildroot}/%{_libdir}/diaspora-bundle \ find %{buildroot}/%{_libdir}/diaspora-bundle \
-type d -fprintf dirs '%%%dir "%%p"\n' -type d -fprintf dirs '%%%dir "%%p"\n'
find -L %{buildroot}/%{_libdir}/diaspora-bundle -regextype posix-awk \ find -L %{buildroot}/%{_libdir}/diaspora-bundle -regextype posix-awk \
@ -224,5 +227,5 @@ cat files >> dirs && cp dirs files
%doc COPYRIGHT AUTHORS GNU-AGPL-3.0 %doc COPYRIGHT AUTHORS GNU-AGPL-3.0
%changelog %changelog
* Sat Oct 02 2010 Alec Leamas <leamas.alec@gmail.com> 1.1009271539_08b9aa8 * Sat Oct 02 2010 Alec Leamas <leamas.alec@gmail.com> 0.0-1.1009271539_08b9aa8
- Initial attempt to create a spec file - Initial attempt to create a spec file

View file

@ -2,13 +2,12 @@
# #
# Try to revert to pristine state, deleting all users and # Try to revert to pristine state, deleting all users and
# configuration # configuration
#
set -x set -x
service mongod stop service mongod stop
service diaspora-ws stop service diaspora-wsd stop
rm -rf /var/lib/mongodb/* rm -rf /var/lib/mongodb/*
cp /usr/share/diaspora/master/config/app_config.yml.example \ cp /usr/share/diaspora/master/config/app_config.yml.example \
/usr/share/diaspora/master/config/app_config.yml /usr/share/diaspora/master/config/app_config.yml
service mongod start service mongod start

View file

@ -2,20 +2,22 @@
# #
# Do what's needed to initiate diaspora. # Do what's needed to initiate diaspora.
# #
# See http://github.com/diaspora/diaspora/issues/issue/395
#
# Note: This is really sort of prototyping. This should be done in ruby,
# on a web page.
test $UID = "0" || { test $UID = "0" || {
echo "You need to be root to do this, giving up" echo "You need to be root to do this, giving up"
exit 2 exit 2
} }
cd /usr/share/diaspora/master services=$( netstat -nl | grep '[^:]:3000[ \t]')
test -n "$services" && {
echo "Warning: something is already using port 3000"
echo " $services"
}
/sbin/service mongod start || : /sbin/service mongod start || :
cd /usr/share/diaspora/master
test -e config/app_config.yml || test -e config/app_config.yml ||
cp config/app_config.yml.example config/app_config.yml cp config/app_config.yml.example config/app_config.yml
@ -49,4 +51,3 @@ while : ; do
break break
} }
done done

View file

@ -1,14 +1,14 @@
#!/bin/bash #!/bin/bash
# #
# /etc/rc.d/init.d/diaspora-ws # /etc/rc.d/init.d/diaspora-wsd
# #
# Starts the diaspora websocket server # Starts the diaspora websocket daemon
# #
# chkconfig: - 80 80 # chkconfig: - 80 80
# description: Diaspora websocket server # description: Diaspora websocket daemon
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: diaspora-ws # Provides: diaspora-wsd
# Required-Start: $local_fs $network # Required-Start: $local_fs $network
# Required-Stop: $local_fs $network # Required-Stop: $local_fs $network
# Should-Start: $remote_fs # Should-Start: $remote_fs
@ -23,8 +23,8 @@
# Source function library. # Source function library.
. /etc/init.d/functions . /etc/init.d/functions
if [ -f /etc/sysconfig/diaspora-ws -a $UID -eq 0 ]; then if [ -f /etc/sysconfig/diaspora-wsd -a $UID -eq 0 ]; then
. /etc/sysconfig/diaspora-ws . /etc/sysconfig/diaspora-wsd
fi fi
# Note: this line is patched by installation scripts. # Note: this line is patched by installation scripts.
@ -33,9 +33,9 @@ cd /usr/share/diaspora
RETVAL=0 RETVAL=0
prog="Diaspora websocket server" prog="Diaspora websocket server"
exec="script/websocket_server.rb" exec="script/websocket_server.rb"
pidfile="/var/run/diaspora-ws" pidfile="/var/run/diaspora-wsd"
lockfile="/var/lock/subsys/diaspora-ws" lockfile="/var/lock/subsys/diaspora-wsd"
logfile=/var/log/diaspora-ws.log logfile=/var/log/diaspora-wsd.log
[ -n "$OPTIONS" ] && OPTIONS=" $OPTIONS" [ -n "$OPTIONS" ] && OPTIONS=" $OPTIONS"
ruby_cmd="ruby -C $PWD $exec$OPTIONS" ruby_cmd="ruby -C $PWD $exec$OPTIONS"

View file

@ -8,6 +8,6 @@
notifempty notifempty
missingok missingok
postrotate postrotate
( /sbin/service diaspora-ws condrestart ) >/dev/null 2>&1 ( /sbin/service diaspora-wsd condrestart ) >/dev/null 2>&1
endscript endscript
} }

View file

@ -10,9 +10,12 @@ Group: Applications/Communications
URL: http://www.joindiaspora.com/ URL: http://www.joindiaspora.com/
Vendor: joindiaspora.com Vendor: joindiaspora.com
Source: %{name}-%{version}-%{git_release}.tar.gz Source: %{name}-%{version}-%{git_release}.tar.gz
Source1: diaspora-ws Source1: diaspora-wsd
Source2: diaspora-setup Source2: diaspora-setup
Source3: diaspora.logconf
Source4: make_rel_symlink.py
BuildArch: noarch BuildArch: noarch
BuildRoot: %{_rmpdir}/not-used-in-fedora/
Requires: mongodb-server Requires: mongodb-server
Requires: ruby(abi) = 1.8 Requires: ruby(abi) = 1.8
@ -31,31 +34,44 @@ find . -perm /u+x -type f -exec \
%build %build
rm -rf master/vendor/bundle rm -rf master/vendor/bundle
mkdir master/tmp || :
pushd master
tar cf public/source.tar --exclude='source.tar' -X .gitignore *
popd
%install %install
[ "$RPM_BUILD_ROOT" != "/" ] && rm -fr $RPM_BUILD_ROOT rm -fr $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora
cp master/README.md . sed -i \
mv master/GNU-AGPL-3.0 . '/BUNDLE_PATH/s|:.*|: %{_libdir}/diaspora-bundle/master/vendor/bundle|' \
master/.bundle/config
cp master/GNU-AGPL-3.0 master/COPYRIGHT master/README.md master/AUTHORS .
cp master/pkg/fedora/README.md README-Fedora.md
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/diaspora
mkdir -p $RPM_BUILD_ROOT/etc/init.d mkdir -p $RPM_BUILD_ROOT/etc/init.d
sed -i '/^cd /s|.*|cd %{_datadir}/diaspora/master|' diaspora-ws cp %SOURCE1 $RPM_BUILD_ROOT/etc/init.d
cp diaspora-ws $RPM_BUILD_ROOT/etc/init.d sed -i '/^cd /s|.*|cd %{_datadir}/diaspora/master|' \
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d $RPM_BUILD_ROOT/etc/init.d/diaspora-wsd
cp diaspora.logconf $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/diaspora
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d
cp %SOURCE3 $RPM_BUILD_ROOT/%{_sysconfdir}/logrotate.d/diaspora
mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora mkdir -p $RPM_BUILD_ROOT/%{_datadir}/diaspora
cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora cp -ar master $RPM_BUILD_ROOT/%{_datadir}/diaspora
cp -ar master/.gitignore master/.bundle $RPM_BUILD_ROOT/%{_datadir}/diaspora/master cp %SOURCE2 $RPM_BUILD_ROOT/%{_datadir}/diaspora
cp diaspora-setup $RPM_BUILD_ROOT/%{_datadir}/diaspora
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/uploads
find $RPM_BUILD_ROOT/%{_datadir}/diaspora -type d -fprintf dirs '%%%dir "%%p"\n' mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/log/diaspora
find -L $RPM_BUILD_ROOT/%{_datadir}/diaspora -type f -fprintf files '"%%p"\n' mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/uploads
mkdir -p $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/tmp
%{SOURCE4} $RPM_BUILD_ROOT/%{_localstatedir}/log/diaspora \
$RPM_BUILD_ROOT/%{_datadir}/diaspora/master/log
%{SOURCE4} $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/uploads \
$RPM_BUILD_ROOT/%{_datadir}/diaspora/master/public/uploads
%{SOURCE4} $RPM_BUILD_ROOT/%{_localstatedir}/lib/diaspora/tmp \
$RPM_BUILD_ROOT/%{_datadir}/diaspora/master/tmp
find $RPM_BUILD_ROOT/%{_datadir}/diaspora -type d \
-fprintf dirs '%%%dir "%%p"\n'
find -L $RPM_BUILD_ROOT/%{_datadir}/diaspora -type f \
-fprintf files '"%%p"\n'
cat files >> dirs && mv -f dirs files cat files >> dirs && mv -f dirs files
sed -i -e '\|.*/master/config.ru"$|d' \ sed -i -e '\|.*/master/config.ru"$|d' \
-e '\|.*/master/config/environment.rb"$|d' \ -e '\|.*/master/config/environment.rb"$|d' \
@ -64,36 +80,33 @@ sed -i -e '\|.*/master/config.ru"$|d' \
%post %post
rm -f %{_datadir}/diaspora/master/vendor/bundle /sbin/chkconfig --add diaspora-wsd
rm -f %{_datadir}/diaspora/master/log
rm -f %{_datadir}/diaspora/master/public/uploads
ln -s %{_localstatedir}/log/diaspora \
%{_datadir}/diaspora/master/log || :
ln -s %{_libdir}/diaspora-bundle/master/vendor/bundle \
%{_datadir}/diaspora/master/vendor || :
ln -s %{_localstatedir}/lib/diaspora/uploads \
%{_datadir}/diaspora/master/public/uploads || :
/sbin/chkconfig --add diaspora-ws || :
%preun %preun
if [ $1 -eq 0 ] ; then if [ $1 -eq 0 ] ; then
service diaspora-ws stop >/dev/null 2>&1 || : service diaspora-wsd stop &>/dev/null || :
/sbin/chkconfig --del diaspora-ws /sbin/chkconfig --del diaspora-wsd
fi fi
%clean %clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -fr $RPM_BUILD_ROOT rm -fr $RPM_BUILD_ROOT
%files -f files %files -f files
%defattr(-, diaspora, diaspora, 0755) %defattr(-, root, root, 0755)
%doc README.md GNU-AGPL-3.0 %doc AUTHORS README.md GNU-AGPL-3.0 COPYRIGHT README-Fedora.md
%attr(-, diaspora, diaspora) %{_datadir}/diaspora/master/config.ru %attr(-, diaspora, diaspora) %{_datadir}/diaspora/master/config.ru
%attr(-, diaspora, diaspora) %{_datadir}/diaspora/master/config/environment.rb %attr(-, diaspora, diaspora) %{_datadir}/diaspora/master/config/environment.rb
%attr(-, diaspora, diaspora) %{_localstatedir}/log/diaspora %attr(-, diaspora, diaspora) %{_localstatedir}/log/diaspora
%attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/uploads %attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/uploads
%attr(-, diaspora, diaspora) %{_localstatedir}/lib/diaspora/tmp
%{_datadir}/diaspora/master/tmp
%{_datadir}/diaspora/master/public/uploads
%{_datadir}/diaspora/master/log
%config(noreplace) %{_sysconfdir}/logrotate.d/diaspora %config(noreplace) %{_sysconfdir}/logrotate.d/diaspora
%{_sysconfdir}/init.d/diaspora-ws %{_sysconfdir}/init.d/diaspora-wsd
%changelog %changelog
* Fri Sep 24 2010 Alec Leamas <leamas.alec@gmail.com> 0.0-1.1009280542_859ec2d * Fri Sep 24 2010 Alec Leamas <leamas.alec@gmail.com> 0.0-1.1009280542_859ec2d

View file

@ -6,6 +6,8 @@
# #
GIT_REPO='http://github.com/diaspora/diaspora.git' GIT_REPO='http://github.com/diaspora/diaspora.git'
VERSION='0.0' VERSION='0.0'
RELEASE='1'
function git_id function git_id
# #
@ -14,28 +16,29 @@ function git_id
# Usage: git_id [-n] [file or directory] # Usage: git_id [-n] [file or directory]
# #
{ {
nl="\n" local nl="\n"
file_or_dir="$PWD" local file_or_dir="$PWD"
test "$1" = '-n' && { nl=""; shift; } test "$1" = '-n' && { nl=""; shift; }
test -n "$1" && file_or_dir="$1" test -n "$1" && file_or_dir="$1"
if [ -d $file_or_dir ]; then if [ -d $file_or_dir ]; then
file="" local file=""
dir=$file_or_dir local dir=$file_or_dir
else else
file=$(basename $file_or_dir) local file=$(basename $file_or_dir)
dir=$(dirname $file_or_dir) local dir=$(dirname $file_or_dir)
fi fi
export LANG=C
( (
cd $dir cd $dir
git log -1 --abbrev-commit --date=iso $file | git log -1 --abbrev-commit --date=iso $file |
awk -v nl="$nl" \ awk -v nl="$nl" \
' BEGIN { commit = "" } ' BEGIN { commit = ""; d[1] = "" }
/^commit/ { if ( commit == "") commit = $2 } /^commit/ { if ( commit == "") commit = $2 }
/^Date:/ { split( $2, d, "-") /^Date:/ { if (d[1] == "") {
split( $2, d, "-")
split( $3, t, ":") split( $3, t, ":")
} }
}
END { printf( "%s%s%s%s%s_%s%s", END { printf( "%s%s%s%s%s_%s%s",
substr( d[1],3), d[2], d[3], substr( d[1],3), d[2], d[3],
t[1], t[2], t[1], t[2],
@ -47,30 +50,31 @@ function git_id
function fix_alphatag() function fix_alphatag()
# Patch version on top comment first id line: # Patch version on top comment first id line:
# Usage: fix_alphatag <file> <version> <commit_id> # Usage: fix_alphatag <file> <version> <commit_id> <release>
# Patches:\ # Patches:\
# * Fri Sep 24 2010 name surname <email@com> 1.20100925_faf23207 # * Fri Sep 24 2010 name surname <email@com> 1.20100925_faf23207
{ {
dist=$(rpm --eval %dist) local dist=$(rpm --eval %dist)
awk -v dist="$dist" -v version="$2" -v release="$3" \ awk -v dist="$dist" -v version="$2" -v commit="$3" -v release="$4" \
' BEGIN { done = 0 } ' BEGIN { done = 0 }
/^[*]/ { if (done) /^[*]/ { if (done)
print print
else else
{ {
gsub( "1[.].*", "") s = sprintf( "-%s.%s%s\n", release, commit, dist)
printf( "%s%s-1.%s%s\n", gsub( "-[0-9][.][^ ]*$", s)
$0, version, release,dist)
done = 1 done = 1
# add new gsub for version...
print
} }
next next
} }
{ print }' \ { print }' < $1 > $1.tmp && mv -f $1.tmp $1
< $1 > $1.tmp && mv -f $1.tmp $1
} }
function fix_bundle_deps function fix_bundle_deps
# usage: fix_bundle_deps <specfile> <version> <release> # usage: fix_bundle_deps <specfile> <version> <commit>
# Patches: Requires: diaspora-bundle = 0.0-20101021-aefsf323148 # Patches: Requires: diaspora-bundle = 0.0-20101021-aefsf323148
{ {
awk -v vers="$2-$3" \ awk -v vers="$2-$3" \
@ -84,17 +88,18 @@ function fix_bundle_deps
< $1 > $1.tmp && mv -f $1.tmp $1 < $1 > $1.tmp && mv -f $1.tmp $1
} }
function patch() function patch()
# Patch spec-files with current version-release # Patch spec-files with current version-release
# Usage: patch VERSION RELEASE # Usage: patch <version> <commit> <release>
{ {
sed -e "/^%define/s|HEAD|$2|" \ sed -e "/^%define/s|HEAD|$2|" \
-e '/^Version:/s|.*|Version: '$1'|' \ -e '/^Version:/s|.*|Version: '$1'|' \
<diaspora.spec >dist/diaspora.spec <diaspora.spec >dist/diaspora.spec
fix_alphatag dist/diaspora.spec $1 $2 fix_alphatag dist/diaspora.spec $1 $2 $3
bundle_id=$(git_id dist/diaspora/Gemfile) local bundle_id=$(git_id dist/diaspora/Gemfile)
dist_tag=$(rpm --eval %dist) local dist_tag=$(rpm --eval %dist)
fix_bundle_deps dist/diaspora.spec $1 "1.${bundle_id}$dist_tag" fix_bundle_deps dist/diaspora.spec $1 "$RELEASE.${bundle_id}$dist_tag"
sed -e "/^%define/s|HEAD|$bundle_id|" \ sed -e "/^%define/s|HEAD|$bundle_id|" \
-e '/^Version:/s|.*|Version: '$1'|' \ -e '/^Version:/s|.*|Version: '$1'|' \
< diaspora-bundle.spec > dist/diaspora-bundle.spec < diaspora-bundle.spec > dist/diaspora-bundle.spec
@ -102,14 +107,21 @@ function patch()
cp dist/diaspora.spec dist/diaspora/diaspora.spec cp dist/diaspora.spec dist/diaspora/diaspora.spec
} }
function checkout() function checkout()
# Checkout last version of diaspora unless it's already there. # Checkout last version of diaspora unless it's already there.
# Usage: checkout [commit id, defaults to HEAD] # Usage: checkout [commit id, defaults to HEAD]
# Returns: commit for current branch's HEAD. # Returns: commit for current branch's HEAD.
{ {
mkdir dist >/dev/null 2>&1 || : mkdir dist &>/dev/null || :
( (
local last_repo=''
cd dist cd dist
test -e '.last-repo' &&
last_repo=$( cat '.last-repo')
test "$last_repo" != $GIT_REPO &&
rm -rf diaspora
test -d diaspora || { test -d diaspora || {
git clone --quiet $GIT_REPO; git clone --quiet $GIT_REPO;
( (
@ -118,9 +130,11 @@ function checkout()
git://github.com/diaspora/diaspora.git git://github.com/diaspora/diaspora.git
for p in ../../*.patch; do for p in ../../*.patch; do
git apply --whitespace=fix $p > /dev/null git apply --whitespace=fix $p > /dev/null
done done &> /dev/null || :
) )
} }
echo -n "$GIT_REPO" > '.last-repo'
cd diaspora; cd diaspora;
git fetch --quiet upstream git fetch --quiet upstream
git merge --quiet upstream/master git merge --quiet upstream/master
@ -130,45 +144,46 @@ function checkout()
} }
function make_dist function make_src
# Create a distribution tarball # Create a distribution tarball
# Usage: make dist [ commit, defaults to HEAD] # Usage: make src <commit>
{ {
echo "Using repo: $GIT_REPO"
commit=$(checkout ${1:-'HEAD'}) commit=$(checkout ${1:-'HEAD'})
echo "Creating source tarball for $commit" echo "Commit id: $commit"
patch $VERSION $commit
RELEASE_DIR="diaspora-$VERSION-$commit" RELEASE_DIR="diaspora-$VERSION-$commit"
rm -rf dist/${RELEASE_DIR} rm -rf dist/${RELEASE_DIR}
mkdir dist/${RELEASE_DIR} mkdir dist/${RELEASE_DIR}
cp diaspora-ws diaspora-setup diaspora.logconf dist/${RELEASE_DIR}
cd dist cd dist
mkdir ${RELEASE_DIR}/master mkdir ${RELEASE_DIR}/master
cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master cp -ar diaspora/* diaspora/.git* ${RELEASE_DIR}/master
mv ${RELEASE_DIR}/master/diaspora.spec ${RELEASE_DIR} mv ${RELEASE_DIR}/master/diaspora.spec ${RELEASE_DIR}
( (
cd ${RELEASE_DIR}; cd ${RELEASE_DIR}/master
find . -name .gitkeep -delete git show --name-only > config/gitversion
cd master tar cf public/source.tar \
--exclude='source.tar' -X .gitignore *
find $PWD -name .git\* | xargs rm -rf
rm -rf .bundle rm -rf .bundle
git apply ../../../add-bundle.patch /usr/bin/patch -p1 -s <../../../add-bundle.diff
) )
tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \ tar czf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR} && \
rm -rf ${RELEASE_DIR} rm -rf ${RELEASE_DIR}
cd .. cd ..
echo "Source: dist/${RELEASE_DIR}.tar.gz" echo "Source: dist/${RELEASE_DIR}.tar.gz"
echo "Required bundle: $(git_id dist/diaspora/Gemfile)" echo "Required bundle: $(git_id dist/diaspora/Gemfile)"
echo "Source specfile: dist/diaspora.spec"
echo "Bundle specfile: dist/diaspora-bundle.spec"
} }
function make_bundle() function make_bundle()
# Create the bundle tarball # Create the bundle tarball
# Usage: make_bundle [ commit, defaults to HEAD] # Usage: make_bundle [ commit, defaults to HEAD]
# #
{ {
checkout ${1:-'HEAD'} >/dev/null checkout ${1:-'HEAD'} >/dev/null
bundle_id=$(git_id dist/diaspora/Gemfile) bundle_id=$( git_id dist/diaspora/Gemfile)
bundle_name="diaspora-bundle-$VERSION-$bundle_id" bundle_name="diaspora-bundle-$VERSION-$bundle_id"
test -e "dist/$bundle_name.tar.gz" || { test -e "dist/$bundle_name.tar.gz" || {
echo "Creating bundle $bundle_name" echo "Creating bundle $bundle_name"
@ -184,85 +199,122 @@ function make_bundle()
"../$bundle_name" "../$bundle_name"
popd > /dev/null popd > /dev/null
tar czf $bundle_name.tar.gz $bundle_name tar czf $bundle_name.tar.gz $bundle_name
rm -rf $bundle_name
cd .. cd ..
} }
echo echo
echo "Bundle: dist/$bundle_name.tar.gz" echo "Bundle: dist/$bundle_name.tar.gz"
} }
function make_links()
# Usage: make_links [source commit] function prepare_rpm()
# Usage: prepare_rpm < commit>
{ {
dest=$(rpm --eval %_sourcedir) local dest=$(rpm --eval %_sourcedir)
test -z "$dest" && { test -z "$dest" && {
echo "Can't find RPM source directory, giving up." echo "Can't find RPM source directory, giving up."
exit 2 exit 2
} }
echo "Linking sources to $dest"
src_commit="${1:-$( checkout)}" local commit=$( checkout $1)
echo "Release: $RELEASE.$commit"
echo "Rpm source dir: $dest"
src="dist/diaspora-$VERSION-$src_commit.tar.gz" patch $VERSION $commit $RELEASE
local src="dist/diaspora-$VERSION-$commit.tar.gz"
test -e $src ||
cat <<- EOF
Warning: $src does not exist
(last version not built?)
EOF
ln -sf $PWD/$src $dest ln -sf $PWD/$src $dest
bundle_commit=$(git_id dist/diaspora/Gemfile) local bundle_commit=$( git_id dist/diaspora/Gemfile)
bundle="dist/diaspora-bundle-$VERSION-$bundle_commit.tar.gz" local bundle="dist/diaspora-bundle-$VERSION-$bundle_commit.tar.gz"
test -e $bundle ||
cat <<- EOF
Warning: $bundle does not exist
(last version not built?)
EOF
ln -sf $PWD/$bundle $dest ln -sf $PWD/$bundle $dest
local file
for file in $( grep -v '^#' SOURCES); do for file in $( grep -v '^#' SOURCES); do
if [ -e "$file" ]; then
ln -sf $PWD/$file $dest/$file ln -sf $PWD/$file $dest/$file
else
echo "Warning: $file (listed in SOURCES) does not exist"
fi
done done
cd $dest ( cd $dest; find . -type l -not -readable -exec rm {} \;)
find . -type l -not -readable -exec rm {} \; echo "Source specfile: dist/diaspora.spec"
echo "Bundle specfile: dist/diaspora-bundle.spec"
} }
function usage() function usage()
{ {
cat <<- EOF cat <<- EOF
Usage: make-dist [-c commit] <dist|bundle|links> Usage: make-dist [options] <dist|bundle|prepare>
-c Use a given commit, defaults to last checked in. Options:
dist Build a diaspora application tarball.
-h Print this message.
-c commit Use a given commit, defaults to last checked in.
-r release Mark with specified release, defaults to 1.
-u uri Git repository URI, defaults to
$GIT_REPO.
source Build a diaspora application tarball.
bundle Build a bundler(1) bundle for diaspora. bundle Build a bundler(1) bundle for diaspora.
links Symlink bundle and source tarballs to rpm source dir. prepare Symlink bundle and source tarballs to rpm source dir,
create patched rpm spec files.
All results are stored in dist/ All results are stored in dist/
EOF EOF
} }
test "$1" = "-h" -o $# = 0 && { commit='HEAD'
usage; while getopts ":r:c:h" opt
do
case $opt in
u) GIT_REPO="$OPTARG"
;;
c) commit="${OPTARG:0:7}"
;;
r) RELEASE="$OPTARG:"
;;
h) usage
exit 0 exit 0
} ;;
*) usage
exit 2
;;
esac
done
shift $(($OPTIND - 1))
test "$1" = "-c" && { typeset -r GIT_REPO RELEASE
test -z "$2" && { export LANG=C
test $# -gt 1 -o $# -eq 0 && {
usage; usage;
exit 1 exit 2;
}
commit="$2"
shift; shift
} }
case $1 in case $1 in
"bundle") make_bundle $commit "bundle") make_bundle $commit
;; ;;
'source') make_src $commit
'source') make_dist $commit
;; ;;
'prepare') prepare_rpm $commit $release
'links') make_links $commit
;; ;;
"fix_gemfile")
fix_gemfile
;;
*) usage *) usage
exit 1 exit 1
;; ;;

52
pkg/fedora/make_rel_symlink.py Executable file
View file

@ -0,0 +1,52 @@
#!/usr/bin/env python
import os
import os.path
import sys
import pdb
import shutil
def relative_ln_s( from_, to_ ):
"""
This is just so dirty & boring: create a relative symlink, making the
to_ path relative to from_. No errorchecks. Both arguments must be
files, a destination directory doesn't work (I think). An existing
file in to_ will be removed.
"""
prefix = os.path.commonprefix( [ to_, from_ ] )
if prefix == '':
prefix = '/'
source = from_.split( prefix )[ 1 ]
dest = to_.split( prefix )[ 1 ]
level = len( dest.split( '/' ) ) - 1
path = ( '../' * level ) + source
return path
USAGE = 'Usage: make_rel_symlink [-p] <sourcefile> <destfile>'
just_print = False;
if sys.argv[1] == "-p":
just_print = True;
sys.argv = sys.argv[ 1:]
if len( sys.argv ) != 3:
print USAGE
sys.exit( 1 )
if os.path.isdir( sys.argv[2] ):
print "Removing link target dir:" + sys.argv[2]
shutil.rmtree( sys.argv[2])
link_path = relative_ln_s( sys.argv[1], sys.argv[2] )
if just_print:
print link_path
else:
os.chdir( os.path.dirname( sys.argv[2]))
target = os.path.basename( sys.argv[2])
if os.path.exists( target ):
os.unlink( target)
os.symlink( link_path, target)

View file

@ -28,6 +28,7 @@ $(document).ready(function(){
//buttons////// //buttons//////
$("#add_aspect_button").fancybox({ 'titleShow' : false }); $("#add_aspect_button").fancybox({ 'titleShow' : false });
$("#add_request_button").fancybox({ 'titleShow': false }); $("#add_request_button").fancybox({ 'titleShow': false });
$("#invite_user_button").fancybox({ 'titleShow': false });
$(".add_request_button").fancybox({ 'titleShow': false }); $(".add_request_button").fancybox({ 'titleShow': false });
$("input[type='submit']").addClass("button"); $("input[type='submit']").addClass("button");
@ -72,7 +73,7 @@ $.fn.clearForm = function() {
$("#publisher .broadcast").live("click", function(evt){ $("#publisher .broadcast").live("click", function(evt){
evt.preventDefault(); evt.preventDefault();
if( confirm("Broadcast to the world?") ) { if( confirm("Publish to Diaspora and Facebook?") ) {
$("#status_message_public").val("true"); $("#status_message_public").val("true");
$(this).submit(); $(this).submit();
} }

View file

@ -115,7 +115,7 @@ describe Person do
end end
end end
describe 'searching' do describe '::search' do
before do before do
@friend_one = Factory.create(:person) @friend_one = Factory.create(:person)
@friend_two = Factory.create(:person) @friend_two = Factory.create(:person)
@ -159,6 +159,11 @@ describe Person do
people.include?(@friend_three).should == false people.include?(@friend_three).should == false
end end
it 'should yield results on full names' do
people = Person.search("Casey Grippi")
people.should == [@friend_four]
end
it 'should search by diaspora_handle exactly' do it 'should search by diaspora_handle exactly' do
stub_success("tom@tom.joindiaspora.com") stub_success("tom@tom.joindiaspora.com")
Person.by_webfinger(@friend_one.diaspora_handle).should == @friend_one Person.by_webfinger(@friend_one.diaspora_handle).should == @friend_one

View file

@ -0,0 +1,35 @@
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
require 'spec_helper'
describe User do
let!(:invited_user) { create_user_with_invitation("abc")}
context "the acceptance of an invitation" do
it "should create the person with the passed in params" do
Person.count.should be 0
u = invited_user.accept_invitation!(:invitation_token => "abc",
:username => "user",
:password => "secret",
:password_confirmation => "secret",
:person => {:profile => {:first_name => "Bob",
:last_name => "Smith"}} )
Person.count.should be 1
u.person.profile.first_name.should == "Bob"
end
end
end
def create_user_with_invitation(invitation_token, attributes={})
user = User.new({:password => nil, :password_confirmation => nil}.update(attributes))
#puts user.inspect
#user.skip_confirmation!
user.invitation_token = invitation_token
user.invitation_sent_at = Time.now.utc
user.save(:validate => false)
user
end

0
tmp/.gitkeep Normal file
View file