From 22edec57766356cdc3d73740b65a557d2a6f57bd Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Fri, 17 Sep 2010 06:39:51 +0800 Subject: [PATCH 01/20] Adding Haml html escaping. Haml's HTML escaping option was not on, leaving the site open for xss attacks. This would seem to fix it. --- config/environment.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/environment.rb b/config/environment.rb index dc11087dd..385a96651 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -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! From c80a79dea5d0cc6b1e60bed82dce12bb18136c3d Mon Sep 17 00:00:00 2001 From: cryptix Date: Thu, 16 Sep 2010 21:13:39 +0800 Subject: [PATCH 02/20] Unified require quotes --- config/application.rb | 6 +++--- config/initializers/socket.rb | 2 +- config/sprinkle/provision.rb | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/application.rb b/config/application.rb index ef8a567a5..b409f91d3 100644 --- a/config/application.rb +++ b/config/application.rb @@ -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) diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index 1fd09fd93..0b1035001 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -5,7 +5,7 @@ require 'em-websocket' require 'eventmachine' -require "lib/diaspora/websocket" +require 'lib/diaspora/websocket' EM.next_tick { Diaspora::WebSocket.initialize_channels diff --git a/config/sprinkle/provision.rb b/config/sprinkle/provision.rb index 9f983399e..ce0fd7374 100644 --- a/config/sprinkle/provision.rb +++ b/config/sprinkle/provision.rb @@ -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 => [:tom,:backer] do # requires :clean_dreamhost From 4d8eb3d53241eec0df5d3dd5c0b372df5f5c3ad2 Mon Sep 17 00:00:00 2001 From: Guido Serra aka Zeph Date: Fri, 17 Sep 2010 05:56:47 +0800 Subject: [PATCH 03/20] issue #9 on github: missing OsX/MongoDB info --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9ae943073..7e1b75153 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,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 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 From d74c4bd1177fd02760a96ac6d9a189dcd37aa23f Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 16 Sep 2010 16:47:10 -0700 Subject: [PATCH 04/20] DG IZ; use focus instead of click --- public/javascripts/aspect-edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index e1d9b6c6c..1fbf355e9 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -91,7 +91,7 @@ $(function() { }); }); -$(".aspect h1").live( 'click', function() { +$(".aspect h1").live( 'focus', function() { var $this = $(this); var id = $this.closest("li").children("ul").attr("id"); From 04d55ef35e4acda726ad00ba58a55814cdf22c72 Mon Sep 17 00:00:00 2001 From: "hemanth.hm" Date: Thu, 16 Sep 2010 21:03:46 +0800 Subject: [PATCH 05/20] Added ubuntu setup script --- ubuntu-setup.bash | 96 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 ubuntu-setup.bash diff --git a/ubuntu-setup.bash b/ubuntu-setup.bash new file mode 100644 index 000000000..e197ed367 --- /dev/null +++ b/ubuntu-setup.bash @@ -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 root privilages +[ "$(whoami)" != "root" ] && echo "Please run this script as root/sudo" && exit 1 + +# Install build tools +echo "Installing build tools.." +sudo apt-get 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 install ruby-full +echo "..Done installing Ruby" + +# Install Rake +echo "Installing rake.." +sudo apt-get 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 install mongodb-stable +echo "Done installing monngodb-stable.." + +# Install imagemagick +echo "Installing imagemagick.." +sudo apt-get install imagemagick libmagick9-dev +echo "Installed imagemagick.." + +# Install git-core +echo "Installing git-core.." +sudo apt-get 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 +) From f76bc6ffc470ef84b34756d3ea64c3c32416136b Mon Sep 17 00:00:00 2001 From: hemanth Date: Thu, 16 Sep 2010 23:23:12 +0800 Subject: [PATCH 06/20] Updated all apt-get installs with apt-get -y to avoid prompts during installation. --- ubuntu-setup.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ubuntu-setup.bash b/ubuntu-setup.bash index e197ed367..47008ab34 100644 --- a/ubuntu-setup.bash +++ b/ubuntu-setup.bash @@ -12,17 +12,17 @@ shopt -s extglob # Install build tools echo "Installing build tools.." -sudo apt-get install build-essential libxslt1.1 libxslt1-dev libxml2 +sudo apt-get -y 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 install ruby-full +sudo apt-get -y install ruby-full echo "..Done installing Ruby" # Install Rake echo "Installing rake.." -sudo apt-get install rake +sudo apt-get -y install rake echo "..Done installing rake" # Get the current release and install mongodb @@ -38,17 +38,17 @@ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo "." sudo apt-get update echo "." -sudo apt-get install mongodb-stable +sudo apt-get -y install mongodb-stable echo "Done installing monngodb-stable.." # Install imagemagick echo "Installing imagemagick.." -sudo apt-get install imagemagick libmagick9-dev +sudo apt-get -y install imagemagick libmagick9-dev echo "Installed imagemagick.." # Install git-core echo "Installing git-core.." -sudo apt-get install git-core +sudo apt-get -y install git-core echo "Installed git-core.." # Setting up ruby gems From 87feb5bba52ce40c22c6047d56cff35831f0ad8b Mon Sep 17 00:00:00 2001 From: hemanth Date: Fri, 17 Sep 2010 01:50:01 +0800 Subject: [PATCH 07/20] Removed root check and added sudo check. --- ubuntu-setup.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubuntu-setup.bash b/ubuntu-setup.bash index 47008ab34..96c995646 100644 --- a/ubuntu-setup.bash +++ b/ubuntu-setup.bash @@ -8,7 +8,7 @@ shopt -s extglob # Check if the user has root privilages -[ "$(whoami)" != "root" ] && echo "Please run this script as root/sudo" && exit 1 +[[ $( id -u) ]] && echo "$(whoami) has no sudo permissions on this machine" && exit 1 # Install build tools echo "Installing build tools.." From e9df690644a9e82608d113793425496198b2fd1f Mon Sep 17 00:00:00 2001 From: hemanth Date: Fri, 17 Sep 2010 01:55:00 +0800 Subject: [PATCH 08/20] Added --no-install-recommends to apt-get to avoid additional extra packages. --- ubuntu-setup.bash | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ubuntu-setup.bash b/ubuntu-setup.bash index 96c995646..c0bceabeb 100644 --- a/ubuntu-setup.bash +++ b/ubuntu-setup.bash @@ -12,17 +12,17 @@ shopt -s extglob # Install build tools echo "Installing build tools.." -sudo apt-get -y install build-essential libxslt1.1 libxslt1-dev libxml2 +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 install ruby-full +sudo apt-get -y --no-install-recommends install ruby-full echo "..Done installing Ruby" # Install Rake echo "Installing rake.." -sudo apt-get -y install rake +sudo apt-get -y --no-install-recommends install rake echo "..Done installing rake" # Get the current release and install mongodb @@ -38,17 +38,17 @@ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10 echo "." sudo apt-get update echo "." -sudo apt-get -y install mongodb-stable +sudo apt-get -y --no-install-recommends install mongodb-stable echo "Done installing monngodb-stable.." # Install imagemagick echo "Installing imagemagick.." -sudo apt-get -y install imagemagick libmagick9-dev +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 install git-core +sudo apt-get -y --no-install-recommends install git-core echo "Installed git-core.." # Setting up ruby gems From 193deb97670bd55c94da68e86d1a3513ece1dbc9 Mon Sep 17 00:00:00 2001 From: hemanth Date: Fri, 17 Sep 2010 02:04:38 +0800 Subject: [PATCH 09/20] Corrected a comment # Check if the user has sudo privileges. --- ubuntu-setup.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubuntu-setup.bash b/ubuntu-setup.bash index c0bceabeb..67b602abe 100644 --- a/ubuntu-setup.bash +++ b/ubuntu-setup.bash @@ -7,7 +7,7 @@ # Set extented globbing shopt -s extglob -# Check if the user has root privilages +# Check if the user has sudo privileges. [[ $( id -u) ]] && echo "$(whoami) has no sudo permissions on this machine" && exit 1 # Install build tools From 3cf085c3c16a79548ccd828e31403d460ff50d32 Mon Sep 17 00:00:00 2001 From: maco Date: Fri, 17 Sep 2010 07:13:33 +0800 Subject: [PATCH 10/20] README.md: add PPA instructions for rubygems 1.3.7 for Ubuntu 10.04 --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7e1b75153..017ce85e6 100644 --- a/README.md +++ b/README.md @@ -147,13 +147,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: From 1e8834a8d5e8b266632c944cf34e8703c704c8a4 Mon Sep 17 00:00:00 2001 From: maco Date: Fri, 17 Sep 2010 07:25:21 +0800 Subject: [PATCH 11/20] README.md: add note about bundle's location with Ubuntu debs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 017ce85e6..8e3426250 100644 --- a/README.md +++ b/README.md @@ -164,7 +164,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 From 2dc0fc9965787d092214d4b54d64d733f3952f67 Mon Sep 17 00:00:00 2001 From: Guido Serra aka Zeph Date: Fri, 17 Sep 2010 06:24:30 +0800 Subject: [PATCH 12/20] wrong! fullpath required --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e3426250..d9ac44c94 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ 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 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) +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. From ae83dae1ca2ca651ef4bad7a968385be8756b5bc Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 16 Sep 2010 17:03:14 -0700 Subject: [PATCH 13/20] added git info (branch,date,author) to debug partial --- app/views/posts/_debug.haml | 4 ++++ config/initializers/git_info.rb | 6 ++++++ 2 files changed, 10 insertions(+) create mode 100644 config/initializers/git_info.rb diff --git a/app/views/posts/_debug.haml b/app/views/posts/_debug.haml index 27d508cf2..17d7baad8 100644 --- a/app/views/posts/_debug.haml +++ b/app/views/posts/_debug.haml @@ -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 + diff --git a/config/initializers/git_info.rb b/config/initializers/git_info.rb new file mode 100644 index 000000000..a6d767aa4 --- /dev/null +++ b/config/initializers/git_info.rb @@ -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` From b0c87fcffa507591242b27ee55be2c0fd86709b6 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 16 Sep 2010 17:04:59 -0700 Subject: [PATCH 14/20] Add a little more feedback to rake task --- lib/tasks/db.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index 22f995325..80e3bafe5 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -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}" From 95a4120e57681bb972a3b13e38d915f043c98a1f Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 16 Sep 2010 17:22:42 -0700 Subject: [PATCH 15/20] DG IZ; dropzones on left back on aspect manage page. --- app/views/aspects/manage.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/aspects/manage.html.haml b/app/views/aspects/manage.html.haml index 9a98b9d06..667196b85 100644 --- a/app/views/aspects/manage.html.haml +++ b/app/views/aspects/manage.html.haml @@ -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") From 755e2a744cd9f41412d727fe36cd5338700fc491 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 16 Sep 2010 17:30:49 -0700 Subject: [PATCH 16/20] DG IZ; dropzones now light up when dragging on aspect page --- public/javascripts/aspect-edit.js | 2 ++ public/stylesheets/application.css | 4 ++++ public/stylesheets/sass/application.sass | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index 1fbf355e9..86c61ba93 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -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')){ diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index f4c40f465..be025e2d7 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -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, diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 85c5f3cdc..7f7125c49 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -711,6 +711,10 @@ h1.big_text :style none :padding 15px + &.active + :background + :color #fafafa + .person, .requested_person :display inline-block From e668071ea51050ae79058978ddb9c01945df4279 Mon Sep 17 00:00:00 2001 From: maxwell Date: Thu, 16 Sep 2010 18:48:18 -0700 Subject: [PATCH 17/20] README.md --- README.md | 7 +++++++ app/controllers/aspects_controller.rb | 2 +- app/models/person.rb | 1 + app/models/request.rb | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d9ac44c94..d941ac182 100644 --- a/README.md +++ b/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 diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 88da5cc88..ab144ad12 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -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 diff --git a/app/models/person.rb b/app/models/person.rb index bed5bb246..48e8b0816 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -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/ diff --git a/app/models/request.rb b/app/models/request.rb index 739500e4e..da62edd93 100644 --- a/app/models/request.rb +++ b/app/models/request.rb @@ -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] From 292a38e6943b52abf2029faaecd17378495df51b Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 16 Sep 2010 18:55:54 -0700 Subject: [PATCH 18/20] DG IZ; arrow keys work in fancybox. removed background color change on close button on hover --- .../fancybox/jquery.fancybox-1.3.1.js | 7 ++++- .../fancybox/jquery.fancybox-1.3.1.pack.js | 31 ++----------------- public/stylesheets/application.css | 3 ++ public/stylesheets/sass/application.sass | 4 +++ 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/public/javascripts/fancybox/jquery.fancybox-1.3.1.js b/public/javascripts/fancybox/jquery.fancybox-1.3.1.js index 688f93aa3..e9b4f404b 100755 --- a/public/javascripts/fancybox/jquery.fancybox-1.3.1.js +++ b/public/javascripts/fancybox/jquery.fancybox-1.3.1.js @@ -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); \ No newline at end of file +})(jQuery); diff --git a/public/javascripts/fancybox/jquery.fancybox-1.3.1.pack.js b/public/javascripts/fancybox/jquery.fancybox-1.3.1.pack.js index 8421d53a6..8efd14070 100755 --- a/public/javascripts/fancybox/jquery.fancybox-1.3.1.pack.js +++ b/public/javascripts/fancybox/jquery.fancybox-1.3.1.pack.js @@ -14,31 +14,6 @@ * http://www.gnu.org/licenses/gpl.html */ -(function(b){var m,u,x,g,D,i,z,A,B,p=0,e={},q=[],n=0,c={},j=[],E=null,s=new Image,G=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,S=/[^\.]\.(swf)\s*$/i,H,I=1,k,l,h=false,y=b.extend(b("
")[0],{prop:0}),v=0,O=!b.support.opacity&&!window.XMLHttpRequest,J=function(){u.hide();s.onerror=s.onload=null;E&&E.abort();m.empty()},P=function(){b.fancybox('

The requested content cannot be loaded.
Please try again later.

',{scrolling:"no",padding:20,transitionIn:"none",transitionOut:"none"})}, -K=function(){return[b(window).width(),b(window).height(),b(document).scrollLeft(),b(document).scrollTop()]},T=function(){var a=K(),d={},f=c.margin,o=c.autoScale,t=(20+f)*2,w=(20+f)*2,r=c.padding*2;if(c.width.toString().indexOf("%")>-1){d.width=a[0]*parseFloat(c.width)/100-40;o=false}else d.width=c.width+r;if(c.height.toString().indexOf("%")>-1){d.height=a[1]*parseFloat(c.height)/100-40;o=false}else d.height=c.height+r;if(o&&(d.width>a[0]-t||d.height>a[1]-w))if(e.type=="image"||e.type=="swf"){t+=r; -w+=r;o=Math.min(Math.min(a[0]-t,c.width)/c.width,Math.min(a[1]-w,c.height)/c.height);d.width=Math.round(o*(d.width-r))+r;d.height=Math.round(o*(d.height-r))+r}else{d.width=Math.min(d.width,a[0]-t);d.height=Math.min(d.height,a[1]-w)}d.top=a[3]+(a[1]-(d.height+40))*0.5;d.left=a[2]+(a[0]-(d.width+40))*0.5;if(c.autoScale===false){d.top=Math.max(a[3]+f,d.top);d.left=Math.max(a[2]+f,d.left)}return d},U=function(a){if(a&&a.length)switch(c.titlePosition){case "inside":return a;case "over":return''+ -a+"";default:return''+a+''}return false},V=function(){var a=c.title,d=l.width-c.padding*2,f="fancybox-title-"+c.titlePosition;b("#fancybox-title").remove();v=0;if(c.titleShow!==false){a=b.isFunction(c.titleFormat)?c.titleFormat(a,j,n,c):U(a);if(!(!a||a==="")){b('
').css({width:d,paddingLeft:c.padding, -paddingRight:c.padding}).html(a).appendTo("body");switch(c.titlePosition){case "inside":v=b("#fancybox-title").outerHeight(true)-c.padding;l.height+=v;break;case "over":b("#fancybox-title").css("bottom",c.padding);break;default:b("#fancybox-title").css("bottom",b("#fancybox-title").outerHeight(true)*-1);break}b("#fancybox-title").appendTo(D).hide()}}},W=function(){b(document).unbind("keydown.fb").bind("keydown.fb",function(a){if(a.keyCode==27&&c.enableEscapeButton){a.preventDefault();b.fancybox.close()}else if(a.keyCode== -37){a.preventDefault();b.fancybox.prev()}else if(a.keyCode==39){a.preventDefault();b.fancybox.next()}});if(b.fn.mousewheel){g.unbind("mousewheel.fb");j.length>1&&g.bind("mousewheel.fb",function(a,d){a.preventDefault();h||d===0||(d>0?b.fancybox.prev():b.fancybox.next())})}if(c.showNavArrows){if(c.cyclic&&j.length>1||n!==0)A.show();if(c.cyclic&&j.length>1||n!=j.length-1)B.show()}},X=function(){var a,d;if(j.length-1>n){a=j[n+1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}if(n>0){a= -j[n-1].href;if(typeof a!=="undefined"&&a.match(G)){d=new Image;d.src=a}}},L=function(){i.css("overflow",c.scrolling=="auto"?c.type=="image"||c.type=="iframe"||c.type=="swf"?"hidden":"auto":c.scrolling=="yes"?"auto":"visible");if(!b.support.opacity){i.get(0).style.removeAttribute("filter");g.get(0).style.removeAttribute("filter")}b("#fancybox-title").show();c.hideOnContentClick&&i.one("click",b.fancybox.close);c.hideOnOverlayClick&&x.one("click",b.fancybox.close);c.showCloseButton&&z.show();W();b(window).bind("resize.fb", -b.fancybox.center);c.centerOnScroll?b(window).bind("scroll.fb",b.fancybox.center):b(window).unbind("scroll.fb");b.isFunction(c.onComplete)&&c.onComplete(j,n,c);h=false;X()},M=function(a){var d=Math.round(k.width+(l.width-k.width)*a),f=Math.round(k.height+(l.height-k.height)*a),o=Math.round(k.top+(l.top-k.top)*a),t=Math.round(k.left+(l.left-k.left)*a);g.css({width:d+"px",height:f+"px",top:o+"px",left:t+"px"});d=Math.max(d-c.padding*2,0);f=Math.max(f-(c.padding*2+v*a),0);i.css({width:d+"px",height:f+ -"px"});if(typeof l.opacity!=="undefined")g.css("opacity",a<0.5?0.5:a)},Y=function(a){var d=a.offset();d.top+=parseFloat(a.css("paddingTop"))||0;d.left+=parseFloat(a.css("paddingLeft"))||0;d.top+=parseFloat(a.css("border-top-width"))||0;d.left+=parseFloat(a.css("border-left-width"))||0;d.width=a.width();d.height=a.height();return d},Q=function(){var a=e.orig?b(e.orig):false,d={};if(a&&a.length){a=Y(a);d={width:a.width+c.padding*2,height:a.height+c.padding*2,top:a.top-c.padding-20,left:a.left-c.padding- -20}}else{a=K();d={width:1,height:1,top:a[3]+a[1]*0.5,left:a[2]+a[0]*0.5}}return d},N=function(){u.hide();if(g.is(":visible")&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){b.event.trigger("fancybox-cancel");h=false;return}j=q;n=p;c=e;i.get(0).scrollTop=0;i.get(0).scrollLeft=0;if(c.overlayShow){O&&b("select:not(#fancybox-tmp select)").filter(function(){return this.style.visibility!=="hidden"}).css({visibility:"hidden"}).one("fancybox-cleanup",function(){this.style.visibility="inherit"}); -x.css({"background-color":c.overlayColor,opacity:c.overlayOpacity}).unbind().show()}l=T();V();if(g.is(":visible")){b(z.add(A).add(B)).hide();var a=g.position(),d;k={top:a.top,left:a.left,width:g.width(),height:g.height()};d=k.width==l.width&&k.height==l.height;i.fadeOut(c.changeFade,function(){var f=function(){i.html(m.contents()).fadeIn(c.changeFade,L)};b.event.trigger("fancybox-change");i.empty().css("overflow","hidden");if(d){i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding* -2,1),height:Math.max(l.height-c.padding*2-v,1)});f()}else{i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)});y.prop=0;b(y).animate({prop:1},{duration:c.changeSpeed,easing:c.easingChange,step:M,complete:f})}})}else{g.css("opacity",1);if(c.transitionIn=="elastic"){k=Q();i.css({top:c.padding,left:c.padding,width:Math.max(k.width-c.padding*2,1),height:Math.max(k.height-c.padding*2,1)}).html(m.contents());g.css(k).show();if(c.opacity)l.opacity= -0;y.prop=0;b(y).animate({prop:1},{duration:c.speedIn,easing:c.easingIn,step:M,complete:L})}else{i.css({top:c.padding,left:c.padding,width:Math.max(l.width-c.padding*2,1),height:Math.max(l.height-c.padding*2-v,1)}).html(m.contents());g.css(l).fadeIn(c.transitionIn=="none"?0:c.speedIn,L)}}},F=function(){m.width(e.width);m.height(e.height);if(e.width=="auto")e.width=m.width();if(e.height=="auto")e.height=m.height();N()},Z=function(){h=true;e.width=s.width;e.height=s.height;b("").attr({id:"fancybox-img", -src:s.src,alt:e.title}).appendTo(m);N()},C=function(){J();var a=q[p],d,f,o,t,w;e=b.extend({},b.fn.fancybox.defaults,typeof b(a).data("fancybox")=="undefined"?e:b(a).data("fancybox"));o=a.title||b(a).title||e.title||"";if(a.nodeName&&!e.orig)e.orig=b(a).children("img:first").length?b(a).children("img:first"):b(a);if(o===""&&e.orig)o=e.orig.attr("alt");d=a.nodeName&&/^(?:javascript|#)/i.test(a.href)?e.href||null:e.href||a.href||null;if(e.type){f=e.type;if(!d)d=e.content}else if(e.content)f="html";else if(d)if(d.match(G))f= -"image";else if(d.match(S))f="swf";else if(b(a).hasClass("iframe"))f="iframe";else if(d.match(/#/)){a=d.substr(d.indexOf("#"));f=b(a).length>0?"inline":"ajax"}else f="ajax";else f="inline";e.type=f;e.href=d;e.title=o;if(e.autoDimensions&&e.type!=="iframe"&&e.type!=="swf"){e.width="auto";e.height="auto"}if(e.modal){e.overlayShow=true;e.hideOnOverlayClick=false;e.hideOnContentClick=false;e.enableEscapeButton=false;e.showCloseButton=false}if(b.isFunction(e.onStart))if(e.onStart(q,p,e)===false){h=false; -return}m.css("padding",20+e.padding+e.margin);b(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change",function(){b(this).replaceWith(i.children())});switch(f){case "html":m.html(e.content);F();break;case "inline":b('
').hide().insertBefore(b(a)).bind("fancybox-cleanup",function(){b(this).replaceWith(i.children())}).bind("fancybox-cancel",function(){b(this).replaceWith(m.children())});b(a).appendTo(m);F();break;case "image":h=false;b.fancybox.showActivity(); -s=new Image;s.onerror=function(){P()};s.onload=function(){s.onerror=null;s.onload=null;Z()};s.src=d;break;case "swf":t='';w="";b.each(e.swf,function(r,R){t+='';w+=" "+r+'="'+R+'"'});t+='";m.html(t); -F();break;case "ajax":a=d.split("#",2);f=e.ajax.data||{};if(a.length>1){d=a[0];if(typeof f=="string")f+="&selector="+a[1];else f.selector=a[1]}h=false;b.fancybox.showActivity();E=b.ajax(b.extend(e.ajax,{url:d,data:f,error:P,success:function(r){if(E.status==200){m.html(r);F()}}}));break;case "iframe":b('').appendTo(m);N();break}},$=function(){if(u.is(":visible")){b("div", -u).css("top",I*-40+"px");I=(I+1)%12}else clearInterval(H)},aa=function(){if(!b("#fancybox-wrap").length){b("body").append(m=b('
'),u=b('
'),x=b('
'),g=b('
'));if(!b.support.opacity){g.addClass("fancybox-ie");u.addClass("fancybox-ie")}D=b('
').append('
').appendTo(g); -D.append(i=b('
'),z=b(''),A=b(''),B=b(''));z.click(b.fancybox.close);u.click(b.fancybox.cancel);A.click(function(a){a.preventDefault();b.fancybox.prev()});B.click(function(a){a.preventDefault();b.fancybox.next()});if(O){x.get(0).style.setExpression("height", -"document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");u.get(0).style.setExpression("top","(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");D.prepend('')}}}; -b.fn.fancybox=function(a){b(this).data("fancybox",b.extend({},a,b.metadata?b(this).metadata():{})).unbind("click.fb").bind("click.fb",function(d){d.preventDefault();if(!h){h=true;b(this).blur();q=[];p=0;d=b(this).attr("rel")||"";if(!d||d==""||d==="nofollow")q.push(this);else{q=b("a[rel="+d+"], area[rel="+d+"]");p=q.index(this)}C();return false}});return this};b.fancybox=function(a,d){if(!h){h=true;d=typeof d!=="undefined"?d:{};q=[];p=d.index||0;if(b.isArray(a)){for(var f=0,o=a.length;fq.length||p<0)p=0;C()}};b.fancybox.showActivity=function(){clearInterval(H);u.show();H=setInterval($,66)};b.fancybox.hideActivity=function(){u.hide()};b.fancybox.next=function(){return b.fancybox.pos(n+1)};b.fancybox.prev=function(){return b.fancybox.pos(n- -1)};b.fancybox.pos=function(a){if(!h){a=parseInt(a,10);if(a>-1&&j.length>a){p=a;C()}if(c.cyclic&&j.length>1&&a<0){p=j.length-1;C()}if(c.cyclic&&j.length>1&&a>=j.length){p=0;C()}}};b.fancybox.cancel=function(){if(!h){h=true;b.event.trigger("fancybox-cancel");J();e&&b.isFunction(e.onCancel)&&e.onCancel(q,p,e);h=false}};b.fancybox.close=function(){function a(){x.fadeOut("fast");g.hide();b.event.trigger("fancybox-cleanup");i.empty();b.isFunction(c.onClosed)&&c.onClosed(j,n,c);j=e=[];n=p=0;c=e={};h=false} -if(!(h||g.is(":hidden"))){h=true;if(c&&b.isFunction(c.onCleanup))if(c.onCleanup(j,n,c)===false){h=false;return}J();b(z.add(A).add(B)).hide();b("#fancybox-title").remove();g.add(i).add(x).unbind();b(window).unbind("resize.fb scroll.fb");b(document).unbind("keydown.fb");i.css("overflow","hidden");if(c.transitionOut=="elastic"){k=Q();var d=g.position();l={top:d.top,left:d.left,width:g.width(),height:g.height()};if(c.opacity)l.opacity=1;y.prop=1;b(y).animate({prop:0},{duration:c.speedOut,easing:c.easingOut, -step:M,complete:a})}else g.fadeOut(c.transitionOut=="none"?0:c.speedOut,a)}};b.fancybox.resize=function(){var a,d;if(!(h||g.is(":hidden"))){h=true;a=i.wrapInner("
").children();d=a.height();g.css({height:d+c.padding*2+v});i.css({height:d});a.replaceWith(a.children());b.fancybox.center()}};b.fancybox.center=function(){h=true;var a=K(),d=c.margin,f={};f.top=a[3]+(a[1]-(g.height()-v+40))*0.5;f.left=a[2]+(a[0]-(g.width()+40))*0.5;f.top=Math.max(a[3]+d,f.top);f.left=Math.max(a[2]+ -d,f.left);g.css(f);h=false};b.fn.fancybox.defaults={padding:10,margin:20,opacity:false,modal:false,cyclic:false,scrolling:"auto",width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:"transparent"},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.3,overlayColor:"#666",titleShow:true,titlePosition:"outside",titleFormat:null,transitionIn:"fade",transitionOut:"fade",speedIn:300,speedOut:300,changeSpeed:300,changeFade:"fast", -easingIn:"swing",easingOut:"swing",showCloseButton:true,showNavArrows:true,enableEscapeButton:true,onStart:null,onCancel:null,onComplete:null,onCleanup:null,onClosed:null};b(document).ready(function(){aa()})})(jQuery); \ No newline at end of file +(function($){var tmp,loading,overlay,wrap,outer,inner,close,nav_left,nav_right,selectedIndex=0,selectedOpts={},selectedArray=[],currentIndex=0,currentOpts={},currentArray=[],ajaxLoader=null,imgPreloader=new Image(),imgRegExp=/\.(jpg|gif|png|bmp|jpeg)(.*)?$/i,swfRegExp=/[^\.]\.(swf)\s*$/i,loadingTimer,loadingFrame=1,start_pos,final_pos,busy=false,shadow=20,fx=$.extend($('
')[0],{prop:0}),titleh=0,isIE6=!$.support.opacity&&!window.XMLHttpRequest,fancybox_abort=function(){loading.hide();imgPreloader.onerror=imgPreloader.onload=null;if(ajaxLoader){ajaxLoader.abort()}tmp.empty()},fancybox_error=function(){$.fancybox('

The requested content cannot be loaded.
Please try again later.

',{'scrolling':'no','padding':20,'transitionIn':'none','transitionOut':'none'})},fancybox_get_viewport=function(){return[$(window).width(),$(window).height(),$(document).scrollLeft(),$(document).scrollTop()]},fancybox_get_zoom_to=function(){var view=fancybox_get_viewport(),to={},margin=currentOpts.margin,resize=currentOpts.autoScale,horizontal_space=(shadow+margin)*2,vertical_space=(shadow+margin)*2,double_padding=(currentOpts.padding*2),ratio;if(currentOpts.width.toString().indexOf('%')>-1){to.width=((view[0]*parseFloat(currentOpts.width))/100)-(shadow*2);resize=false}else{to.width=currentOpts.width+double_padding}if(currentOpts.height.toString().indexOf('%')>-1){to.height=((view[1]*parseFloat(currentOpts.height))/100)-(shadow*2);resize=false}else{to.height=currentOpts.height+double_padding}if(resize&&(to.width>(view[0]-horizontal_space)||to.height>(view[1]-vertical_space))){if(selectedOpts.type=='image'||selectedOpts.type=='swf'){horizontal_space+=double_padding;vertical_space+=double_padding;ratio=Math.min(Math.min(view[0]-horizontal_space,currentOpts.width)/currentOpts.width,Math.min(view[1]-vertical_space,currentOpts.height)/currentOpts.height);to.width=Math.round(ratio*(to.width-double_padding))+double_padding;to.height=Math.round(ratio*(to.height-double_padding))+double_padding}else{to.width=Math.min(to.width,(view[0]-horizontal_space));to.height=Math.min(to.height,(view[1]-vertical_space))}}to.top=view[3]+((view[1]-(to.height+(shadow*2)))*0.5);to.left=view[2]+((view[0]-(to.width+(shadow*2)))*0.5);if(currentOpts.autoScale===false){to.top=Math.max(view[3]+margin,to.top);to.left=Math.max(view[2]+margin,to.left)}return to},fancybox_format_title=function(title){if(title&&title.length){switch(currentOpts.titlePosition){case'inside':return title;case'over':return''+title+'';default:return''+title+''}}return false},fancybox_process_title=function(){var title=currentOpts.title,width=final_pos.width-(currentOpts.padding*2),titlec='fancybox-title-'+currentOpts.titlePosition;$('#fancybox-title').remove();titleh=0;if(currentOpts.titleShow===false){return}title=$.isFunction(currentOpts.titleFormat)?currentOpts.titleFormat(title,currentArray,currentIndex,currentOpts):fancybox_format_title(title);if(!title||title===''){return}$('
').css({'width':width,'paddingLeft':currentOpts.padding,'paddingRight':currentOpts.padding}).html(title).appendTo('body');switch(currentOpts.titlePosition){case'inside':titleh=$("#fancybox-title").outerHeight(true)-currentOpts.padding;final_pos.height+=titleh;break;case'over':$('#fancybox-title').css('bottom',currentOpts.padding);break;default:$('#fancybox-title').css('bottom',$("#fancybox-title").outerHeight(true)*-1);break}$('#fancybox-title').appendTo(outer).hide()},fancybox_set_navigation=function(){$(document).unbind('keydown.fb').bind('keydown.fb',function(e){if(e.keyCode==27&¤tOpts.enableEscapeButton){e.preventDefault();$.fancybox.close()}else if(e.keyCode==37){e.preventDefault();$.fancybox.prev()}else if(e.keyCode==39){e.preventDefault();$.fancybox.next()}});if($.fn.mousewheel){wrap.unbind('mousewheel.fb');if(currentArray.length>1){wrap.bind('mousewheel.fb',function(e,delta){e.preventDefault();if(busy||delta===0){return}if(delta>0){$.fancybox.prev()}else{$.fancybox.next()}})}}if(!currentOpts.showNavArrows){return}if((currentOpts.cyclic&¤tArray.length>1)||currentIndex!==0){nav_left.show()}if((currentOpts.cyclic&¤tArray.length>1)||currentIndex!=(currentArray.length-1)){nav_right.show()}},fancybox_preload_images=function(){var href,objNext;if((currentArray.length-1)>currentIndex){href=currentArray[currentIndex+1].href;if(typeof href!=='undefined'&&href.match(imgRegExp)){objNext=new Image();objNext.src=href}}if(currentIndex>0){href=currentArray[currentIndex-1].href;if(typeof href!=='undefined'&&href.match(imgRegExp)){objNext=new Image();objNext.src=href}}},_finish=function(){inner.css('overflow',(currentOpts.scrolling=='auto'?(currentOpts.type=='image'||currentOpts.type=='iframe'||currentOpts.type=='swf'?'hidden':'auto'):(currentOpts.scrolling=='yes'?'auto':'visible')));if(!$.support.opacity){inner.get(0).style.removeAttribute('filter');wrap.get(0).style.removeAttribute('filter')}$('#fancybox-title').show();if(currentOpts.hideOnContentClick){inner.one('click',$.fancybox.close)}if(currentOpts.hideOnOverlayClick){overlay.one('click',$.fancybox.close)}if(currentOpts.showCloseButton){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);if(currentOpts.centerOnScroll){$(window).bind("scroll.fb",$.fancybox.center)}else{$(window).unbind("scroll.fb")}if($.isFunction(currentOpts.onComplete)){currentOpts.onComplete(currentArray,currentIndex,currentOpts)}busy=false;fancybox_preload_images()},fancybox_draw=function(pos){var width=Math.round(start_pos.width+(final_pos.width-start_pos.width)*pos),height=Math.round(start_pos.height+(final_pos.height-start_pos.height)*pos),top=Math.round(start_pos.top+(final_pos.top-start_pos.top)*pos),left=Math.round(start_pos.left+(final_pos.left-start_pos.left)*pos);wrap.css({'width':width+'px','height':height+'px','top':top+'px','left':left+'px'});width=Math.max(width-currentOpts.padding*2,0);height=Math.max(height-(currentOpts.padding*2+(titleh*pos)),0);inner.css({'width':width+'px','height':height+'px'});if(typeof final_pos.opacity!=='undefined'){wrap.css('opacity',(pos<0.5?0.5:pos))}},fancybox_get_obj_pos=function(obj){var pos=obj.offset();pos.top+=parseFloat(obj.css('paddingTop'))||0;pos.left+=parseFloat(obj.css('paddingLeft'))||0;pos.top+=parseFloat(obj.css('border-top-width'))||0;pos.left+=parseFloat(obj.css('border-left-width'))||0;pos.width=obj.width();pos.height=obj.height();return pos},fancybox_get_zoom_from=function(){var orig=selectedOpts.orig?$(selectedOpts.orig):false,from={},pos,view;if(orig&&orig.length){pos=fancybox_get_obj_pos(orig);from={width:(pos.width+(currentOpts.padding*2)),height:(pos.height+(currentOpts.padding*2)),top:(pos.top-currentOpts.padding-shadow),left:(pos.left-currentOpts.padding-shadow)}}else{view=fancybox_get_viewport();from={width:1,height:1,top:view[3]+view[1]*0.5,left:view[2]+view[0]*0.5}}return from},fancybox_show=function(){loading.hide();if(wrap.is(":visible")&&$.isFunction(currentOpts.onCleanup)){if(currentOpts.onCleanup(currentArray,currentIndex,currentOpts)===false){$.event.trigger('fancybox-cancel');busy=false;return}}currentArray=selectedArray;currentIndex=selectedIndex;currentOpts=selectedOpts;inner.get(0).scrollTop=0;inner.get(0).scrollLeft=0;if(currentOpts.overlayShow){if(isIE6){$('select:not(#fancybox-tmp select)').filter(function(){return this.style.visibility!=='hidden'}).css({'visibility':'hidden'}).one('fancybox-cleanup',function(){this.style.visibility='inherit'})}overlay.css({'background-color':currentOpts.overlayColor,'opacity':currentOpts.overlayOpacity}).unbind().show()}final_pos=fancybox_get_zoom_to();fancybox_process_title();if(wrap.is(":visible")){$(close.add(nav_left).add(nav_right)).hide();var pos=wrap.position(),equal;start_pos={top:pos.top,left:pos.left,width:wrap.width(),height:wrap.height()};equal=(start_pos.width==final_pos.width&&start_pos.height==final_pos.height);inner.fadeOut(currentOpts.changeFade,function(){var finish_resizing=function(){inner.html(tmp.contents()).fadeIn(currentOpts.changeFade,_finish)};$.event.trigger('fancybox-change');inner.empty().css('overflow','hidden');if(equal){inner.css({top:currentOpts.padding,left:currentOpts.padding,width:Math.max(final_pos.width-(currentOpts.padding*2),1),height:Math.max(final_pos.height-(currentOpts.padding*2)-titleh,1)});finish_resizing()}else{inner.css({top:currentOpts.padding,left:currentOpts.padding,width:Math.max(start_pos.width-(currentOpts.padding*2),1),height:Math.max(start_pos.height-(currentOpts.padding*2),1)});fx.prop=0;$(fx).animate({prop:1},{duration:currentOpts.changeSpeed,easing:currentOpts.easingChange,step:fancybox_draw,complete:finish_resizing})}});return}wrap.css('opacity',1);if(currentOpts.transitionIn=='elastic'){start_pos=fancybox_get_zoom_from();inner.css({top:currentOpts.padding,left:currentOpts.padding,width:Math.max(start_pos.width-(currentOpts.padding*2),1),height:Math.max(start_pos.height-(currentOpts.padding*2),1)}).html(tmp.contents());wrap.css(start_pos).show();if(currentOpts.opacity){final_pos.opacity=0}fx.prop=0;$(fx).animate({prop:1},{duration:currentOpts.speedIn,easing:currentOpts.easingIn,step:fancybox_draw,complete:_finish})}else{inner.css({top:currentOpts.padding,left:currentOpts.padding,width:Math.max(final_pos.width-(currentOpts.padding*2),1),height:Math.max(final_pos.height-(currentOpts.padding*2)-titleh,1)}).html(tmp.contents());wrap.css(final_pos).fadeIn(currentOpts.transitionIn=='none'?0:currentOpts.speedIn,_finish)}},fancybox_process_inline=function(){tmp.width(selectedOpts.width);tmp.height(selectedOpts.height);if(selectedOpts.width=='auto'){selectedOpts.width=tmp.width()}if(selectedOpts.height=='auto'){selectedOpts.height=tmp.height()}fancybox_show()},fancybox_process_image=function(){busy=true;selectedOpts.width=imgPreloader.width;selectedOpts.height=imgPreloader.height;$("").attr({'id':'fancybox-img','src':imgPreloader.src,'alt':selectedOpts.title}).appendTo(tmp);fancybox_show()},fancybox_start=function(){fancybox_abort();var obj=selectedArray[selectedIndex],href,type,title,str,emb,selector,data;selectedOpts=$.extend({},$.fn.fancybox.defaults,(typeof $(obj).data('fancybox')=='undefined'?selectedOpts:$(obj).data('fancybox')));title=obj.title||$(obj).title||selectedOpts.title||'';if(obj.nodeName&&!selectedOpts.orig){selectedOpts.orig=$(obj).children("img:first").length?$(obj).children("img:first"):$(obj)}if(title===''&&selectedOpts.orig){title=selectedOpts.orig.attr('alt')}if(obj.nodeName&&(/^(?:javascript|#)/i).test(obj.href)){href=selectedOpts.href||null}else{href=selectedOpts.href||obj.href||null}if(selectedOpts.type){type=selectedOpts.type;if(!href){href=selectedOpts.content}}else if(selectedOpts.content){type='html'}else if(href){if(href.match(imgRegExp)){type='image'}else if(href.match(swfRegExp)){type='swf'}else if($(obj).hasClass("iframe")){type='iframe'}else if(href.match(/#/)){obj=href.substr(href.indexOf("#"));type=$(obj).length>0?'inline':'ajax'}else{type='ajax'}}else{type='inline'}selectedOpts.type=type;selectedOpts.href=href;selectedOpts.title=title;if(selectedOpts.autoDimensions&&selectedOpts.type!=='iframe'&&selectedOpts.type!=='swf'){selectedOpts.width='auto';selectedOpts.height='auto'}if(selectedOpts.modal){selectedOpts.overlayShow=true;selectedOpts.hideOnOverlayClick=false;selectedOpts.hideOnContentClick=false;selectedOpts.enableEscapeButton=false;selectedOpts.showCloseButton=false}if($.isFunction(selectedOpts.onStart)){if(selectedOpts.onStart(selectedArray,selectedIndex,selectedOpts)===false){busy=false;return}}tmp.css('padding',(shadow+selectedOpts.padding+selectedOpts.margin));$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change',function(){$(this).replaceWith(inner.children())});switch(type){case'html':tmp.html(selectedOpts.content);fancybox_process_inline();break;case'inline':$('
').hide().insertBefore($(obj)).bind('fancybox-cleanup',function(){$(this).replaceWith(inner.children())}).bind('fancybox-cancel',function(){$(this).replaceWith(tmp.children())});$(obj).appendTo(tmp);fancybox_process_inline();break;case'image':busy=false;$.fancybox.showActivity();imgPreloader=new Image();imgPreloader.onerror=function(){fancybox_error()};imgPreloader.onload=function(){imgPreloader.onerror=null;imgPreloader.onload=null;fancybox_process_image()};imgPreloader.src=href;break;case'swf':str='';emb='';$.each(selectedOpts.swf,function(name,val){str+='';emb+=' '+name+'="'+val+'"'});str+='';tmp.html(str);fancybox_process_inline();break;case'ajax':selector=href.split('#',2);data=selectedOpts.ajax.data||{};if(selector.length>1){href=selector[0];if(typeof data=="string"){data+='&selector='+selector[1]}else{data.selector=selector[1]}}busy=false;$.fancybox.showActivity();ajaxLoader=$.ajax($.extend(selectedOpts.ajax,{url:href,data:data,error:fancybox_error,success:function(data,textStatus,XMLHttpRequest){if(ajaxLoader.status==200){tmp.html(data);fancybox_process_inline()}}}));break;case'iframe':$('').appendTo(tmp);fancybox_show();break}},fancybox_animate_loading=function(){if(!loading.is(':visible')){clearInterval(loadingTimer);return}$('div',loading).css('top',(loadingFrame*-40)+'px');loadingFrame=(loadingFrame+1)%12},fancybox_init=function(){if($("#fancybox-wrap").length){return}$('body').append(tmp=$('
'),loading=$('
'),overlay=$('
'),wrap=$('
'));if(!$.support.opacity){wrap.addClass('fancybox-ie');loading.addClass('fancybox-ie')}outer=$('
').append('
').appendTo(wrap);outer.append(inner=$('
'),close=$(''),nav_left=$(''),nav_right=$(''));close.click($.fancybox.close);loading.click($.fancybox.cancel);nav_left.click(function(e){e.preventDefault();$.fancybox.prev()});nav_right.click(function(e){e.preventDefault();$.fancybox.next()});if(isIE6){overlay.get(0).style.setExpression('height',"document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");loading.get(0).style.setExpression('top',"(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");outer.prepend('')}};$.fn.fancybox=function(options){$(this).data('fancybox',$.extend({},options,($.metadata?$(this).metadata():{}))).unbind('click.fb').bind('click.fb',function(e){e.preventDefault();if(busy){return}busy=true;$(this).blur();selectedArray=[];selectedIndex=0;var rel=$(this).attr('rel')||'';if(!rel||rel==''||rel==='nofollow'){selectedArray.push(this)}else{selectedArray=$("a[rel="+rel+"], area[rel="+rel+"]");selectedIndex=selectedArray.index(this)}fancybox_start();return false});return this};$.fancybox=function(obj){if(busy){return}busy=true;var opts=typeof arguments[1]!=='undefined'?arguments[1]:{};selectedArray=[];selectedIndex=opts.index||0;if($.isArray(obj)){for(var i=0,j=obj.length;iselectedArray.length||selectedIndex<0){selectedIndex=0}fancybox_start()};$.fancybox.showActivity=function(){clearInterval(loadingTimer);loading.show();loadingTimer=setInterval(fancybox_animate_loading,66)};$.fancybox.hideActivity=function(){loading.hide()};$.fancybox.next=function(){return $.fancybox.pos(currentIndex+1)};$.fancybox.prev=function(){return $.fancybox.pos(currentIndex-1)};$.fancybox.pos=function(pos){if(busy){return}pos=parseInt(pos,10);if(pos>-1&¤tArray.length>pos){selectedIndex=pos;fancybox_start()}if(currentOpts.cyclic&¤tArray.length>1&&pos<0){selectedIndex=currentArray.length-1;fancybox_start()}if(currentOpts.cyclic&¤tArray.length>1&&pos>=currentArray.length){selectedIndex=0;fancybox_start()}return};$.fancybox.cancel=function(){if(busy){return}busy=true;$.event.trigger('fancybox-cancel');fancybox_abort();if(selectedOpts&&$.isFunction(selectedOpts.onCancel)){selectedOpts.onCancel(selectedArray,selectedIndex,selectedOpts)}busy=false};$.fancybox.close=function(){if(busy||wrap.is(':hidden')){return}busy=true;if(currentOpts&&$.isFunction(currentOpts.onCleanup)){if(currentOpts.onCleanup(currentArray,currentIndex,currentOpts)===false){busy=false;return}}fancybox_abort();$(close.add(nav_left).add(nav_right)).hide();$('#fancybox-title').remove();wrap.add(inner).add(overlay).unbind();$(window).unbind("resize.fb scroll.fb");$(document).unbind('keydown.fb');function _cleanup(){overlay.fadeOut('fast');wrap.hide();$.event.trigger('fancybox-cleanup');inner.empty();if($.isFunction(currentOpts.onClosed)){currentOpts.onClosed(currentArray,currentIndex,currentOpts)}currentArray=selectedOpts=[];currentIndex=selectedIndex=0;currentOpts=selectedOpts={};busy=false}inner.css('overflow','hidden');if(currentOpts.transitionOut=='elastic'){start_pos=fancybox_get_zoom_from();var pos=wrap.position();final_pos={top:pos.top,left:pos.left,width:wrap.width(),height:wrap.height()};if(currentOpts.opacity){final_pos.opacity=1}fx.prop=1;$(fx).animate({prop:0},{duration:currentOpts.speedOut,easing:currentOpts.easingOut,step:fancybox_draw,complete:_cleanup})}else{wrap.fadeOut(currentOpts.transitionOut=='none'?0:currentOpts.speedOut,_cleanup)}};$.fancybox.resize=function(){var c,h;if(busy||wrap.is(':hidden')){return}busy=true;c=inner.wrapInner("
").children();h=c.height();wrap.css({height:h+(currentOpts.padding*2)+titleh});inner.css({height:h});c.replaceWith(c.children());$.fancybox.center()};$.fancybox.center=function(){busy=true;var view=fancybox_get_viewport(),margin=currentOpts.margin,to={};to.top=view[3]+((view[1]-((wrap.height()-titleh)+(shadow*2)))*0.5);to.left=view[2]+((view[0]-(wrap.width()+(shadow*2)))*0.5);to.top=Math.max(view[3]+margin,to.top);to.left=Math.max(view[2]+margin,to.left);wrap.css(to);busy=false};$.fn.fancybox.defaults={padding:10,margin:20,opacity:false,modal:false,cyclic:false,scrolling:'auto',width:560,height:340,autoScale:true,autoDimensions:true,centerOnScroll:false,ajax:{},swf:{wmode:'transparent'},hideOnOverlayClick:true,hideOnContentClick:false,overlayShow:true,overlayOpacity:0.3,overlayColor:'#666',titleShow:true,titlePosition:'outside',titleFormat:null,transitionIn:'fade',transitionOut:'fade',speedIn:300,speedOut:300,changeSpeed:300,changeFade:'fast',easingIn:'swing',easingOut:'swing',showCloseButton:true,showNavArrows:true,enableEscapeButton:true,onStart:null,onCancel:null,onComplete:null,onCleanup:null,onClosed:null};$(document).ready(function(){fancybox_init()})})(jQuery); +// removed arrow functionality from vanilla pack + diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index be025e2d7..c6282b1b8 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -601,3 +601,6 @@ h1.big_text { border: 1px solid #cccccc; border-bottom: none; padding: 3px 10px; } + +#fancybox-close:hover { + background-color: transparent; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 7f7125c49..206c122bd 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -756,3 +756,7 @@ h1.big_text :bottom none :padding 3px 10px + +#fancybox-close:hover + :background + :color transparent From c520fb71a71d09a9a8d9672aa1b5cb7735c1cac2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 16 Sep 2010 21:34:15 -0700 Subject: [PATCH 19/20] Moved socket out to separate process. Multiple thins should now be possible --- Gemfile | 5 ++++- Gemfile.lock | 10 ++++++++++ app/controllers/sockets_controller.rb | 2 +- app/models/post.rb | 1 + config/app_config.yml | 1 + config/initializers/socket.rb | 26 -------------------------- lib/diaspora/websocket.rb | 6 +++++- 7 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 config/initializers/socket.rb diff --git a/Gemfile b/Gemfile index 77627808d..cc92bec3d 100644 --- a/Gemfile +++ b/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' diff --git a/Gemfile.lock b/Gemfile.lock index 007810850..dd181b320 100644 --- a/Gemfile.lock +++ b/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)! diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb index 2852a7160..9b90ea831 100644 --- a/app/controllers/sockets_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -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 diff --git a/app/models/post.rb b/app/models/post.rb index e2dd53d3d..9f7c3ff27 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -4,6 +4,7 @@ class Post + require 'lib/diaspora/websocket' require 'lib/encryptable' include MongoMapper::Document include ApplicationHelper diff --git a/config/app_config.yml b/config/app_config.yml index 0a206c366..a138424ee 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -8,6 +8,7 @@ development: debug: false socket_debug : false socket_port: 8080 + socket_collection_name: 'websocket' pubsub_server: 'https://pubsubhubbub.appspot.com/' test: diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb deleted file mode 100644 index 0b1035001..000000000 --- a/config/initializers/socket.rb +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3. See -# the COPYRIGHT file. - - -require 'em-websocket' -require 'eventmachine' -require 'lib/diaspora/websocket' - EM.next_tick { - Diaspora::WebSocket.initialize_channels - - EventMachine::WebSocket.start( - :host => "0.0.0.0", - :port => APP_CONFIG[:socket_port], - :debug =>APP_CONFIG[:socket_debug]) do |ws| - ws.onopen { - - sid = Diaspora::WebSocket.subscribe(ws.request['Path'].gsub('/',''), ws) - - ws.onmessage { |msg| SocketsController.new.incoming(msg) } - - ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) } - } - end - } - diff --git a/lib/diaspora/websocket.rb b/lib/diaspora/websocket.rb index fc79559f6..687bd2b7c 100644 --- a/lib/diaspora/websocket.rb +++ b/lib/diaspora/websocket.rb @@ -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 From 7c02200a67f2257f5c35beceaa153b05a501bc4c Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 16 Sep 2010 21:42:16 -0700 Subject: [PATCH 20/20] Finish moving out websocket server, add task to start it --- config/deploy.rb | 5 +++++ script/websocket_server.rb | 40 ++++++++++++++++++++++++++++++++++++++ spec/lib/websocket_spec.rb | 24 +++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 script/websocket_server.rb create mode 100644 spec/lib/websocket_spec.rb diff --git a/config/deploy.rb b/config/deploy.rb index b4870f94d..805eadf4d 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -58,6 +58,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 diff --git a/script/websocket_server.rb b/script/websocket_server.rb new file mode 100644 index 000000000..8c466ca77 --- /dev/null +++ b/script/websocket_server.rb @@ -0,0 +1,40 @@ +# 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__) + '/../config/environment' +require File.dirname(__FILE__) + '/../lib/diaspora/websocket' + +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( + :host => "0.0.0.0", + :port => APP_CONFIG[:socket_port], + :debug =>APP_CONFIG[:socket_debug]) do |ws| + ws.onopen { + + sid = Diaspora::WebSocket.subscribe(ws.request['Path'].gsub('/',''), ws) + + ws.onmessage { |msg| SocketsController.new.incoming(msg) } + + ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) } + } + end + process_message + } + diff --git a/spec/lib/websocket_spec.rb b/spec/lib/websocket_spec.rb new file mode 100644 index 000000000..233f7be48 --- /dev/null +++ b/spec/lib/websocket_spec.rb @@ -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