From 81476025702348e2c247f5aa1bef9696cd453678 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 9 Jul 2010 18:10:11 -0700 Subject: [PATCH 01/10] DG MS friends now are delete --- app/models/retraction.rb | 25 ++++++++++++++++++------- app/models/user.rb | 10 +++++++++- lib/common.rb | 2 +- spec/factories.rb | 1 + spec/models/person_spec.rb | 15 +++++++++++++-- spec/models/user_spec.rb | 6 +++--- 6 files changed, 45 insertions(+), 14 deletions(-) diff --git a/app/models/retraction.rb b/app/models/retraction.rb index a4d10bb59..1ccfa33f9 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -2,21 +2,32 @@ class Retraction include ROXML include Diaspora::Webhooks - def self.for(post) - result = self.new - result.post_id = post.id - result.person_id = post.person.id - result + def self.for(object) + retraction = self.new + retraction.post_id= object.id + retraction.person_id = person_id_from(object) + retraction.type = object.class + retraction end xml_accessor :post_id xml_accessor :person_id + xml_accessor :type attr_accessor :post_id attr_accessor :person_id - + attr_accessor :type + def perform - Post.delete(self.post_id) + self.type.constantize.delete(self.post_id) + end + + def self.person_id_from(object) + if object.is_a? Person + object.id + else + object.person.id + end end end diff --git a/app/models/user.rb b/app/models/user.rb index a7bdcd294..872d35a48 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -46,7 +46,7 @@ class User < Person end def ignore_friend_request(friend_request_id) - request = Request.where(:id => friend_request_id).first + request = Request.first(:id => friend_request_id) person = request.person person.destroy unless person.active request.destroy @@ -61,6 +61,14 @@ class User < Person end end + def unfriend(friend_id) + bad_friend = Person.first(:id => friend_id, :active => true) + if bad_friend + Retraction.for(self).push_to_url(bad_friend.url) + bad_friend.destroy + end + end + ###Helpers############ def mine?(post) diff --git a/lib/common.rb b/lib/common.rb index c0fd6947f..a049b561f 100644 --- a/lib/common.rb +++ b/lib/common.rb @@ -76,7 +76,7 @@ module Diaspora end def people_with_permissions - Person.where( :_type => "Person" ).all + Person.friends.all end def self.build_xml_for(posts) diff --git a/spec/factories.rb b/spec/factories.rb index 5467a6b39..46e09e3dd 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -11,6 +11,7 @@ end Factory.define :person do |p| p.email "bob@aol.com" + p.active true p.sequence(:url) {|n|"http://google-#{n}.com/"} p.profile Profile.new( :first_name => "Robert", :last_name => "Grimm" ) end diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index 69b5ff29a..8c6dd30bf 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -26,9 +26,9 @@ describe Person do end it 'should only return active friends' do - Factory.create(:person, :active => true) - Factory.create(:person) Factory.create(:person) + Factory.create(:person, :active => false) + Factory.create(:person, :active => false) Person.friends.all.count.should == 1 end @@ -57,5 +57,16 @@ describe Person do s.comments.count.should == 1 end + it 'should let a user unfriend another user' do + u = Factory.create(:user) + + f = Factory.create(:person, :active => true) + + + Person.friends.all.count.should == 1 + u.unfriend(f.id) + Person.friends.all.count.should == 0 + + end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 201ec6318..8c0f1cf7b 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -9,7 +9,7 @@ describe User do it "should be able to accept a pending friend request" do @user = Factory.create(:user) - @friend = Factory.create(:person) + @friend = Factory.create(:person, :active => false) r = Request.instantiate(:to => @user.url, :from => @friend) r.save Person.all.count.should == 2 @@ -21,7 +21,7 @@ describe User do it 'should be able to ignore a pending friend request' do @user = Factory.create(:user) - @friend = Factory.create(:person) + @friend = Factory.create(:person, :active => false) r = Request.instantiate(:to => @user.url, :from => @friend) r.save @@ -36,7 +36,7 @@ describe User do it 'should not be able to friend request an existing friend' do @user = Factory.create(:user) - @friend = Factory.create(:person, :active => true) + @friend = Factory.create(:person) @user.send_friend_request_to( @friend.url ).should be nil end From 23057869e1f1a3dda13475f0b3f362f7f3df8a85 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 9 Jul 2010 18:41:39 -0700 Subject: [PATCH 02/10] DG MS debugging friend request --- app/controllers/people_controller.rb | 3 +-- app/controllers/requests_controller.rb | 2 +- app/models/user.rb | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index d8769d448..9c8d2f711 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -12,8 +12,7 @@ class PeopleController < ApplicationController end def destroy - @person = Person.where(:id => params[:id]).first - @person.destroy + current_user.unfriend(params[:id]) flash[:notice] = "Successfully destroyed person." redirect_to people_url end diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index 4bafd6d54..e6528d156 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -9,7 +9,7 @@ class RequestsController < ApplicationController def destroy if params[:accept] current_user.accept_friend_request params[:id] - flash[:notice] = "you are now friends with #{@request.person.real_name}" + flash[:notice] = "you are now friends" else current_user.ignore_friend_request params[:id] flash[:notice] = "ignored friend request" diff --git a/app/models/user.rb b/app/models/user.rb index 872d35a48..14ec61077 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -29,10 +29,11 @@ class User < Person def send_friend_request_to(friend_url) unless Person.where(:url => friend_url).first p = Request.instantiate(:to => friend_url, :from => self) + puts p.inspect if p.save p.push_to_url friend_url - p end + p end end From aa916d06047294c37460de669969170f9cce018a Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 9 Jul 2010 18:50:39 -0700 Subject: [PATCH 03/10] moved User.first out of the application view --- app/views/layouts/application.html.haml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 09c7dff3b..79abadcdf 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,7 +2,7 @@ %html %head %title - = User.first.real_name if User.first + = current_user.real_name if current_user = " | diaspora" %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/ @@ -30,7 +30,7 @@ #session_action - if user_signed_in? - =User.first.real_name + = current_user.real_name | = link_to "requests (#{@request_count})", requests_path | @@ -50,9 +50,9 @@ .span-20 - if user_signed_in? %h1#user_name - = link_to User.first.real_name, root_url + = link_to current_user.real_name, root_url %span.description = my_latest_message = yield - .span-20 + .span-12 = render "posts/debug" From 29516d829eb8a6c5323d06bbe84540d81fc214a0 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 9 Jul 2010 18:53:47 -0700 Subject: [PATCH 04/10] MS flash now gives message if you have already friended a given person --- app/controllers/requests_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index e6528d156..d96dc354c 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -24,11 +24,13 @@ class RequestsController < ApplicationController def create @request = current_user.send_friend_request_to(params[:request][:destination_url]) - if @request flash[:notice] = "a friend request was sent to #{@request.destination_url}" redirect_to requests_url else + + flash[:error] = "you have already friended this person" + @request = Request.new render :action => 'new' end end From 7bfdaac6917e095eb38d5bb64aa6e91c8f98beda Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 9 Jul 2010 18:54:48 -0700 Subject: [PATCH 05/10] added unfriend button to person show page --- app/views/people/show.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index ccdabacd3..50050d2eb 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -1,5 +1,6 @@ .span-20.last %h1= "#{@person.real_name}" + = link_to 'remove friend', @person, :confirm => 'Are you sure?', :method => :delete - if @person_profile %p %b First Name From d37461a43279ea0d3bfa76309a82213c5909d243 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 9 Jul 2010 19:27:39 -0700 Subject: [PATCH 06/10] ms dg post deletions now come thru the socket again --- app/controllers/people_controller.rb | 2 +- app/controllers/requests_controller.rb | 6 ++++-- app/controllers/sockets_controller.rb | 5 +++++ app/models/retraction.rb | 16 ++++++++++++++-- app/views/requests/_request.html.haml | 2 +- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 9c8d2f711..44bdaf63f 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -13,7 +13,7 @@ class PeopleController < ApplicationController def destroy current_user.unfriend(params[:id]) - flash[:notice] = "Successfully destroyed person." + flash[:notice] = "unfriended person." redirect_to people_url end diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index d96dc354c..c37a86ca7 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -8,13 +8,15 @@ class RequestsController < ApplicationController def destroy if params[:accept] - current_user.accept_friend_request params[:id] + @friend = current_user.accept_friend_request params[:id] + flash[:notice] = "you are now friends" + redirect_to root_url else current_user.ignore_friend_request params[:id] flash[:notice] = "ignored friend request" + redirect_to requests_url end - redirect_to requests_url end diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb index daea6466a..05150f785 100644 --- a/app/controllers/sockets_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -20,6 +20,11 @@ class SocketsController < ApplicationController def outgoing(object) @_request = ActionDispatch::Request.new({}) + + puts action_hash(object) + + + WebSocket.push_to_clients(action_hash(object)) end diff --git a/app/models/retraction.rb b/app/models/retraction.rb index 1ccfa33f9..c799df5fd 100644 --- a/app/models/retraction.rb +++ b/app/models/retraction.rb @@ -6,7 +6,7 @@ class Retraction retraction = self.new retraction.post_id= object.id retraction.person_id = person_id_from(object) - retraction.type = object.class + retraction.type = self.type_name(object) retraction end @@ -19,7 +19,8 @@ class Retraction attr_accessor :type def perform - self.type.constantize.delete(self.post_id) + puts('GO GO GO') + self.type.constantize.destroy(self.post_id) end def self.person_id_from(object) @@ -30,4 +31,15 @@ class Retraction end end + + def self.type_name(object) + if object.is_a? Post + object.class + elsif object.is_a? User + 'Person' + else + 'Clowntown' + end + end + end diff --git a/app/views/requests/_request.html.haml b/app/views/requests/_request.html.haml index 84284151a..39a4114b3 100644 --- a/app/views/requests/_request.html.haml +++ b/app/views/requests/_request.html.haml @@ -4,6 +4,6 @@ = "#{request.destination_url}" .destroy_link - = link_to 'Accept', request_path(request, :accept => true), :confirm => 'Are you sure?', :method => :delete + = link_to 'Accept', request_path(request, :accept => true), :method => :delete | = link_to 'Ignore', request_path(request), :confirm => 'Are you sure?', :method => :delete From c073fc6137d4a5c8bb7d776dbfb6073e9b487b69 Mon Sep 17 00:00:00 2001 From: maxwell Date: Fri, 9 Jul 2010 19:36:02 -0700 Subject: [PATCH 07/10] MS DG friend deletions dont work, but they do send, prob a parser problem --- app/controllers/sockets_controller.rb | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/app/controllers/sockets_controller.rb b/app/controllers/sockets_controller.rb index 05150f785..67ffc7dc8 100644 --- a/app/controllers/sockets_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -3,12 +3,6 @@ class SocketsController < ApplicationController include SocketsHelper include Rails.application.routes.url_helpers before_filter :authenticate_user! - - - - # def default_url_options() - # {:host=> 'example.com'} - # end def incoming(msg) puts "#{msg} connected!" @@ -20,17 +14,11 @@ class SocketsController < ApplicationController def outgoing(object) @_request = ActionDispatch::Request.new({}) - puts action_hash(object) - - - WebSocket.push_to_clients(action_hash(object)) end def delete_subscriber(sid) WebSocket.unsubscribe(sid) end - - end From a02a8336256b880ab6da9559a01c21058a0c299b Mon Sep 17 00:00:00 2001 From: maxwell Date: Sat, 10 Jul 2010 00:32:58 -0700 Subject: [PATCH 08/10] updated rails for kicks, run bundle install, and run gem install bundler --pre rspec-rails --pre too --- .gitignore | 1 + Gemfile | 2 +- config/environments/development.rb | 2 +- lib/common.rb | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8b309cc03..91e987e1c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ db/*.sqlite3 log/*.log tmp/**/* +Gemfile.lock gpg/diaspora-development/*.gpg gpg/diaspora-production/*.gpg diff --git a/Gemfile b/Gemfile index 4f2c736a1..7be06ae84 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'http://rubygems.org' source 'http://gemcutter.org' -gem 'rails', '3.0.0.beta4' +gem 'rails', :git =>'http://github.com/rails/rails.git' gem 'bundler' gem 'mongo_mapper', :git => "http://github.com/BadMinus/mongomapper.git" gem 'devise', :git => "http://github.com/BadMinus/devise.git" diff --git a/config/environments/development.rb b/config/environments/development.rb index d03bf7d3a..12446d661 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -16,6 +16,6 @@ Diaspora::Application.configure do # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false - + config.active_support.deprecation = :log #config.threadsafe! end diff --git a/lib/common.rb b/lib/common.rb index a049b561f..13c87ae62 100644 --- a/lib/common.rb +++ b/lib/common.rb @@ -47,6 +47,7 @@ module Diaspora def self.included(klass) klass.class_eval do include ROXML + require 'message_handler' @@queue = MessageHandler.new def notify_people From 902a8cb349db6f8164c5f77a8732874fd6af6852 Mon Sep 17 00:00:00 2001 From: maxwell Date: Sat, 10 Jul 2010 10:34:46 -0700 Subject: [PATCH 09/10] MS factored out User.first EVERYWHERE. Use User.owner now instead (currently just calls User.first, but now it is easier to make a new change --- app/controllers/dashboards_controller.rb | 30 ++++++++++++------------ app/helpers/application_helper.rb | 6 ++--- app/models/comment.rb | 2 +- app/models/person.rb | 1 + app/models/post.rb | 2 +- app/models/user.rb | 7 +++++- app/views/devise/sessions/new.html.haml | 2 +- app/views/layouts/session_wall.html.haml | 4 ++-- lib/common.rb | 4 ++-- spec/models/post_spec.rb | 2 +- 10 files changed, 33 insertions(+), 27 deletions(-) diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb index c5508d51c..11dbd939a 100644 --- a/app/controllers/dashboards_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -17,21 +17,21 @@ class DashboardsController < ApplicationController def warzombie render :nothing => true - if User.first.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil - StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => User.first) - Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => User.first ) - StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => User.first, :created_at => Time.now-930) - StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => User.first, :created_at => Time.now-43990) - StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => User.first, :created_at => Time.now-4390) - Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => User.first, :created_at => Time.now-54390) - Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => User.first, :created_at => Time.now-3090) - StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => User.first, :created_at => Time.now-30900) - Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => User.first, :created_at => Time.now-9090) - StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => User.first, :created_at => Time.now-590000) - StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => User.first, :created_at => Time.now-503900) - StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => User.first, :created_at => Time.now-4400) - StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => User.first, :created_at => Time.now-400239) - StatusMessage.create(:message => "A cool, cool morning for once.", :person => User.first, :created_at => Time.now-150000) + if User.owner.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil + StatusMessage.create(:message => "There's a bomb in the lasagna!?", :person => User.owner) + Bookmark.create(:title => "xkcd", :link => "http://xkcd.com/743/", :person => User.owner ) + StatusMessage.create(:message => "I switched to Motoroi today, a Motorola Android-based phone, in Korea. Now, I am using Android phones in both the U.S. and Korea", :person => User.owner, :created_at => Time.now-930) + StatusMessage.create(:message => "I had 5 hours to study for it :-( GREs on Thursday. Wunderbar.", :person => User.owner, :created_at => Time.now-43990) + StatusMessage.create(:message => "Spotted in toy story 3: google maps, OSX, and windows XP. Two out of three isn't bad.", :person => User.owner, :created_at => Time.now-4390) + Bookmark.create( :title => "Reddit", :link => "http://reddit.com", :person => User.owner, :created_at => Time.now-54390) + Blog.create(:title => "I Love Rock'N'Roll - Joan Jett & The Blackhearts", :body => "

