Merge branch 'master' of github.com:diaspora/diaspora into production
This commit is contained in:
commit
2e8ecceaf7
26 changed files with 234 additions and 57 deletions
5
Gemfile
5
Gemfile
|
|
@ -28,9 +28,12 @@ gem 'redfinger', :git => 'git://github.com/rsofaer/redfinger.git'
|
|||
|
||||
#EventMachine
|
||||
gem 'em-http-request',:git => 'git://github.com/igrigorik/em-http-request.git', :require => 'em-http'
|
||||
gem 'em-websocket'
|
||||
gem 'thin'
|
||||
|
||||
#Websocket
|
||||
gem 'em-websocket'
|
||||
gem 'magent', :git => 'http://github.com/dcu/magent.git'
|
||||
|
||||
#File uploading
|
||||
gem 'carrierwave', :git => 'git://github.com/rsofaer/carrierwave.git' , :branch => 'master' #Untested mongomapper branch
|
||||
gem 'mini_magick'
|
||||
|
|
|
|||
10
Gemfile.lock
10
Gemfile.lock
|
|
@ -47,6 +47,14 @@ GIT
|
|||
bcrypt-ruby (~> 2.1.2)
|
||||
warden (~> 0.10.7)
|
||||
|
||||
GIT
|
||||
remote: http://github.com/dcu/magent.git
|
||||
revision: 06513f3dac812469a55f2e365c349af4d2abc92a
|
||||
specs:
|
||||
magent (0.4.2)
|
||||
mongo (>= 0.1.0)
|
||||
uuidtools (>= 2.0.0)
|
||||
|
||||
GIT
|
||||
remote: http://github.com/jnunemaker/mongomapper.git
|
||||
revision: 931dab779011aa7acf60c1a4c7ad19e1ba838345
|
||||
|
|
@ -213,6 +221,7 @@ GEM
|
|||
treetop (1.4.8)
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.23)
|
||||
uuidtools (2.1.1)
|
||||
warden (0.10.7)
|
||||
rack (>= 1.0.0)
|
||||
webmock (1.3.5)
|
||||
|
|
@ -242,6 +251,7 @@ DEPENDENCIES
|
|||
haml
|
||||
jnunemaker-validatable (= 1.8.4)!
|
||||
json
|
||||
magent!
|
||||
mini_magick
|
||||
mocha
|
||||
mongo_mapper (= 0.8.4)!
|
||||
|
|
|
|||
23
README.md
23
README.md
|
|
@ -12,6 +12,13 @@ GEMS: We would like to keep external dependencies unduplicated. We're using No
|
|||
The privacy aware, personally controlled, do-it-all, open source social network.
|
||||
|
||||
**DISCLAIMER: THIS IS PRE-ALPHA SOFTWARE AND SHOULD BE TREATED ACCORDINGLY.**
|
||||
**PLEASE, DO NOT RUN IN PRODUCTION. IT IS FUN TO GET RUNNING, BUT EXPECT THINGS TO BE BROKEN**
|
||||
|
||||
Also, we really want to continue to focus on features and improving the code base. When we think it is
|
||||
ready for general use, we will post more detailed instructions.
|
||||
|
||||
|
||||
|
||||
These instructions are for machines running [Ubuntu](http://www.ubuntu.com/), [Fedora](http://www.fedoraproject.org) 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
|
||||
|
|
@ -147,13 +154,13 @@ To install Git on **Mac OS X**, run the following:
|
|||
|
||||
### Rubygems
|
||||
|
||||
On **Ubuntu**, run the following:
|
||||
On **Ubuntu** 10.04, run the following:
|
||||
|
||||
wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
|
||||
tar -xf rubygems-1.3.7.tgz
|
||||
cd rubygems-1.3.7
|
||||
sudo ruby setup.rb
|
||||
sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
|
||||
sudo add-apt-repository ppa:maco.m/ruby
|
||||
sudo apt-get update
|
||||
sudo apt-get install rubygems
|
||||
|
||||
This PPA is maintained by an Ubuntu Developer. For Ubuntu 10.10, this version of rubygems is in the repositories.
|
||||
|
||||
On **Fedora**, run the following:
|
||||
|
||||
|
|
@ -164,7 +171,7 @@ On **Mac OS X**, RubyGems comes preinstalled; however, you might need to update
|
|||
|
||||
### Bundler
|
||||
|
||||
After RubyGems is updated, simply run `sudo gem install bundler` to get Bundler.
|
||||
After RubyGems is updated, simply run `sudo gem install bundler` to get Bundler. If you're using Ubuntu repository .debs, bundler is found at /var/lib/gems/1.8/bin/bundle
|
||||
|
||||
|
||||
## Getting Diaspora
|
||||
|
|
@ -184,6 +191,8 @@ If you installed the Ubuntu package, MongoDB should already be running (if not,
|
|||
|
||||
If you installed the Fedora package, MongoDB will need to be started via `service mongodb start`. If you installed the binary manually, run `sudo mongod` from where mongo is installed to start mongo.
|
||||
|
||||
If you installed the OsX package through "brew", MongoDB will need to be started via `sudo launchctl load /Library/LaunchDaemons/org.mongodb.mongod.plist`. (before you have to go to /Library/LaunchDaemons and add a symlink to /usr/local/Cellar/mongodb/1.6.2-x86_64/org.mongodb.mongod.plist)
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class AspectsController < ApplicationController
|
|||
|
||||
def manage
|
||||
@aspect = :manage
|
||||
@remote_requests = Request.for_user current_user
|
||||
@remote_requests = Request.for_user(current_user).all
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class SocketsController < ApplicationController
|
|||
|
||||
def outgoing(uid,object,opts={})
|
||||
@_request = ActionDispatch::Request.new({})
|
||||
Diaspora::WebSocket.push_to_user(uid, action_hash(uid, object, opts))
|
||||
Diaspora::WebSocket.queue_to_user(uid, action_hash(uid, object, opts))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ class Person
|
|||
local_person
|
||||
elsif !identifier.include?("localhost") && !opts[:local]
|
||||
begin
|
||||
puts "begin finger"
|
||||
f = Redfinger.finger(identifier)
|
||||
rescue SocketError => e
|
||||
raise "Diaspora server for #{identifier} not found" if e.message =~ /Name or service not known/
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
|
||||
class Post
|
||||
require 'lib/diaspora/websocket'
|
||||
require 'lib/encryptable'
|
||||
include MongoMapper::Document
|
||||
include ApplicationHelper
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ class Request
|
|||
validates_presence_of :destination_url, :callback_url
|
||||
before_validation :clean_link
|
||||
|
||||
scope :for_user, lambda{ |user| where(:destination_url => user.person.receive_url) }
|
||||
scope :from_user, lambda{ |user| where(:destination_url.ne => user.person.receive_url) }
|
||||
scope :for_user, lambda{ |user| where(:destination_url => user.receive_url) }
|
||||
scope :from_user, lambda{ |user| where(:destination_url.ne => user.receive_url) }
|
||||
|
||||
def self.instantiate(options = {})
|
||||
person = options[:from]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
Requests
|
||||
|
||||
.requests
|
||||
%ul
|
||||
%ul.dropzone
|
||||
- for request in @remote_requests
|
||||
%li.requested_person{:id => request.person.id, :request_id => request.id}
|
||||
= person_image_tag(request.person)
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
Ignore/Remove
|
||||
|
||||
%li.remove
|
||||
%ul
|
||||
%ul.dropzone
|
||||
|
||||
- content_for :publish do
|
||||
= link_to("add a new aspect", "#add_aspect_pane", :id => "add_aspect_button", :class => "new_aspect button", :title => "Add a new aspect")
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
%h5 DEBUG INFO
|
||||
#debug_more{ :style => "display:none;" }
|
||||
%ul
|
||||
%li
|
||||
%b
|
||||
= GIT_INFO
|
||||
%li
|
||||
%b params
|
||||
= params.inspect
|
||||
|
|
@ -14,3 +17,4 @@
|
|||
%b websocket status
|
||||
#debug
|
||||
.msg
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ development:
|
|||
debug: false
|
||||
socket_debug : false
|
||||
socket_port: 8080
|
||||
socket_collection_name: 'websocket'
|
||||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||
|
||||
test:
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
require File.expand_path('../boot', __FILE__)
|
||||
|
||||
require "action_controller/railtie"
|
||||
require "action_mailer/railtie"
|
||||
require "active_resource/railtie"
|
||||
require 'action_controller/railtie'
|
||||
require 'action_mailer/railtie'
|
||||
require 'active_resource/railtie'
|
||||
# If you have a Gemfile, require the gems listed there, including any gems
|
||||
# you've limited to :test, :development, or :production.
|
||||
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
||||
|
|
|
|||
|
|
@ -53,6 +53,11 @@ namespace :deploy do
|
|||
task :start do
|
||||
start_mongo
|
||||
start_thin
|
||||
start_websocket
|
||||
end
|
||||
|
||||
task :start_websocket do
|
||||
run("cd #{current_path} && bundle exec ruby ./script/websocket_server.rb > /dev/null&")
|
||||
end
|
||||
|
||||
task :start_mongo do
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
# Load the rails application
|
||||
require File.expand_path('../application', __FILE__)
|
||||
Haml::Template.options[:format] = :html5
|
||||
Haml::Template.options[:escape_html] = true
|
||||
# Initialize the rails application
|
||||
Diaspora::Application.initialize!
|
||||
|
||||
|
|
|
|||
6
config/initializers/git_info.rb
Normal file
6
config/initializers/git_info.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
|
||||
GIT_INFO = `git show`
|
||||
|
|
@ -7,11 +7,11 @@
|
|||
|
||||
|
||||
|
||||
require "#{File.dirname(__FILE__)}/packages/essential"
|
||||
require "#{File.dirname(__FILE__)}/packages/database"
|
||||
require "#{File.dirname(__FILE__)}/packages/server"
|
||||
require "#{File.dirname(__FILE__)}/packages/scm"
|
||||
require "#{File.dirname(__FILE__)}/packages/ruby"
|
||||
require '#{File.dirname(__FILE__)}/packages/essential'
|
||||
require '#{File.dirname(__FILE__)}/packages/database'
|
||||
require '#{File.dirname(__FILE__)}/packages/server'
|
||||
require '#{File.dirname(__FILE__)}/packages/scm'
|
||||
require '#{File.dirname(__FILE__)}/packages/ruby'
|
||||
|
||||
policy :diaspora, :roles => [:pivots] do
|
||||
# requires :clean_dreamhost
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@
|
|||
|
||||
module Diaspora
|
||||
module WebSocket
|
||||
def self.queue_to_user(uid, data)
|
||||
channel = Magent::GenericChannel.new('websocket')
|
||||
channel.enqueue({:uid => uid, :data => data})
|
||||
end
|
||||
|
||||
def self.initialize_channels
|
||||
@channels = {}
|
||||
end
|
||||
|
|
@ -44,6 +49,5 @@ module Diaspora
|
|||
def unsocket_from_uid(id, opts={})
|
||||
SocketsController.new.outgoing(id, Retraction.for(self), opts)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ namespace :db do
|
|||
return this.diaspora_handle.charAt(this.diaspora_handle.length-1) == '@'
|
||||
}")
|
||||
|
||||
puts "Found #{people.count} people with broken diaspora_handle fields"
|
||||
people.each do |person|
|
||||
if person.owner
|
||||
puts "Resetting diaspora handle for #{person.owner.username}"
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ $(function() {
|
|||
});
|
||||
|
||||
$(".aspect ul").droppable({
|
||||
hoverClass: 'active',
|
||||
drop: function(event, ui) {
|
||||
|
||||
if ($(ui.draggable[0]).hasClass('requested_person')){
|
||||
|
|
@ -69,6 +70,7 @@ $(function() {
|
|||
});
|
||||
|
||||
$(".remove ul").droppable({
|
||||
hoverClass: 'active',
|
||||
drop: function(event, ui) {
|
||||
|
||||
if ($(ui.draggable[0]).hasClass('requested_person')){
|
||||
|
|
@ -91,7 +93,7 @@ $(function() {
|
|||
});
|
||||
});
|
||||
|
||||
$(".aspect h1").live( 'click', function() {
|
||||
$(".aspect h1").live( 'focus', function() {
|
||||
|
||||
var $this = $(this);
|
||||
var id = $this.closest("li").children("ul").attr("id");
|
||||
|
|
|
|||
|
|
@ -262,6 +262,11 @@
|
|||
close.show();
|
||||
}
|
||||
|
||||
$("#fancybox-inner input[type='text'], #fancybox-inner textarea").focus(function() {
|
||||
$(document).unbind('keydown.fb');
|
||||
});
|
||||
|
||||
|
||||
fancybox_set_navigation();
|
||||
|
||||
$(window).bind("resize.fb", $.fancybox.center);
|
||||
|
|
@ -1074,4 +1079,4 @@
|
|||
fancybox_init();
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
})(jQuery);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -547,6 +547,10 @@ h1.big_text {
|
|||
border: 1px solid #cccccc;
|
||||
list-style: none;
|
||||
padding: 15px; }
|
||||
.aspect ul.dropzone.active,
|
||||
.requests ul.dropzone.active,
|
||||
.remove ul.dropzone.active {
|
||||
background-color: #fafafa; }
|
||||
.aspect .person,
|
||||
.aspect .requested_person,
|
||||
.requests .person,
|
||||
|
|
@ -597,3 +601,6 @@ h1.big_text {
|
|||
border: 1px solid #cccccc;
|
||||
border-bottom: none;
|
||||
padding: 3px 10px; }
|
||||
|
||||
#fancybox-close:hover {
|
||||
background-color: transparent; }
|
||||
|
|
|
|||
|
|
@ -711,6 +711,10 @@ h1.big_text
|
|||
:style none
|
||||
:padding 15px
|
||||
|
||||
&.active
|
||||
:background
|
||||
:color #fafafa
|
||||
|
||||
.person,
|
||||
.requested_person
|
||||
:display inline-block
|
||||
|
|
@ -752,3 +756,7 @@ h1.big_text
|
|||
:bottom none
|
||||
|
||||
:padding 3px 10px
|
||||
|
||||
#fancybox-close:hover
|
||||
:background
|
||||
:color transparent
|
||||
|
|
|
|||
|
|
@ -2,11 +2,24 @@
|
|||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require File.dirname(__FILE__) + '/../config/environment'
|
||||
require File.dirname(__FILE__) + '/../lib/diaspora/websocket'
|
||||
|
||||
require 'em-websocket'
|
||||
require 'eventmachine'
|
||||
require "lib/diaspora/websocket"
|
||||
EM.next_tick {
|
||||
CHANNEL = Magent::GenericChannel.new('websocket')
|
||||
def process_message
|
||||
if CHANNEL.queue_count > 0
|
||||
message = CHANNEL.dequeue
|
||||
if message
|
||||
Diaspora::WebSocket.push_to_user(message['uid'], message['data'])
|
||||
end
|
||||
EM.next_tick{ process_message}
|
||||
else
|
||||
EM::Timer.new(1){process_message}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
EM.run {
|
||||
Diaspora::WebSocket.initialize_channels
|
||||
|
||||
EventMachine::WebSocket.start(
|
||||
|
|
@ -22,5 +35,6 @@ require "lib/diaspora/websocket"
|
|||
ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) }
|
||||
}
|
||||
end
|
||||
process_message
|
||||
}
|
||||
|
||||
24
spec/lib/websocket_spec.rb
Normal file
24
spec/lib/websocket_spec.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe Diaspora::WebSocket do
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
@aspect = @user.aspect(:name => "losers")
|
||||
@post = @user.build_post(:status_message, :message => "hey", :to => @aspect.id)
|
||||
end
|
||||
|
||||
it 'should queue a job' do
|
||||
Diaspora::WebSocket.should_receive(:queue_to_user)
|
||||
@post.socket_to_uid(@user.id, :aspect_ids => @aspect.id)
|
||||
end
|
||||
|
||||
it 'The queued job should reach Magent' do
|
||||
Magent.should_receive(:push)
|
||||
@post.socket_to_uid(@user.id, :aspect_ids => @aspect.id)
|
||||
end
|
||||
|
||||
end
|
||||
96
ubuntu-setup.bash
Normal file
96
ubuntu-setup.bash
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
#!/bin/bash
|
||||
# Author : hemanth.hm@gmail.com
|
||||
# Site : www.h3manth.com
|
||||
# This script helps to setup diaspora.
|
||||
#
|
||||
|
||||
# Set extented globbing
|
||||
shopt -s extglob
|
||||
|
||||
# Check if the user has sudo privileges.
|
||||
[[ $( id -u) ]] && echo "$(whoami) has no sudo permissions on this machine" && exit 1
|
||||
|
||||
# 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.."
|
||||
(
|
||||
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 "."
|
||||
)
|
||||
echo "Done installing the gems.."
|
||||
|
||||
# Install blunder
|
||||
echo "Installing blunder.."
|
||||
sudo gem install bundler
|
||||
echo "Installed blunder.."
|
||||
|
||||
# Take a clone of Diaspora
|
||||
(
|
||||
echo "Clone diaspora source.."
|
||||
git clone http://github.com/diaspora/diaspora.git
|
||||
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