Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
26a4dc76a6
12 changed files with 245 additions and 137 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -17,3 +17,4 @@ public/uploads/*
|
|||
config/app_config.yml
|
||||
bin/*
|
||||
nbproject
|
||||
config/initializers/secret_token.rb
|
||||
|
|
|
|||
|
|
@ -26,11 +26,15 @@ class UsersController < ApplicationController
|
|||
|
||||
private
|
||||
def prep_image_url(params)
|
||||
url = APP_CONFIG[:pod_url].chop if APP_CONFIG[:pod_url][-1,1] == '/'
|
||||
if params[:profile][:image_url].empty?
|
||||
params[:profile].delete(:image_url)
|
||||
else
|
||||
url = APP_CONFIG[:pod_url].chop if APP_CONFIG[:pod_url][-1,1] == '/'
|
||||
params[:profile][:image_url] = url + params[:profile][:image_url]
|
||||
if /^http:\/\// =~ params[:profile][:image_url]
|
||||
params[:profile][:image_url] = params[:profile][:image_url]
|
||||
else
|
||||
params[:profile][:image_url] = url + params[:profile][:image_url]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -291,10 +291,4 @@ class User
|
|||
OpenSSL::PKey::RSA.new( serialized_private_key )
|
||||
end
|
||||
|
||||
def encryption_key= new_key
|
||||
raise TypeError unless new_key.class == OpenSSL::PKey::RSA
|
||||
serialized_private_key = new_key.export
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
5
config/initializers/check_session_secret.rb
Normal file
5
config/initializers/check_session_secret.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
unless File.exists?( File.join(Rails.root, 'config', 'initializers', 'secret_token.rb'))
|
||||
`rake generate:secret_token`
|
||||
require File.join(Rails.root, 'config', 'initializers', 'secret_token.rb')
|
||||
end
|
||||
|
||||
|
|
@ -8,4 +8,4 @@
|
|||
# If you change this key, all old signed cookies will become invalid!
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
Rails.application.config.secret_token = 'ea08916110cae7f10fe9e1f7c7cb8c1fee13c3c3bee35180ac3061c370bd9ad985f28fcf2eb5f5684d0d618855efdeb862918628e994ed3e7fc806777428ef40'
|
||||
Rails.application.config.secret_token = '3484b78b0f9d88f40cd44a20cf647140e5900632d0c9b85e1fd91dc539811d243f2f0756f791019c'
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace :db do
|
|||
|
||||
puts "Resetting the database for #{Rails.env}".upcase
|
||||
Rake::Task['db:purge'].invoke
|
||||
Rake::Task['db:seed:tom'].invoke
|
||||
Rake::Task['db:seed:dev'].invoke
|
||||
puts "Success!"
|
||||
end
|
||||
|
||||
|
|
|
|||
26
lib/tasks/generate_session_secret.rake
Normal file
26
lib/tasks/generate_session_secret.rake
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
namespace :generate do
|
||||
desc 'Generates a Session Secret Token'
|
||||
task :secret_token do
|
||||
|
||||
path = File.join(Rails.root, 'config', 'initializers', 'secret_token.rb')
|
||||
secret = ActiveSupport::SecureRandom.hex(40)
|
||||
File.open(path, 'w') do |f|
|
||||
f.write <<"EOF"
|
||||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Your secret key for verifying the integrity of signed cookies.
|
||||
# If you change this key, all old signed cookies will become invalid!
|
||||
# Make sure the secret is at least 30 characters and all random,
|
||||
# no regular words or you'll be exposed to dictionary attacks.
|
||||
Rails.application.config.secret_token = '#{secret}'
|
||||
EOF
|
||||
|
||||
puts "YAY!!"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
171
script/ubuntu-setup.bash
Executable file
171
script/ubuntu-setup.bash
Executable file
|
|
@ -0,0 +1,171 @@
|
|||
#!/bin/bash
|
||||
# Author : hemanth.hm@gmail.com
|
||||
# Site : www.h3manth.com
|
||||
# Contributions from: Mackenzie Morgan (maco) and Daniel Thomas (drt24)
|
||||
# This script helps to setup diaspora.
|
||||
#
|
||||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
# USAGE: ./script/ubuntu-setup.bash
|
||||
# Do NOT run this script as root.
|
||||
|
||||
# Set extented globbing
|
||||
shopt -s extglob
|
||||
|
||||
# fail on error
|
||||
set -e
|
||||
|
||||
[ "$(whoami)" == "root" ] && echo "Please do not run this script as root/sudo
|
||||
We need to do some actions as an ordinary user. We use sudo where necessary." && exit 1
|
||||
|
||||
# Check if the user has sudo privileges.
|
||||
sudo -v >/dev/null 2>&1 || { echo $(whoami) has no sudo privileges ; exit 1; }
|
||||
|
||||
# Check if universal repository is enabled
|
||||
grep -i universe /etc/apt/sources.list > /dev/null || \
|
||||
{ echo "Please enable universe repository" ; exit 1 ; }
|
||||
|
||||
# Make sure that we only install the latest version of packages
|
||||
sudo apt-get update
|
||||
|
||||
# Check if wget is installed
|
||||
test wget || { echo "Installing wget.." && sudo apt-get install wget \
|
||||
&& echo "Installed wget.." ; }
|
||||
|
||||
# Install build tools
|
||||
echo "Installing build tools.."
|
||||
sudo apt-get -y --no-install-recommends install \
|
||||
build-essential libxslt1.1 libxslt1-dev libxml2
|
||||
echo "..Done installing build tools"
|
||||
|
||||
# Install Ruby 1.8.7
|
||||
echo "Installing ruby-full Ruby 1.8.7.."
|
||||
sudo apt-get -y --no-install-recommends install ruby-full
|
||||
echo "..Done installing Ruby"
|
||||
|
||||
# Install Rake
|
||||
echo "Installing rake.."
|
||||
sudo apt-get -y --no-install-recommends install rake
|
||||
echo "..Done installing rake"
|
||||
|
||||
#Store the release name so we can use it here and later
|
||||
RELEASE=$(lsb_release -c | cut -f2)
|
||||
|
||||
# Get the current release and install mongodb
|
||||
if [ $RELEASE == "maverick" ]
|
||||
then
|
||||
#mongodb does not supply a repository for maverick yet so install
|
||||
# an older version from the ubuntu repositories
|
||||
if [ ! -f /usr/lib/libmozjs.so ]
|
||||
then
|
||||
echo "Lanchpad bug https://bugs.launchpad.net/ubuntu/+source/mongodb/+bug/557024
|
||||
has not been fixed using workaround:"
|
||||
echo "sudo ln -s /usr/lib/xulrunner-1.9.2.10/libmozjs.so /usr/lib/libmozjs.so"
|
||||
sudo ln -s /usr/lib/xulrunner-1.9.2.10/libmozjs.so /usr/lib/libmozjs.so
|
||||
fi
|
||||
|
||||
sudo apt-get -y --no-install-recommends install mongodb
|
||||
else
|
||||
lsb=$(lsb_release -rs)
|
||||
ver=${lsb//.+(0)/.}
|
||||
repo="deb http://downloads.mongodb.org/distros/ubuntu ${ver} 10gen"
|
||||
echo "Setting up MongoDB.."
|
||||
echo "."
|
||||
echo ${repo} | sudo tee -a /etc/apt/sources.list
|
||||
echo "."
|
||||
echo "Fetching keys.."
|
||||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
|
||||
echo "."
|
||||
sudo apt-get update
|
||||
echo "."
|
||||
sudo apt-get -y --no-install-recommends install mongodb-stable
|
||||
echo "Done installing monngodb-stable.."
|
||||
fi
|
||||
|
||||
# Install imagemagick
|
||||
echo "Installing imagemagick.."
|
||||
sudo apt-get -y --no-install-recommends install imagemagick libmagick9-dev
|
||||
echo "Installed imagemagick.."
|
||||
|
||||
# Install git-core
|
||||
echo "Installing git-core.."
|
||||
sudo apt-get -y --no-install-recommends install git-core
|
||||
echo "Installed git-core.."
|
||||
|
||||
# Setting up ruby gems
|
||||
echo "Fetching and installing ruby gems.."
|
||||
(
|
||||
if [ $RELEASE == "maverick" ]
|
||||
then
|
||||
sudo apt-get install --no-install-recommends -y rubygems
|
||||
sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
|
||||
elif [ $RELEASE == "lucid" ]
|
||||
then
|
||||
sudo add-apt-repository ppa:maco.m/ruby
|
||||
sudo apt-get update
|
||||
sudo apt-get install --no-install-recommends -y rubygems
|
||||
sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
|
||||
else
|
||||
# Old version
|
||||
echo "."
|
||||
cd /tmp
|
||||
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
|
||||
echo "."
|
||||
tar -xf rubygems-1.3.7.tgz
|
||||
echo "."
|
||||
cd rubygems-1.3.7
|
||||
echo "."
|
||||
sudo ruby setup.rb
|
||||
echo "."
|
||||
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
|
||||
echo "."
|
||||
fi
|
||||
)
|
||||
echo "Done installing the gems.."
|
||||
|
||||
# Install bundler
|
||||
echo "Installing bundler.."
|
||||
sudo gem install bundler
|
||||
echo "Installed bundler.."
|
||||
|
||||
# Take a clone of Diaspora
|
||||
(
|
||||
# Check if the user is already in a cloned source if not clone the source
|
||||
[[ $( basename $PWD ) == "diaspora" ]] && \
|
||||
echo "Already in diaspora directory" || \
|
||||
{ git clone http://github.com/diaspora/diaspora.git && cd diaspora
|
||||
echo "Cloned the source.."
|
||||
}
|
||||
|
||||
# Install extra gems
|
||||
echo "Installing more gems.."
|
||||
bundle install
|
||||
echo "Installed."
|
||||
|
||||
#Configure diaspora
|
||||
cp config/app_config.yml.example config/app_config.yml
|
||||
echo "You need to configure diaspora to tell it which URL it has.
|
||||
Opening editor in 5 seconds and then continuing with install."
|
||||
sleep 5
|
||||
#ensure EDITOR is set
|
||||
if [ -z "${EDITOR}"]
|
||||
then
|
||||
EDITOR=vi
|
||||
fi
|
||||
$EDITOR config/app_config.yml
|
||||
|
||||
# Create the shared directory which is used by rake db:seed:tom
|
||||
mkdir shared
|
||||
|
||||
# Install DB setup
|
||||
echo "Seting up DB.."
|
||||
rake db:seed:tom
|
||||
echo "DB ready. Login -> tom and password -> evankorth.
|
||||
More details ./diaspora/db/seeds/tom.rb."
|
||||
|
||||
# Run appserver
|
||||
echo "Starting server"
|
||||
bundle exec thin start
|
||||
)
|
||||
33
spec/controllers/users_controller_spec.rb
Normal file
33
spec/controllers/users_controller_spec.rb
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe UsersController do
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
sign_in :user, @user
|
||||
@user.aspect(:name => "lame-os")
|
||||
end
|
||||
|
||||
describe '#update' do
|
||||
context 'with a profile photo set' do
|
||||
before do
|
||||
@user.person.profile.image_url = "http://tom.joindiaspora.com/images/user/tom.jpg"
|
||||
@user.person.profile.save
|
||||
end
|
||||
|
||||
it "doesn't overwrite the profile photo when an empty string is passed in" do
|
||||
image_url = @user.person.profile.image_url
|
||||
put("update", :id => @user.id, "user"=> {"profile"=>
|
||||
{"image_url" => "",
|
||||
"last_name" => @user.person.profile.last_name,
|
||||
"first_name" => @user.person.profile.first_name}})
|
||||
|
||||
@user.person.profile.image_url.should == image_url
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -25,10 +25,6 @@ Factory.define :album do |p|
|
|||
p.person { |a| Factory.create(:person) }
|
||||
end
|
||||
|
||||
Factory.define :person_with_private_key, :parent => :person do |p|
|
||||
p.serialized_key OpenSSL::PKey::RSA.generate(1024).export
|
||||
end
|
||||
|
||||
Factory.define :user do |u|
|
||||
u.sequence(:username) {|n| "bob#{n}"}
|
||||
u.sequence(:email) {|n| "bob#{n}@pivotallabs.com"}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ describe MessageHandler do
|
|||
}
|
||||
end
|
||||
|
||||
it 'should only retry a bad request three times ' do
|
||||
it 'should only retry a bad request the correct number of times' do
|
||||
request = FakeHttpRequest.new(:failure)
|
||||
request.should_receive(:get).exactly(MessageHandler::NUM_TRIES).times.and_return(request)
|
||||
EventMachine::HttpRequest.stub!(:new).and_return(request)
|
||||
|
|
|
|||
|
|
@ -1,122 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Author : hemanth.hm@gmail.com
|
||||
# Site : www.h3manth.com
|
||||
# Contributions from: Mackenzie Morgan (maco) and Daniel Thomas (drt24)
|
||||
# This script helps to setup diaspora.
|
||||
#
|
||||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
# Set extented globbing
|
||||
shopt -s extglob
|
||||
|
||||
# Check if the user has sudo privileges.
|
||||
sudo -v >/dev/null 2>&1 || { echo $(whoami) has no sudo privileges ; exit 1; }
|
||||
|
||||
# Check if universal repository is enabled
|
||||
grep -i universe /etc/apt/sources.list > /dev/null || { echo "Please enable universe repository" ; exit 1 ; }
|
||||
|
||||
# Check if wget is installed
|
||||
test wget || echo "Installing wget.." && sudo apt-get install wget && echo "Installed wget.."
|
||||
|
||||
# Install build tools
|
||||
echo "Installing build tools.."
|
||||
sudo apt-get -y --no-install-recommends install build-essential libxslt1.1 libxslt1-dev libxml2
|
||||
echo "..Done installing build tools"
|
||||
|
||||
# Install Ruby 1.8.7
|
||||
echo "Installing ruby-full Ruby 1.8.7.."
|
||||
sudo apt-get -y --no-install-recommends install ruby-full
|
||||
echo "..Done installing Ruby"
|
||||
|
||||
# Install Rake
|
||||
echo "Installing rake.."
|
||||
sudo apt-get -y --no-install-recommends install rake
|
||||
echo "..Done installing rake"
|
||||
|
||||
# Get the current release and install mongodb
|
||||
lsb=$(lsb_release -rs)
|
||||
ver=${lsb//.+(0)/.}
|
||||
repo="deb http://downloads.mongodb.org/distros/ubuntu ${ver} 10gen"
|
||||
echo "Setting up MongoDB.."
|
||||
echo "."
|
||||
echo ${repo} | sudo tee -a /etc/apt/sources.list
|
||||
echo "."
|
||||
echo "Fetching keys.."
|
||||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
|
||||
echo "."
|
||||
sudo apt-get update
|
||||
echo "."
|
||||
sudo apt-get -y --no-install-recommends install mongodb-stable
|
||||
echo "Done installing monngodb-stable.."
|
||||
|
||||
# Install imagemagick
|
||||
echo "Installing imagemagick.."
|
||||
sudo apt-get -y --no-install-recommends install imagemagick libmagick9-dev
|
||||
echo "Installed imagemagick.."
|
||||
|
||||
# Install git-core
|
||||
echo "Installing git-core.."
|
||||
sudo apt-get -y --no-install-recommends install git-core
|
||||
echo "Installed git-core.."
|
||||
|
||||
# Setting up ruby gems
|
||||
echo "Fetching and installing ruby gems.."
|
||||
(
|
||||
RELEASE=$(lsb_release -c | cut -f2)
|
||||
if [ RELEASE == "maverick" ]
|
||||
then
|
||||
sudo apt-get install --no-install-recommends -y rubygems
|
||||
sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
|
||||
elif [ RELEASE == "lucid" ]
|
||||
then
|
||||
sudo add-apt-repository ppa:maco.m/ruby
|
||||
sudo apt-get update
|
||||
sudo apt-get install --no-install-recommends -y rubygems
|
||||
sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle #for PATH
|
||||
else
|
||||
# Old version
|
||||
echo "."
|
||||
cd /tmp
|
||||
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
|
||||
echo "."
|
||||
tar -xf rubygems-1.3.7.tgz
|
||||
echo "."
|
||||
cd rubygems-1.3.7
|
||||
echo "."
|
||||
sudo ruby setup.rb
|
||||
echo "."
|
||||
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
|
||||
echo "."
|
||||
fi
|
||||
)
|
||||
echo "Done installing the gems.."
|
||||
|
||||
# Install bundler
|
||||
echo "Installing bundler.."
|
||||
sudo gem install bundler
|
||||
echo "Installed bundler.."
|
||||
|
||||
# Take a clone of Diaspora
|
||||
(
|
||||
|
||||
# Check if the user is already in a cloned source if not clone the source
|
||||
[[ $( basename $PWD ) == "diaspora" ]] && echo "Already in diaspora directory" || git clone http://github.com/diaspora/diaspora.git ; cd diaspora
|
||||
echo "Cloned the source.."
|
||||
|
||||
# Install extra gems
|
||||
cd diaspora
|
||||
echo "Installing more gems.."
|
||||
sudo bundle install
|
||||
echo "Installed."
|
||||
|
||||
# Install DB setup
|
||||
echo "Seting up DB.."
|
||||
rake db:seed:tom
|
||||
echo "DB ready. Login -> tom and password -> evankorth. More details ./diaspora/db/seeds/tom.rb."
|
||||
|
||||
# Run appserver
|
||||
echo "Starting server"
|
||||
bundle exec thin start
|
||||
)
|
||||
Loading…
Reference in a new issue