The loudspeakers played this song as we walked into the city pool for the first time this summer. Those loudspeakers make every song sound fresh even if I have heard it a thousand times and their effect on this song was no different. Joan sounded young and strong and ready, and for a moment I forgot where or when I was.

also i can tell it won’t be long and also happy summer imaginary constructs -mumblelard

", :person => User.owner, :created_at => Time.now-3090) + StatusMessage.create(:message => "Commercials for IE make me SO MAD and my friends just don't get why.", :person => User.owner, :created_at => Time.now-30900) + Bookmark.create(:title => "Zombo.com", :link => "http://zombo.com", :person => User.owner, :created_at => Time.now-9090) + StatusMessage.create(:message => "Why do I have \"No More Heroes\" by Westlife on repeat all day?", :person => User.owner, :created_at => Time.now-590000) + StatusMessage.create(:message => "Mmm. Friday night. Acknowledged.", :person => User.owner, :created_at => Time.now-503900) + StatusMessage.create(:message => "Getting a universal remote is the epitome of laziness, I do declare.", :person => User.owner, :created_at => Time.now-4400) + StatusMessage.create(:message => "Does anyone know how to merge two Skype contact entries of the same person? (i.e. one Skype ID and one mobile number)", :person => User.owner, :created_at => Time.now-400239) + StatusMessage.create(:message => "A cool, cool morning for once.", :person => User.owner, :created_at => Time.now-150000) end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c476210ab..897c4826a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -10,7 +10,7 @@ module ApplicationHelper end def mine?(post) - post.person == User.first + post.person == User.owner end def type_partial(post) @@ -39,9 +39,9 @@ module ApplicationHelper def owner_picture default = "/images/user/default.jpg" - image = "/images/user/#{User.first.profile.last_name.gsub(/ /,'').downcase}.jpg" + image = "/images/user/#{User.owner.profile.last_name.gsub(/ /,'').downcase}.jpg" - if File.exist?("public/images/user/#{User.first.profile.last_name.gsub(/ /,'').downcase}.jpg") + if File.exist?("public/images/user/#{User.owner.profile.last_name.gsub(/ /,'').downcase}.jpg") image_tag image, :id => "user_picture" else image_tag default, :id => "user_picture" diff --git a/app/models/comment.rb b/app/models/comment.rb index b8a682a94..b1cdc493b 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -29,7 +29,7 @@ class Comment protected def send_people_comments_on_my_posts - if User.first.mine?(self.post) && !(self.person.is_a? User) + if User.owner.mine?(self.post) && !(self.person.is_a? User) self.push_to(self.post.people_with_permissions) end end diff --git a/app/models/person.rb b/app/models/person.rb index 48999c664..b1e24890a 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -28,6 +28,7 @@ class Person scope :friends, where(:_type => "Person", :active => true) + def real_name "#{profile.first_name.to_s} #{profile.last_name.to_s}" diff --git a/app/models/post.rb b/app/models/post.rb index a0b69e08b..fec801a71 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -36,7 +36,7 @@ class Post end def self.my_newest - self.newest(User.first) + self.newest(User.owner) end def self.newest_by_email(email) self.newest(Person.first(:email => email)) diff --git a/app/models/user.rb b/app/models/user.rb index 14ec61077..9b9a456a4 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,7 +8,9 @@ class User < Person validates_presence_of :profile before_validation :do_bad_things - + + + ######## Commenting ######## def comment(text, options = {}) @@ -80,6 +82,9 @@ class User < Person self.password_confirmation = self.password end + def self.owner + User.first + end protected diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index 79a391314..96b9ca9c4 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -6,7 +6,7 @@ /= f.check_box :remember_me /= f.label :remember_me - = hidden_field_tag "user_email", "#{User.first.email}", :name => "user[email]" + = hidden_field_tag "user_email", "#{User.owner.email}", :name => "user[email]" = f.submit "Sign in" /= render :partial => "devise/shared/links" diff --git a/app/views/layouts/session_wall.html.haml b/app/views/layouts/session_wall.html.haml index f4b13e524..19e9d2043 100644 --- a/app/views/layouts/session_wall.html.haml +++ b/app/views/layouts/session_wall.html.haml @@ -39,11 +39,11 @@ - flash.each do |name, msg| = content_tag :div, msg, :id => "flash_#{name}" - - if User.first + - if User.owner %div#huge_text welcome back, %span - = User.first.real_name.downcase + = User.owner.real_name.downcase = yield -else %div#huge_text diff --git a/lib/common.rb b/lib/common.rb index 13c87ae62..fcd9cd82b 100644 --- a/lib/common.rb +++ b/lib/common.rb @@ -33,7 +33,7 @@ module Diaspora if p.is_a? Retraction p.perform elsif p.is_a? Request - User.first.receive_friend_request(p) + User.owner.receive_friend_request(p) #This line checks if the sender was in the database, among other things? elsif p.respond_to?(:person) && !(p.person.nil?) && !(p.person.is_a? User) #WTF p.save @@ -51,7 +51,7 @@ module Diaspora @@queue = MessageHandler.new def notify_people - if self.person_id == User.first.id + if self.person_id == User.owner.id push_to(people_with_permissions) end end diff --git a/spec/models/post_spec.rb b/spec/models/post_spec.rb index e2e068b6d..96b271861 100644 --- a/spec/models/post_spec.rb +++ b/spec/models/post_spec.rb @@ -12,7 +12,7 @@ describe Post do end it "should associate the owner if none is present" do - @post.person.should == User.first + @post.person.should == User.owner end end From 3a785e24fdc884d59948b4be95d57e4a69ea1351 Mon Sep 17 00:00:00 2001 From: maxwell Date: Sat, 10 Jul 2010 10:42:38 -0700 Subject: [PATCH 10/10] removed old jquery ajax form thing we never used but made it into the repo --- public/javascripts/jquery_form.js | 675 ------------------------------ 1 file changed, 675 deletions(-) delete mode 100644 public/javascripts/jquery_form.js diff --git a/public/javascripts/jquery_form.js b/public/javascripts/jquery_form.js deleted file mode 100644 index be8c0b6bf..000000000 --- a/public/javascripts/jquery_form.js +++ /dev/null @@ -1,675 +0,0 @@ -/*! - * jQuery Form Plugin - * version: 2.43 (12-MAR-2010) - * @requires jQuery v1.3.2 or later - * - * Examples and documentation at: http://malsup.com/jquery/form/ - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - */ -;(function($) { - -/* - Usage Note: - ----------- - Do not use both ajaxSubmit and ajaxForm on the same form. These - functions are intended to be exclusive. Use ajaxSubmit if you want - to bind your own submit handler to the form. For example, - - $(document).ready(function() { - $('#myForm').bind('submit', function() { - $(this).ajaxSubmit({ - target: '#output' - }); - return false; // <-- important! - }); - }); - - Use ajaxForm when you want the plugin to manage all the event binding - for you. For example, - - $(document).ready(function() { - $('#myForm').ajaxForm({ - target: '#output' - }); - }); - - When using ajaxForm, the ajaxSubmit function will be invoked for you - at the appropriate time. -*/ - -/** - * ajaxSubmit() provides a mechanism for immediately submitting - * an HTML form using AJAX. - */ -$.fn.ajaxSubmit = function(options) { - // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) - if (!this.length) { - log('ajaxSubmit: skipping submit process - no element selected'); - return this; - } - - if (typeof options == 'function') - options = { success: options }; - - var url = $.trim(this.attr('action')); - if (url) { - // clean url (don't include hash vaue) - url = (url.match(/^([^#]+)/)||[])[1]; - } - url = url || window.location.href || ''; - - options = $.extend({ - url: url, - type: this.attr('method') || 'GET', - iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' - }, options || {}); - - // hook for manipulating the form data before it is extracted; - // convenient for use with rich editors like tinyMCE or FCKEditor - var veto = {}; - this.trigger('form-pre-serialize', [this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); - return this; - } - - // provide opportunity to alter form data before it is serialized - if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSerialize callback'); - return this; - } - - var a = this.formToArray(options.semantic); - if (options.data) { - options.extraData = options.data; - for (var n in options.data) { - if(options.data[n] instanceof Array) { - for (var k in options.data[n]) - a.push( { name: n, value: options.data[n][k] } ); - } - else - a.push( { name: n, value: options.data[n] } ); - } - } - - // give pre-submit callback an opportunity to abort the submit - if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSubmit callback'); - return this; - } - - // fire vetoable 'validate' event - this.trigger('form-submit-validate', [a, this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); - return this; - } - - var q = $.param(a); - - if (options.type.toUpperCase() == 'GET') { - options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; - options.data = null; // data is null for 'get' - } - else - options.data = q; // data is the query string for 'post' - - var $form = this, callbacks = []; - if (options.resetForm) callbacks.push(function() { $form.resetForm(); }); - if (options.clearForm) callbacks.push(function() { $form.clearForm(); }); - - // perform a load on the target only if dataType is not provided - if (!options.dataType && options.target) { - var oldSuccess = options.success || function(){}; - callbacks.push(function(data) { - var fn = options.replaceTarget ? 'replaceWith' : 'html'; - $(options.target)[fn](data).each(oldSuccess, arguments); - }); - } - else if (options.success) - callbacks.push(options.success); - - options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg - for (var i=0, max=callbacks.length; i < max; i++) - callbacks[i].apply(options, [data, status, xhr || $form, $form]); - }; - - // are there files to upload? - var files = $('input:file', this).fieldValue(); - var found = false; - for (var j=0; j < files.length; j++) - if (files[j]) - found = true; - - var multipart = false; -// var mp = 'multipart/form-data'; -// multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); - - // options.iframe allows user to force iframe mode - // 06-NOV-09: now defaulting to iframe mode if file input is detected - if ((files.length && options.iframe !== false) || options.iframe || found || multipart) { - // hack to fix Safari hang (thanks to Tim Molendijk for this) - // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d - if (options.closeKeepAlive) - $.get(options.closeKeepAlive, fileUpload); - else - fileUpload(); - } - else - $.ajax(options); - - // fire 'notify' event - this.trigger('form-submit-notify', [this, options]); - return this; - - - // private function for handling file uploads (hat tip to YAHOO!) - function fileUpload() { - var form = $form[0]; - - if ($(':input[name=submit]', form).length) { - alert('Error: Form elements must not be named "submit".'); - return; - } - - var opts = $.extend({}, $.ajaxSettings, options); - var s = $.extend(true, {}, $.extend(true, {}, $.ajaxSettings), opts); - - var id = 'jqFormIO' + (new Date().getTime()); - var $io = $('