From 9571ade89c652e4b5357d3a0ef01fb9a2ac7ac52 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Tue, 21 Sep 2010 12:29:39 -0700 Subject: [PATCH 01/46] basic setup --- Gemfile | 1 + Gemfile.lock | 4 ++++ app/controllers/services_controller.rb | 25 +++++++++++++++++++++ app/controllers/users_controller.rb | 3 +++ app/views/users/edit.html.haml | 8 +++++++ config/environment.rb | 9 +++++++- config/fb_config.yml | 4 ++++ config/routes.rb | 31 +++++++++++++------------- 8 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 app/controllers/services_controller.rb create mode 100644 config/fb_config.yml diff --git a/Gemfile b/Gemfile index cc92bec3d..18cfef692 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,7 @@ gem 'will_paginate', '3.0.pre2' gem 'roxml', :git => 'git://github.com/Empact/roxml.git' gem 'addressable', :require => 'addressable/uri' gem 'json' +gem 'mini_fb' #Standards gem 'pubsubhubbub' diff --git a/Gemfile.lock b/Gemfile.lock index dd181b320..68cf44272 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -142,6 +142,9 @@ GEM mime-types treetop (>= 1.4.5) mime-types (1.16) + mini_fb (1.1.3) + hashie + rest-client mini_magick (2.1) subexec (~> 0.0.4) mocha (0.9.8) @@ -252,6 +255,7 @@ DEPENDENCIES jnunemaker-validatable (= 1.8.4)! json magent! + mini_fb mini_magick mocha mongo_mapper (= 0.8.4)! diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb new file mode 100644 index 000000000..567a1d144 --- /dev/null +++ b/app/controllers/services_controller.rb @@ -0,0 +1,25 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3. See +# the COPYRIGHT file. + + +class ServicesController < ApplicationController + + def create + puts 'services/create' + p params + + code = params['code'] # Facebooks verification string + if code + access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, HOST + "services/create", FB_SECRET, code) + p access_token_hash + @access_token = access_token_hash["access_token"] + + # TODO: This is where you'd want to store the token in your database + # but for now, we'll just keep it in the cookie so we don't need a database + cookies[:access_token] = @access_token + flash[:success] = "Authentication successful." + end + redirect_to edit_user_url current_user + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index dbb69d1a2..76ed944dd 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -13,6 +13,9 @@ class UsersController < ApplicationController @person = @user.person @profile = @user.profile @photos = Photo.find_all_by_person_id(@person.id).paginate :page => params[:page], :order => 'created_at DESC' + + @fb_access_url = MiniFB.oauth_url(FB_APP_ID, HOST + "services/create", + :scope=>MiniFB.scopes.join(",")) end def update diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index fd94b2a42..330ad7f48 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -53,6 +53,14 @@ = p.label :last_name = p.text_field :last_name, :value => @profile.last_name + %br + %br + + %h3 Connect with Facebook + + %p + = link_to "Login to Facebook", @fb_access_url + #submit_block = link_to "Cancel", root_path or diff --git a/config/environment.rb b/config/environment.rb index 385a96651..7bf59851a 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -8,7 +8,14 @@ require File.expand_path('../application', __FILE__) Haml::Template.options[:format] = :html5 Haml::Template.options[:escape_html] = true + +# Load facebook connection application credentials +fb_config = YAML::load(File.open(File.expand_path("./config/fb_config.yml"))) +FB_API_KEY = fb_config['fb_api_key'] +FB_SECRET = fb_config['fb_secret'] +FB_APP_ID = fb_config['fb_app_id'] +HOST = fb_config['host'] + # Initialize the rails application Diaspora::Application.initialize! - diff --git a/config/fb_config.yml b/config/fb_config.yml new file mode 100644 index 000000000..7b69791e5 --- /dev/null +++ b/config/fb_config.yml @@ -0,0 +1,4 @@ +fb_api_key: {dcf4e90df086cf6d3e531b31e043ff32} +fb_secret: {36917c2878d658b8c575952b6a78e3c3} +fb_app_id: {120373411325347} +host: http://localhost:3000/ diff --git a/config/routes.rb b/config/routes.rb index ae757499c..016a89bcb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,32 +5,33 @@ Diaspora::Application.routes.draw do - resources :people, :only => [:index, :show, :destroy] - resources :users, :except => [:create, :new, :show] - resources :status_messages, :only => [:create, :destroy, :show] - resources :comments, :except => [:index] - resources :requests, :except => [:edit, :update] - resources :photos, :except => [:index] + resources :people, :only => [:index, :show, :destroy] + resources :users, :except => [:create, :new, :show] + resources :status_messages, :only => [:create, :destroy, :show] + resources :comments, :except => [:index] + resources :requests, :except => [:edit, :update] + resources :photos, :except => [:index] resources :albums match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends' - match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' - match 'aspects/manage', :to => 'aspects#manage' - resources :aspects, :except => [:edit] + match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' + match 'aspects/manage', :to => 'aspects#manage' + resources :aspects, :except => [:edit] + match 'services/create', :to => "services#create" - match 'warzombie', :to => "dev_utilities#warzombie" - match 'zombiefriends', :to => "dev_utilities#zombiefriends" - match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept" - match 'set_backer_number', :to => "dev_utilities#set_backer_number" - match 'set_profile_photo', :to => "dev_utilities#set_profile_photo" + match 'warzombie', :to => "dev_utilities#warzombie" + match 'zombiefriends', :to => "dev_utilities#zombiefriends" + match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept" + match 'set_backer_number', :to => "dev_utilities#set_backer_number" + match 'set_profile_photo', :to => "dev_utilities#set_profile_photo" #routes for devise, not really sure you will need to mess with this in the future, lets put default, #non mutable stuff in anohter file devise_for :users, :controllers => {:registrations => "registrations"} match 'login', :to => 'devise/sessions#new', :as => "new_user_session" match 'logout', :to => 'devise/sessions#destroy', :as => "destroy_user_session" - match 'signup', :to => 'registrations#new', :as => "new_user_registration" + match 'signup', :to => 'registrations#new', :as => "new_user_registration" match 'get_to_the_choppa', :to => redirect("/signup") #public routes From fcc681df71f7876a609b105e06fa72d173e5999b Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 16:32:52 -0700 Subject: [PATCH 02/46] DG IZ moved to be APP_CONFIG for host --- app/controllers/services_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/views/shared/_aspect_nav.haml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 567a1d144..b254b0a63 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -11,7 +11,7 @@ class ServicesController < ApplicationController code = params['code'] # Facebooks verification string if code - access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, HOST + "services/create", FB_SECRET, code) + access_token_hash = MiniFB.oauth_access_token(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", FB_SECRET, code) p access_token_hash @access_token = access_token_hash["access_token"] diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 76ed944dd..c425729b2 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -14,7 +14,7 @@ class UsersController < ApplicationController @profile = @user.profile @photos = Photo.find_all_by_person_id(@person.id).paginate :page => params[:page], :order => 'created_at DESC' - @fb_access_url = MiniFB.oauth_url(FB_APP_ID, HOST + "services/create", + @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", :scope=>MiniFB.scopes.join(",")) end diff --git a/app/views/shared/_aspect_nav.haml b/app/views/shared/_aspect_nav.haml index dbca3bbef..55da1bcdf 100644 --- a/app/views/shared/_aspect_nav.haml +++ b/app/views/shared/_aspect_nav.haml @@ -8,11 +8,11 @@ - for aspect in @aspects %li{:class => ("selected" if current_aspect?(aspect))} = link_for_aspect aspect - - %ul{ :style => "position:absolute;right:0;bottom:0.01em;"} %li{:class => ("selected" if @aspect == :all)} = link_to "All Aspects", root_url + %ul{ :style => "position:absolute;right:0;bottom:0.01em;"} + %li{ :style => "margin-right:0;", :class => ("selected" if @aspect == :manage)} = link_to ( (@request_count == 0)? "Manage Aspects" : "Manage Aspects (#{@request_count})"), {:controller => :aspects, :action => :manage}, :class => "edit_aspect_button", :class => new_request(@request_count), :title => "Manage your Aspects" From 53c0aff23db50d39cd814704a2eabfc64f5592fe Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 16:34:42 -0700 Subject: [PATCH 03/46] deploy from the right branch --- config/deploy_config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy_config.yml b/config/deploy_config.yml index c653b6565..f724ec383 100644 --- a/config/deploy_config.yml +++ b/config/deploy_config.yml @@ -8,7 +8,7 @@ cross_server: deploy_to: '/usr/local/app/diaspora' user: 'root' repo: 'git@github.com:diaspora/diaspora.git' - branch: 'master' + branch: 'fb' default_env: 'development' servers: tom: From 159d72c04c1d1f3c1cc6fc69f2e32b1c3eb5080d Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 16:56:39 -0700 Subject: [PATCH 04/46] DG IZ; logged in as? --- app/controllers/application_controller.rb | 6 ++++++ app/views/users/edit.html.haml | 14 +++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f0ca5bfc8..0060a8989 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,6 +9,7 @@ class ApplicationController < ActionController::Base before_filter :set_friends_and_status, :except => [:create, :update] before_filter :count_requests + before_filter :fb_user_info layout :layout_by_resource @@ -37,4 +38,9 @@ class ApplicationController < ActionController::Base @request_count = Request.for_user(current_user).size if current_user end + def fb_user_info + @access_token = cookies[:access_token] + @logged_in = @access_token.present? + end + end diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index ddbc9c10a..bfb4e92e1 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -56,10 +56,18 @@ %br %br - %h3 Connect with Facebook - %p - = link_to "Login to Facebook", @fb_access_url + %h2 Services + + %h3 Facebook + + - if @logged_in + Logged in to facebook as + - @response_hash = MiniFB.get(@access_token, @id, :type => "user") + = @response_hash[:user][:name] + %p + = link_to "Login to Facebook", @fb_access_url + #submit_block = link_to "Cancel", root_path From 26478403e2efeb2906510ea74509e2870cc3e06e Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 17:14:58 -0700 Subject: [PATCH 05/46] DG IZ; connecting/disconnecting from fb --- app/controllers/application_controller.rb | 2 +- app/controllers/services_controller.rb | 11 +++++++++-- app/views/users/edit.html.haml | 15 ++++++++------- config/routes.rb | 1 + 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0060a8989..2fecb4f90 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -39,7 +39,7 @@ class ApplicationController < ActionController::Base end def fb_user_info - @access_token = cookies[:access_token] + @access_token = session[:access_token] @logged_in = @access_token.present? end diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index b254b0a63..ab654e739 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -16,10 +16,17 @@ class ServicesController < ApplicationController @access_token = access_token_hash["access_token"] # TODO: This is where you'd want to store the token in your database - # but for now, we'll just keep it in the cookie so we don't need a database - cookies[:access_token] = @access_token + # but for now, we'll just keep it in the session so we don't need a database + session[:access_token] = @access_token flash[:success] = "Authentication successful." end redirect_to edit_user_url current_user end + + def destroy + session[:access_token] = nil + session[:user_id] = nil + redirect_to edit_user_url current_url + end + end diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index bfb4e92e1..924b0f72f 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -60,13 +60,14 @@ %h2 Services %h3 Facebook - - - if @logged_in - Logged in to facebook as - - @response_hash = MiniFB.get(@access_token, @id, :type => "user") - = @response_hash[:user][:name] - %p - = link_to "Login to Facebook", @fb_access_url + %p + - if @logged_in + Connected to facebook as + - @response_hash = MiniFB.get(@access_token, 'me') + = @response_hash[:name] + = link_to "Disconnect from Facebook", services_destroy_path + - else + = link_to "Connect to Facebook", @fb_access_url #submit_block diff --git a/config/routes.rb b/config/routes.rb index 016a89bcb..57e58e9aa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,6 +19,7 @@ Diaspora::Application.routes.draw do resources :aspects, :except => [:edit] match 'services/create', :to => "services#create" + match 'services/destroy', :to => "services#destroy" match 'warzombie', :to => "dev_utilities#warzombie" match 'zombiefriends', :to => "dev_utilities#zombiefriends" From aef3c8d7bbeea1980845ad61a091b73cb2992e8f Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 17:16:16 -0700 Subject: [PATCH 06/46] indent, whoops --- app/views/users/edit.html.haml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 924b0f72f..1973d9a25 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -59,15 +59,15 @@ %h2 Services - %h3 Facebook - %p - - if @logged_in - Connected to facebook as - - @response_hash = MiniFB.get(@access_token, 'me') - = @response_hash[:name] - = link_to "Disconnect from Facebook", services_destroy_path - - else - = link_to "Connect to Facebook", @fb_access_url + %h3 Facebook + %p + - if @logged_in + Connected to facebook as + - @response_hash = MiniFB.get(@access_token, 'me') + = @response_hash[:name] + = link_to "Disconnect from Facebook", services_destroy_path + - else + = link_to "Connect to Facebook", @fb_access_url #submit_block From ddbde60e8cf715ca25071bc2e3ad06d20686b363 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 17:17:24 -0700 Subject: [PATCH 07/46] another indent... --- app/views/users/edit.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 1973d9a25..56a537c98 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -60,7 +60,7 @@ %h2 Services %h3 Facebook - %p + %p - if @logged_in Connected to facebook as - @response_hash = MiniFB.get(@access_token, 'me') From ae58120deb8071092994a048c3e010a31014cd34 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 17:18:46 -0700 Subject: [PATCH 08/46] another typo... --- app/controllers/services_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index ab654e739..e13820b5a 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -26,7 +26,7 @@ class ServicesController < ApplicationController def destroy session[:access_token] = nil session[:user_id] = nil - redirect_to edit_user_url current_url + redirect_to edit_user_url current_user end end From bc70ebdb950836d0e1d1bd661516ac749d2243a1 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 17:33:57 -0700 Subject: [PATCH 09/46] DG IZ; quick form in user edit --- app/controllers/services_controller.rb | 8 ++++++++ app/views/users/edit.html.haml | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index e13820b5a..d6a7db8a7 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -29,4 +29,12 @@ class ServicesController < ApplicationController redirect_to edit_user_url current_user end + def fb_post + id = 'me' + type = 'feed' + + @res = MiniFB.post(@access_token, id, :type=>type, :metadata=>true, :params=>params) + redirect_to user_edit_url current_user + end + end diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 56a537c98..5f8e1e4f6 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -65,6 +65,12 @@ Connected to facebook as - @response_hash = MiniFB.get(@access_token, 'me') = @response_hash[:name] + + + - form_tag :controller => "services", :action => "fb_post" + = text_area_tag "message" + = submit_tag "send it off" + = link_to "Disconnect from Facebook", services_destroy_path - else = link_to "Connect to Facebook", @fb_access_url From 0c2480c9be3b4369ab30df8c16cbcf225ccb94fc Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 17:34:57 -0700 Subject: [PATCH 10/46] DG IZ; quick form in user edit --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.rb b/config/routes.rb index 57e58e9aa..269622156 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,7 @@ Diaspora::Application.routes.draw do match 'services/create', :to => "services#create" match 'services/destroy', :to => "services#destroy" + match 'services/fb_post', :to => "services#fb_post" match 'warzombie', :to => "dev_utilities#warzombie" match 'zombiefriends', :to => "dev_utilities#zombiefriends" From fc0350e4e13e8934a987b4310a1b489babe836b4 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 17:49:11 -0700 Subject: [PATCH 11/46] DG IZ; user can post a status update from user edit page to facebook. --- app/controllers/services_controller.rb | 2 +- app/views/users/edit.html.haml | 38 ++++++++++++++------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index d6a7db8a7..373eb100e 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -34,7 +34,7 @@ class ServicesController < ApplicationController type = 'feed' @res = MiniFB.post(@access_token, id, :type=>type, :metadata=>true, :params=>params) - redirect_to user_edit_url current_user + redirect_to edit_user_url current_user end end diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 5f8e1e4f6..1c345559e 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -57,29 +57,33 @@ %br - %h2 Services - - %h3 Facebook - %p - - if @logged_in - Connected to facebook as - - @response_hash = MiniFB.get(@access_token, 'me') - = @response_hash[:name] - - - - form_tag :controller => "services", :action => "fb_post" - = text_area_tag "message" - = submit_tag "send it off" - - = link_to "Disconnect from Facebook", services_destroy_path - - else - = link_to "Connect to Facebook", @fb_access_url #submit_block = link_to "Cancel", root_path or = f.submit "Update Profile" + + + +%h2 Services + +%h3 Facebook +%p + - if @logged_in + Connected to facebook as + - @response_hash = MiniFB.get(@access_token, 'me') + = @response_hash[:name] + + + - form_tag :controller => "services", :action => "fb_post" do + = text_area_tag "message" + = submit_tag "send it off" + + = link_to "Disconnect from Facebook", services_destroy_path + - else + = link_to "Connect to Facebook", @fb_access_url + - end #content_bottom .back From 7303212784c865cf1aaea8257c13cdd1bf30e239 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Wed, 22 Sep 2010 17:50:47 -0700 Subject: [PATCH 12/46] DG IZ; haml typo --- app/views/users/edit.html.haml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 1c345559e..fb9de28be 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -75,15 +75,13 @@ - @response_hash = MiniFB.get(@access_token, 'me') = @response_hash[:name] - - - form_tag :controller => "services", :action => "fb_post" do + - form_tag "/services/fb_post" do = text_area_tag "message" = submit_tag "send it off" = link_to "Disconnect from Facebook", services_destroy_path - else = link_to "Connect to Facebook", @fb_access_url - - end #content_bottom .back From 48c212c1ab8e1e46a026bf07cbb102203ff32020 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 12:18:26 -0700 Subject: [PATCH 13/46] made a public view, copied the fb publisher there --- app/controllers/aspects_controller.rb | 10 ++++++++++ app/views/shared/_aspect_nav.haml | 2 ++ config/fb_config.yml | 2 +- config/routes.rb | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 779ce0f6f..9112792c1 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -45,6 +45,16 @@ class AspectsController < ApplicationController respond_with @aspect end + def public + @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", + :scope=>MiniFB.scopes.join(",")) + + @posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' + @aspect = :all + + respond_with @aspect + end + def manage @aspect = :manage @remote_requests = Request.for_user(current_user).all diff --git a/app/views/shared/_aspect_nav.haml b/app/views/shared/_aspect_nav.haml index 55da1bcdf..ebfd2b57d 100644 --- a/app/views/shared/_aspect_nav.haml +++ b/app/views/shared/_aspect_nav.haml @@ -12,6 +12,8 @@ = link_to "All Aspects", root_url %ul{ :style => "position:absolute;right:0;bottom:0.01em;"} + %li{:class => ("selected" if @aspect == :all)} + = link_to "Public", aspects_public_path %li{ :style => "margin-right:0;", :class => ("selected" if @aspect == :manage)} = link_to ( (@request_count == 0)? "Manage Aspects" : "Manage Aspects (#{@request_count})"), {:controller => :aspects, :action => :manage}, :class => "edit_aspect_button", :class => new_request(@request_count), :title => "Manage your Aspects" diff --git a/config/fb_config.yml b/config/fb_config.yml index 7b69791e5..4c3309fac 100644 --- a/config/fb_config.yml +++ b/config/fb_config.yml @@ -1,4 +1,4 @@ fb_api_key: {dcf4e90df086cf6d3e531b31e043ff32} -fb_secret: {36917c2878d658b8c575952b6a78e3c3} +fb_secret: {7fe864834726f8a5e65bc93928b99a53} fb_app_id: {120373411325347} host: http://localhost:3000/ diff --git a/config/routes.rb b/config/routes.rb index 269622156..112ff5768 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,7 @@ Diaspora::Application.routes.draw do match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends' match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' match 'aspects/manage', :to => 'aspects#manage' + match 'aspects/public', :to => 'aspects#public' resources :aspects, :except => [:edit] match 'services/create', :to => "services#create" From 5857838a0a6ece7f42da2df6264c4d334e8e5c6a Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 12:29:00 -0700 Subject: [PATCH 14/46] adding the new files --- app/views/aspects/public.html.haml | 35 ++++++++++++++++++++++++++++++ config/deploy_config.yml | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 app/views/aspects/public.html.haml diff --git a/app/views/aspects/public.html.haml b/app/views/aspects/public.html.haml new file mode 100644 index 000000000..add02f490 --- /dev/null +++ b/app/views/aspects/public.html.haml @@ -0,0 +1,35 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3. See +-# the COPYRIGHT file. + + +- content_for :page_title do + = link_to "photos", albums_path(:aspect => @aspect) + +- content_for :left_pane do + = render "shared/aspect_friends" + +- content_for :publish do + = render "shared/publisher", :aspect_ids => :public + +%h3 Facebook +%p + - if @logged_in + Connected to facebook as + - @response_hash = MiniFB.get(@access_token, 'me') + = @response_hash[:name] + + - form_tag "/services/fb_post" do + = text_area_tag "message" + = submit_tag "send it off" + + = link_to "Disconnect from Facebook", services_destroy_path + - else + = link_to "Connect to Facebook", @fb_access_url + +%ul#stream + - for post in @posts + = render type_partial(post), :post => post unless post.class == Album +#pagination + = will_paginate @posts + diff --git a/config/deploy_config.yml b/config/deploy_config.yml index f724ec383..fcecaa6b1 100644 --- a/config/deploy_config.yml +++ b/config/deploy_config.yml @@ -7,7 +7,7 @@ cross_server: deploy_to: '/usr/local/app/diaspora' user: 'root' - repo: 'git@github.com:diaspora/diaspora.git' + repo: 'git://github.com/diaspora/diaspora.git' branch: 'fb' default_env: 'development' servers: From f0999628ae651309c2d4b9a6b0b895fd7e7e9c09 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 14:43:08 -0700 Subject: [PATCH 15/46] trying to get friends from fb --- app/views/users/edit.html.haml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index fb9de28be..bbd84ec92 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -75,10 +75,12 @@ - @response_hash = MiniFB.get(@access_token, 'me') = @response_hash[:name] + - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") + = @fb_friends.inspect + - form_tag "/services/fb_post" do = text_area_tag "message" = submit_tag "send it off" - = link_to "Disconnect from Facebook", services_destroy_path - else = link_to "Connect to Facebook", @fb_access_url From 19c3a5ce4b32b9183d593ea92a25a536a9cdd2e2 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 15:07:07 -0700 Subject: [PATCH 16/46] fetching friend data --- app/views/users/edit.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index bbd84ec92..3045a2ad2 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -76,7 +76,8 @@ = @response_hash[:name] - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") - = @fb_friends.inspect + - @fb_friends[:data] do |friend| + = MiniFB.get(@access_token, friend[:id]).inspect - form_tag "/services/fb_post" do = text_area_tag "message" From 1fdbc637d173a5a473339686dbd79008874d5044 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 15:18:29 -0700 Subject: [PATCH 17/46] trying profile pictures on remote --- app/views/users/edit.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 3045a2ad2..7d6d0d552 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -76,8 +76,8 @@ = @response_hash[:name] - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") - - @fb_friends[:data] do |friend| - = MiniFB.get(@access_token, friend[:id]).inspect + - @fb_friends[:data].each do |friend| + = image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" - form_tag "/services/fb_post" do = text_area_tag "message" From fc2cf4fde64a39694bd7b8d3c1a23ed6ba4b2d28 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 15:21:15 -0700 Subject: [PATCH 18/46] typo --- app/views/users/edit.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index 7d6d0d552..e4789e361 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -77,7 +77,7 @@ - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") - @fb_friends[:data].each do |friend| - = image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" + = image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" ) - form_tag "/services/fb_post" do = text_area_tag "message" From be10681945160fb60d4ab644d5fc7f8503d174f5 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 16:06:55 -0700 Subject: [PATCH 19/46] IZ tying the publisher to fb in public aspect --- app/controllers/status_messages_controller.rb | 10 ++++++++++ app/views/aspects/public.html.haml | 5 ++++- app/views/shared/_aspect_nav.haml | 2 +- app/views/shared/_publisher.haml | 8 +++++++- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 5a8efbe06..5dc1cbce0 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -13,6 +13,16 @@ class StatusMessagesController < ApplicationController params[:status_message][:to] = params[:aspect_ids] data = clean_hash params[:status_message] + + if @logged_in && params[:status_message][:to] == :public + id = 'me' + type = 'feed' + + @res = MiniFB.post(@access_token, id, :type=>type, + :metadata=>true, :params=>{:message => params[:status_message][:message]}) + + params[:status_message][:to] == :all + end @status_message = current_user.post(:status_message, data) respond_with @status_message diff --git a/app/views/aspects/public.html.haml b/app/views/aspects/public.html.haml index add02f490..e8872cfb7 100644 --- a/app/views/aspects/public.html.haml +++ b/app/views/aspects/public.html.haml @@ -10,7 +10,10 @@ = render "shared/aspect_friends" - content_for :publish do - = render "shared/publisher", :aspect_ids => :public + - if @logged_in + = render "shared/publisher", :aspect_ids => :public + - else + = render "shared/publisher", :aspect_ids => :all %h3 Facebook %p diff --git a/app/views/shared/_aspect_nav.haml b/app/views/shared/_aspect_nav.haml index ebfd2b57d..1d49ef049 100644 --- a/app/views/shared/_aspect_nav.haml +++ b/app/views/shared/_aspect_nav.haml @@ -12,7 +12,7 @@ = link_to "All Aspects", root_url %ul{ :style => "position:absolute;right:0;bottom:0.01em;"} - %li{:class => ("selected" if @aspect == :all)} + %li{:class => ("selected" if @aspect == :public)} = link_to "Public", aspects_public_path %li{ :style => "margin-right:0;", :class => ("selected" if @aspect == :manage)} diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 130f136a9..a84b39052 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -16,7 +16,13 @@ going to... - for aspect in @aspects %li - = check_box_tag("aspect_ids[]", aspect.id, @aspect == :all || current_aspect?(aspect) ) + = check_box_tag("aspect_ids[]", aspect.id, @aspect == :public || @aspect == :all || current_aspect?(aspect) ) = aspect.name = f.submit "Share" + + - if @logged_in + - @response_hash = MiniFB.get(@access_token, 'me') + = "going to Facebook as #{@response_hash[:name]}" + + From 4d2bd52310f1dbd49a47f7f5906ae16f3cdfb905 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 16:41:05 -0700 Subject: [PATCH 20/46] public aspect param on statusMessage create and in the partial --- app/controllers/status_messages_controller.rb | 5 ++--- app/views/shared/_publisher.haml | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 5dc1cbce0..e970fb2bb 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -14,14 +14,12 @@ class StatusMessagesController < ApplicationController data = clean_hash params[:status_message] - if @logged_in && params[:status_message][:to] == :public + if @logged_in && params[:status_message][:public] == true id = 'me' type = 'feed' @res = MiniFB.post(@access_token, id, :type=>type, :metadata=>true, :params=>{:message => params[:status_message][:message]}) - - params[:status_message][:to] == :all end @status_message = current_user.post(:status_message, data) @@ -44,6 +42,7 @@ class StatusMessagesController < ApplicationController return { :message => params[:message], :to => params[:to] + :public => params[:public] } end end diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index a84b39052..ae61300f3 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -11,12 +11,13 @@ %p %label{:for => "status_message_message"} Message = f.text_area :message, :rows => 2, :value => params[:prefill] + = f.hidden_field( :public, :value => (params[:action] == 'public') ) %ul.aspect_selector{ :style => "display:none;"} going to... - for aspect in @aspects %li - = check_box_tag("aspect_ids[]", aspect.id, @aspect == :public || @aspect == :all || current_aspect?(aspect) ) + = check_box_tag("aspect_ids[]", aspect.id, (params[:action] == 'public') || @aspect == :all || current_aspect?(aspect) ) = aspect.name = f.submit "Share" From d7833c66b24ea5a157ab3331acb8995fb2621f30 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 16:48:58 -0700 Subject: [PATCH 21/46] typo --- app/controllers/status_messages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index e970fb2bb..8611b3804 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -41,7 +41,7 @@ class StatusMessagesController < ApplicationController def clean_hash(params) return { :message => params[:message], - :to => params[:to] + :to => params[:to], :public => params[:public] } end From 107fb58917979d76f29fd7b7e2e29258b5831ed0 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 17:04:27 -0700 Subject: [PATCH 22/46] added a logger statement --- app/controllers/status_messages_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 8611b3804..28ce83ecd 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -17,7 +17,8 @@ class StatusMessagesController < ApplicationController if @logged_in && params[:status_message][:public] == true id = 'me' type = 'feed' - + + Rails.logger.info("Sending a message: #{params[:status_message][:message]} to Facebook") @res = MiniFB.post(@access_token, id, :type=>type, :metadata=>true, :params=>{:message => params[:status_message][:message]}) end From 0d71a1896c8b41a8ff76d632b2e225be27f09ae7 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 17:11:42 -0700 Subject: [PATCH 23/46] posting to FB from public now works --- app/controllers/status_messages_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index 28ce83ecd..98ae19b82 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -14,7 +14,7 @@ class StatusMessagesController < ApplicationController data = clean_hash params[:status_message] - if @logged_in && params[:status_message][:public] == true + if @logged_in && params[:status_message][:public] == 'true' id = 'me' type = 'feed' From 75e1ddf9d28ec19d41b03dce3e844bafc776ff6b Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 17:17:18 -0700 Subject: [PATCH 24/46] saying going to FB in public aspect --- app/views/shared/_publisher.haml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index ae61300f3..fdacfccb4 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -11,6 +11,7 @@ %p %label{:for => "status_message_message"} Message = f.text_area :message, :rows => 2, :value => params[:prefill] + = "going to Facebook as #{MiniFB.get(@access_token, 'me')[:name]}" if @logged_in = f.hidden_field( :public, :value => (params[:action] == 'public') ) %ul.aspect_selector{ :style => "display:none;"} @@ -22,8 +23,3 @@ = f.submit "Share" - - if @logged_in - - @response_hash = MiniFB.get(@access_token, 'me') - = "going to Facebook as #{@response_hash[:name]}" - - From 11dc2253111af29ae6644a54e1c7aec7ec53a5c7 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 17:19:43 -0700 Subject: [PATCH 25/46] removed the old publish box --- app/views/aspects/public.html.haml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/app/views/aspects/public.html.haml b/app/views/aspects/public.html.haml index e8872cfb7..def45bc7c 100644 --- a/app/views/aspects/public.html.haml +++ b/app/views/aspects/public.html.haml @@ -15,21 +15,6 @@ - else = render "shared/publisher", :aspect_ids => :all -%h3 Facebook -%p - - if @logged_in - Connected to facebook as - - @response_hash = MiniFB.get(@access_token, 'me') - = @response_hash[:name] - - - form_tag "/services/fb_post" do - = text_area_tag "message" - = submit_tag "send it off" - - = link_to "Disconnect from Facebook", services_destroy_path - - else - = link_to "Connect to Facebook", @fb_access_url - %ul#stream - for post in @posts = render type_partial(post), :post => post unless post.class == Album From 796f198d8c717d5211708a13a8e304e45000942e Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 17:20:55 -0700 Subject: [PATCH 26/46] notification only on user page --- app/views/shared/_publisher.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index fdacfccb4..4714b1f1f 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -11,7 +11,7 @@ %p %label{:for => "status_message_message"} Message = f.text_area :message, :rows => 2, :value => params[:prefill] - = "going to Facebook as #{MiniFB.get(@access_token, 'me')[:name]}" if @logged_in + = "going to Facebook as #{MiniFB.get(@access_token, 'me')[:name]}" if @logged_in && (params[:action] == 'public') = f.hidden_field( :public, :value => (params[:action] == 'public') ) %ul.aspect_selector{ :style => "display:none;"} From eaea26e58d7781c79d7ea962b491cfd4aeb06445 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 19:33:33 -0700 Subject: [PATCH 27/46] the public aspect is now set in application controller --- app/controllers/application_controller.rb | 4 +++- app/controllers/aspects_controller.rb | 1 - app/views/shared/_aspect_friends.haml | 2 +- app/views/shared/_publisher.haml | 5 +++-- app/views/shared/_sub_header.haml | 2 ++ 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2fecb4f90..1cbdc7c39 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -23,7 +23,9 @@ class ApplicationController < ActionController::Base def set_friends_and_status if current_user - if params[:aspect] == nil || params[:aspect] == 'all' + if params[:action] == 'public' + @aspect = :public + elsif params[:aspect] == nil || params[:aspect] == 'all' @aspect = :all else @aspect = current_user.aspect_by_id( params[:aspect]) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 9112792c1..f05edfe6e 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -50,7 +50,6 @@ class AspectsController < ApplicationController :scope=>MiniFB.scopes.join(",")) @posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' - @aspect = :all respond_with @aspect end diff --git a/app/views/shared/_aspect_friends.haml b/app/views/shared/_aspect_friends.haml index 6ab286a81..f4aa811b1 100644 --- a/app/views/shared/_aspect_friends.haml +++ b/app/views/shared/_aspect_friends.haml @@ -8,7 +8,7 @@ - for friend in @friends = person_image_link(friend) - -unless @aspect == :all + -unless (@aspect == :all) || (@aspect == :public) = link_to (image_tag('add_friend_button.png', :height => "50px", :width => "50px")), "#add_request_pane", :id => 'add_request_button' .yo{:style => 'display:none'} diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 4714b1f1f..54f14c27a 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -5,20 +5,21 @@ #publisher = owner_image_tag + = @aspect = form_for StatusMessage.new, :remote => true do |f| = f.error_messages %p %label{:for => "status_message_message"} Message = f.text_area :message, :rows => 2, :value => params[:prefill] - = "going to Facebook as #{MiniFB.get(@access_token, 'me')[:name]}" if @logged_in && (params[:action] == 'public') + = "going to Facebook as #{MiniFB.get(@access_token, 'me')[:name]}" if @logged_in && @aspect == :public = f.hidden_field( :public, :value => (params[:action] == 'public') ) %ul.aspect_selector{ :style => "display:none;"} going to... - for aspect in @aspects %li - = check_box_tag("aspect_ids[]", aspect.id, (params[:action] == 'public') || @aspect == :all || current_aspect?(aspect) ) + = check_box_tag("aspect_ids[]", aspect.id, @aspect == :public || @aspect == :all || current_aspect?(aspect) ) = aspect.name = f.submit "Share" diff --git a/app/views/shared/_sub_header.haml b/app/views/shared/_sub_header.haml index 4e0e2aca4..c8b2bd5e9 100644 --- a/app/views/shared/_sub_header.haml +++ b/app/views/shared/_sub_header.haml @@ -10,6 +10,8 @@ = link_to "All Aspects", root_path - elsif @aspect == :manage = "Manage Aspects" + - elsif @aspect == :public + = "Public" - else = link_to @aspect.name, @aspect From 265753b5fecedd83c8432b952169024cebe7d501 Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 23 Sep 2010 20:13:07 -0700 Subject: [PATCH 28/46] user edit is now divided into real sections --- app/views/layouts/application.html.haml | 2 +- app/views/users/_profile.haml | 59 ++++++++++++++ app/views/users/_services.haml | 28 +++++++ app/views/users/edit.html.haml | 98 +++++------------------- public/stylesheets/application.css | 22 +++--- public/stylesheets/sass/application.sass | 31 +++++--- 6 files changed, 140 insertions(+), 100 deletions(-) create mode 100644 app/views/users/_profile.haml create mode 100644 app/views/users/_services.haml diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 4a3ec2dbb..4226ef139 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -50,7 +50,7 @@ = text_field_tag 'q' %li= link_to current_user.real_name, current_user.person - %li= link_to "edit profile", edit_user_path(current_user) + %li= link_to "settings", edit_user_path(current_user) %li= link_to "logout", destroy_user_session_path = render "shared/aspect_nav" diff --git a/app/views/users/_profile.haml b/app/views/users/_profile.haml new file mode 100644 index 000000000..e1da95649 --- /dev/null +++ b/app/views/users/_profile.haml @@ -0,0 +1,59 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3. See +-# the COPYRIGHT file. + + +%h2 Profile + += form_for @user do |f| + = f.error_messages + + = f.fields_for :profile do |p| + + %h3 Picture + %div#image_picker + = p.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field' + + - unless @photos.nil? || @photos.empty? + - for photo in @photos + - if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium)) + %div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'} + = check_box_tag 'checked_photo', true, true + = link_to image_tag(photo.url(:thumb_medium)), "#" + - else + %div.small_photo{:id => photo.url(:thumb_medium)} + = check_box_tag 'checked_photo' + = link_to image_tag(photo.url(:thumb_medium)), "#" + + - else + You don't have any photos! Go to the + = link_to "albums", albums_path(:aspect => 'all') + page to upload some. + + =will_paginate @photos + + %br + + %h3 Info + + %p + %b + DIASPORA USERNAME: + = @user.diaspora_handle + + %p + = p.label :first_name + = p.text_field :first_name, :value => @profile.first_name + %p + = p.label :last_name + = p.text_field :last_name, :value => @profile.last_name + + #submit_block + = link_to "Cancel", root_path + or + = f.submit "Update Profile" + +#content_bottom + .back + = link_to "⇧ home", root_path + diff --git a/app/views/users/_services.haml b/app/views/users/_services.haml new file mode 100644 index 000000000..c6e31939a --- /dev/null +++ b/app/views/users/_services.haml @@ -0,0 +1,28 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3. See +-# the COPYRIGHT file. + + +%h2 Services + +%h3 Facebook +%p + - if @logged_in + Connected to facebook as + - @response_hash = MiniFB.get(@access_token, 'me') + = @response_hash[:name] + + - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") + - @fb_friends[:data].each do |friend| + = image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" ) + + - form_tag "/services/fb_post" do + = text_area_tag "message" + = submit_tag "send it off" + = link_to "Disconnect from Facebook", services_destroy_path + - else + = link_to "Connect to Facebook", @fb_access_url + + #content_bottom + .back + = link_to "⇧ home", root_path diff --git a/app/views/users/edit.html.haml b/app/views/users/edit.html.haml index e4789e361..b4ef0226c 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -3,89 +3,29 @@ -# the COPYRIGHT file. +:javascript + $("#settings_nav li > a").click( function() { + var target = "#"+$(this).attr('class'); + if( !$(target).is(":visible") ) { + $(".settings_pane").fadeOut(200, function() { + $(target).delay(200).fadeIn(200); + }); + } + }); + + - content_for :publish do %h1 - Editing profile + Settings - content_for :left_pane do - \. - -= form_for @user do |f| - = f.error_messages - - = f.fields_for :profile do |p| - - %h3 Picture - %div#image_picker - = p.hidden_field :image_url, :value => (@profile.image_url if @profile.image_url), :id => 'image_url_field' - - - unless @photos.nil? || @photos.empty? - - for photo in @photos - - if @profile.image_url && @profile.image_url.include?(photo.url(:thumb_medium)) - %div.small_photo{:id => photo.url(:thumb_medium), :class=>'selected'} - = check_box_tag 'checked_photo', true, true - = link_to image_tag(photo.url(:thumb_medium)), "#" - - else - %div.small_photo{:id => photo.url(:thumb_medium)} - = check_box_tag 'checked_photo' - = link_to image_tag(photo.url(:thumb_medium)), "#" - - - else - You don't have any photos! Go to the - = link_to "albums", albums_path(:aspect => 'all') - page to upload some. - - =will_paginate @photos - - %br - - %h3 Info - - %p - %b - DIASPORA USERNAME: - = @user.diaspora_handle - - %p - = p.label :first_name - = p.text_field :first_name, :value => @profile.first_name - %p - = p.label :last_name - = p.text_field :last_name, :value => @profile.last_name - - %br - %br + %ul#settings_nav + %li=link_to 'Profile', '#', :class => 'profile' + %li=link_to 'Services', '#', :class => 'services' +#profile.settings_pane{:style=>"display:block;"} + = render 'users/profile' +#services.settings_pane + = render 'users/services' - - #submit_block - = link_to "Cancel", root_path - or - = f.submit "Update Profile" - - - -%h2 Services - -%h3 Facebook -%p - - if @logged_in - Connected to facebook as - - @response_hash = MiniFB.get(@access_token, 'me') - = @response_hash[:name] - - - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") - - @fb_friends[:data].each do |friend| - = image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" ) - - - form_tag "/services/fb_post" do - = text_area_tag "message" - = submit_tag "send it off" - = link_to "Disconnect from Facebook", services_destroy_path - - else - = link_to "Connect to Facebook", @fb_access_url - -#content_bottom - .back - = link_to "⇧ home", root_path diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 82bbd8b6d..4c83aa0c2 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -659,15 +659,19 @@ h1.big_text { -moz-box-shadow: 0 2px 4px #333333; opacity: 0.9; } -#notification_badge { - position: fixed; - bottom: 0; - margin-left: 854px; } - #notification_badge a { - background-color: #eeeeee; - border: 1px solid #cccccc; - border-bottom: none; - padding: 3px 10px; } +ul#settings_nav { + list-style: none; + padding: 0; + marign: 0; + font-size: larger; } + ul#settings_nav > li a { + display: block; + height: 100%; + border-bottom: 1px solid #eeeeee; + padding: 5px 0; } + +.settings_pane { + display: none; } #fancybox-close:hover { background-color: transparent; } diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 7c77a0b79..890ef7708 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -839,21 +839,30 @@ h1.big_text :-moz-box-shadow 0 2px 4px #333 :opacity 0.9 -#notification_badge - :position fixed - :bottom 0 - :margin - :left 854px +ul#settings_nav + :list + :style none + :padding 0 + :marign 0 - a - :background - :color #eee + :font + :size larger - :border 1px solid #ccc - :bottom none + > li + + a + :display block + :height 100% + :border + :bottom 1px solid #eee + :padding 5px 0 + + +.settings_pane + :display none - :padding 3px 10px #fancybox-close:hover :background :color transparent + From a594c9a34f16173468c815537d0fe96e915af6c7 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 20:19:02 -0700 Subject: [PATCH 29/46] friends in the public bucket --- app/views/shared/_aspect_friends.haml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/views/shared/_aspect_friends.haml b/app/views/shared/_aspect_friends.haml index f4aa811b1..10a0da317 100644 --- a/app/views/shared/_aspect_friends.haml +++ b/app/views/shared/_aspect_friends.haml @@ -7,7 +7,11 @@ = owner_image_link - for friend in @friends = person_image_link(friend) - + - if @logged_in && (@aspect == :public) + Facebook Friends + - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") + - @fb_friends[:data].each do |friend| + = image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" ) -unless (@aspect == :all) || (@aspect == :public) = link_to (image_tag('add_friend_button.png', :height => "50px", :width => "50px")), "#add_request_pane", :id => 'add_request_button' From a6c1ff8ce236ac03581169483c73eec21370e017 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 20:21:17 -0700 Subject: [PATCH 30/46] fixed the deploy scripts --- db/seeds/backer.rb | 4 ++-- db/seeds/tom.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 20fe90fdf..12e6236f8 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -44,8 +44,8 @@ end def set_app_config username current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example'))) current_config[Rails.env.to_s] ||= {} - current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" - current_config['default']['pod_url'] = "#{username}.joindiaspora.com" + current_config[Rails.env.to_s]['pod_url'] = "http://#{username}.joindiaspora.com/" + current_config['default']['pod_url'] = "http://#{username}.joindiaspora.com/" file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index cc3000d0b..1eaa5b236 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -9,8 +9,8 @@ require 'config/environment' def set_app_config username current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example'))) current_config[Rails.env.to_s] ||= {} - current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" - current_config['default']['pod_url'] = "#{username}.joindiaspora.com" + current_config[Rails.env.to_s]['pod_url'] = "http://#{username}.joindiaspora.com/" + current_config['default']['pod_url'] = "http://#{username}.joindiaspora.com/" file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close From 4f17eb4e02c13783de1efc8ac99bd57957c9de4e Mon Sep 17 00:00:00 2001 From: danielvincent Date: Thu, 23 Sep 2010 20:33:34 -0700 Subject: [PATCH 31/46] stray aspect name removed from publisher --- app/views/shared/_publisher.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 54f14c27a..a137ccdeb 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -5,7 +5,6 @@ #publisher = owner_image_tag - = @aspect = form_for StatusMessage.new, :remote => true do |f| = f.error_messages From deea03bf82e14fe8e4d01f9ca5bc81ae50f3a6b3 Mon Sep 17 00:00:00 2001 From: ilya Date: Thu, 23 Sep 2010 20:38:39 -0700 Subject: [PATCH 32/46] deploy restart after db:reset since we need the new app_config.yml --- config/deploy.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/deploy.rb b/config/deploy.rb index 2f8065134..869328533 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -150,6 +150,7 @@ namespace :db do purge backer_seed tom_seed + deploy::restart end From 82b99decbbed20896b9d049cf96fa378c76699fe Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 24 Sep 2010 10:45:27 -0700 Subject: [PATCH 33/46] putting the token in the warden session --- app/controllers/application_controller.rb | 2 +- app/controllers/services_controller.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1cbdc7c39..2bf2bf174 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -41,7 +41,7 @@ class ApplicationController < ActionController::Base end def fb_user_info - @access_token = session[:access_token] + @access_token = env['warden'].session[:access_token] @logged_in = @access_token.present? end diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index 373eb100e..b39538d96 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -17,15 +17,15 @@ class ServicesController < ApplicationController # TODO: This is where you'd want to store the token in your database # but for now, we'll just keep it in the session so we don't need a database - session[:access_token] = @access_token + env['warden'].session[:access_token] = @access_token flash[:success] = "Authentication successful." end redirect_to edit_user_url current_user end def destroy - session[:access_token] = nil - session[:user_id] = nil + env['warden'].session[:access_token] = nil + env['warden'].session[:user_id] = nil redirect_to edit_user_url current_user end From bb5867855695a8ad9dd69c6856f721129a00cbc9 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 24 Sep 2010 14:41:31 -0700 Subject: [PATCH 34/46] added a fb_status model & parser method --- app/models/fb_status.rb | 30 +++++++++++++ spec/factories.rb | 8 ++++ spec/fixtures/fb_status | 79 +++++++++++++++++++++++++++++++++++ spec/models/fb_status_spec.rb | 44 +++++++++++++++++++ 4 files changed, 161 insertions(+) create mode 100644 app/models/fb_status.rb create mode 100644 spec/fixtures/fb_status create mode 100644 spec/models/fb_status_spec.rb diff --git a/app/models/fb_status.rb b/app/models/fb_status.rb new file mode 100644 index 000000000..d1a57ef9a --- /dev/null +++ b/app/models/fb_status.rb @@ -0,0 +1,30 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3. See +# the COPYRIGHT file. + + +class FbStatus + include MongoMapper::Document + + key :graph_id, String + key :author_id, String + key :author_name, String + key :message, String + key :updated_time, DateTime + + timestamps! + + validates_presence_of :graph_id,:author_id,:author_name,:message,:updated_time + + def self.from_api(json) + hash = JSON.parse(json) + self.create( + :graph_id => hash['id'], + :author_id => hash['from']['id'] + :author_name => hash['from']['name'], + :message => hash['message'] + :updated_time => Time.parse(hash['updated_time'] + end + +end + diff --git a/spec/factories.rb b/spec/factories.rb index 21a7ad110..0b00ed3d5 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -69,3 +69,11 @@ Factory.define :photo do |p| end Factory.define(:comment) {} + +Factory.define :fb_status do |s| + s.graph_id "367501354973" + s.author_name "Bret Taylor" + s.author_id "220439" + s.message "Pigs run from our house in fear. Tonight, I am wrapping the pork tenderloin in bacon and putting pancetta in the corn." + s.updated_time Time.parse "2010-03-06T02:57:48+0000" +end diff --git a/spec/fixtures/fb_status b/spec/fixtures/fb_status new file mode 100644 index 000000000..5602e8343 --- /dev/null +++ b/spec/fixtures/fb_status @@ -0,0 +1,79 @@ +{ + "id": "367501354973", + "from": { + "name": "Bret Taylor", + "id": "220439" + }, + "message": "Pigs run from our house in fear. Tonight, I am wrapping the pork tenderloin in bacon and putting pancetta in the corn.", + "updated_time": "2010-03-06T02:57:48+0000", + "likes": { + "data": [ + { + "id": "29906278", + "name": "Ross Miller" + } + ] + }, + "comments": { + "data": [ + { + "id": "367501354973_12216733", + "from": { + "name": "Doug Edwards", + "id": "628675309" + }, + "message": "Make sure you don't, as they say, go whole hog...\nhttp://www.youtube.com/watch?v=U4wTFuaV8VQ", + "created_time": "2010-03-06T03:24:46+0000" + }, + { + "id": "367501354973_12249673", + "from": { + "name": "Tom Taylor", + "id": "1249191863" + }, + "message": "Are you and Karen gonna, as they say, pig out?", + "created_time": "2010-03-06T21:05:21+0000" + }, + { + "id": "367501354973_12249857", + "from": { + "name": "Sheila Taylor", + "id": "1315606682" + }, + "message": "how did it turn out? Sounds nummy!\n", + "created_time": "2010-03-06T21:10:30+0000" + }, + { + "id": "367501354973_12250973", + "from": { + "name": "Bret Taylor", + "id": "220439" + }, + "message": "Mom: turned out well. Sauce was good as well: pan sauce with mustard, balsamic, onion, and maple syrup. Surprisingly good in the end, and not too sweet, which was my concern. ", + "created_time": "2010-03-06T21:44:53+0000" + }, + { + "id": "367501354973_12251276", + "from": { + "name": "Sheila Taylor", + "id": "1315606682" + }, + "message": "Sounds delicious! I probably would have skipped the maple syrup, but I am not married to a Canadian :)\n\nSheila Taylor\n(925) 818-7795\nP.O. Box 938\nGlen Ellen, CA 95442\nwww.winecountrytrekking.com", + "created_time": "2010-03-06T21:55:12+0000" + }, + { + "id": "367501354973_12264435", + "from": { + "name": "Amelia Ann Arapoff", + "id": "1580390378" + }, + "message": "Bacon is always in our refrigerator, in case of need, somehow there is always need.", + "created_time": "2010-03-07T05:11:52+0000" + } + ], + "paging": { + "previous": "https://graph.facebook.com/367501354973/comments?access_token=2227470867%7C2.wNlupL2HPsOtrlYFBF56NA__.3600.1285354800-100001548997697%7C8lZ_pdgNDvSHYS4o1OkqhdQu6mA&limit=25&since=2010-03-07T05%3A11%3A52%2B0000", + "next": "https://graph.facebook.com/367501354973/comments?access_token=2227470867%7C2.wNlupL2HPsOtrlYFBF56NA__.3600.1285354800-100001548997697%7C8lZ_pdgNDvSHYS4o1OkqhdQu6mA&limit=25&until=2010-03-06T03%3A24%3A45%2B0000" + } + } +} \ No newline at end of file diff --git a/spec/models/fb_status_spec.rb b/spec/models/fb_status_spec.rb new file mode 100644 index 000000000..a74506512 --- /dev/null +++ b/spec/models/fb_status_spec.rb @@ -0,0 +1,44 @@ +# 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' +require 'json' + +describe FbStatus do + + let(:fb_status) { Factory.create :fb_status } + + it 'is valid' do + fb_status.should be_valid + end + + describe '#from_api' do + let(:json_string) {File.open(File.dirname(__FILE__) + '/../fixtures/fb_status').read} + let!(:json_object) { JSON.parse(json_string) } + let!(:status_from_json) {FbStatus.from_api(json_string)} + + it 'has graph_id' do + status_from_json.graph_id.should == json_object['id'] + end + + it 'has author_id' do + status_from_json.graph_id.should == json_object['from']['id'] + end + + it 'has author_name' do + status_from_json.graph_id.should == json_object['from']['name'] + end + + it 'has message' do + status_from_json.message.should == json_object['message'] + end + + it 'has author_name' do + status_from_json.updated_time.should == Time.parse(json_object['updated_time']) + end + end + +end From ac9854596f4c3fdaa286391612464e0585ea612c Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 24 Sep 2010 15:04:31 -0700 Subject: [PATCH 35/46] fb_status partial rendered in public --- app/models/fb_status.rb | 3 ++- app/views/aspects/public.html.haml | 5 +++++ app/views/fb_status/_fb_status.html.haml | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 app/views/fb_status/_fb_status.html.haml diff --git a/app/models/fb_status.rb b/app/models/fb_status.rb index d1a57ef9a..367549c1b 100644 --- a/app/models/fb_status.rb +++ b/app/models/fb_status.rb @@ -18,7 +18,8 @@ class FbStatus def self.from_api(json) hash = JSON.parse(json) - self.create( + #just keeping them in memory for now + self.new( :graph_id => hash['id'], :author_id => hash['from']['id'] :author_name => hash['from']['name'], diff --git a/app/views/aspects/public.html.haml b/app/views/aspects/public.html.haml index def45bc7c..b760c9215 100644 --- a/app/views/aspects/public.html.haml +++ b/app/views/aspects/public.html.haml @@ -18,6 +18,11 @@ %ul#stream - for post in @posts = render type_partial(post), :post => post unless post.class == Album + - if @logged_in + - MiniFB.get(@access_token, 'me', :type => "feed").each do |item| + - if item['type'] == 'status' + = render "fb_status", :post => FbStatus.from_api() + #pagination = will_paginate @posts diff --git a/app/views/fb_status/_fb_status.html.haml b/app/views/fb_status/_fb_status.html.haml new file mode 100644 index 000000000..30ec62652 --- /dev/null +++ b/app/views/fb_status/_fb_status.html.haml @@ -0,0 +1,13 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3. See +-# the COPYRIGHT file. + + +%li.message{:id => post.id, :class => ("mine" if current_user.owns?(post))} + + = image_tag( "http://graph.facebook.com/#{post.author_id}/picture" ) + + .content + %span.from + = post.author_name + = post.message From c7757a302cf30395b200ca979f3bedf6094dd9b5 Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 24 Sep 2010 15:06:48 -0700 Subject: [PATCH 36/46] typo --- app/views/aspects/public.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/aspects/public.html.haml b/app/views/aspects/public.html.haml index b760c9215..e6500e648 100644 --- a/app/views/aspects/public.html.haml +++ b/app/views/aspects/public.html.haml @@ -21,7 +21,7 @@ - if @logged_in - MiniFB.get(@access_token, 'me', :type => "feed").each do |item| - if item['type'] == 'status' - = render "fb_status", :post => FbStatus.from_api() + = render "fb_status", :post => FbStatus.from_api(item) #pagination = will_paginate @posts From e414558f7903d3f01c46d360bef39dcc3889133f Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 24 Sep 2010 15:52:29 -0700 Subject: [PATCH 37/46] passing the right things to the partial --- app/models/fb_status.rb | 12 ++++++------ app/views/aspects/public.html.haml | 6 +++--- app/views/fb_status/_fb_status.html.haml | 2 +- spec/models/fb_status_spec.rb | 9 ++++----- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/models/fb_status.rb b/app/models/fb_status.rb index 367549c1b..fd190c2c7 100644 --- a/app/models/fb_status.rb +++ b/app/models/fb_status.rb @@ -10,21 +10,21 @@ class FbStatus key :author_id, String key :author_name, String key :message, String - key :updated_time, DateTime + key :updated_time, Time timestamps! validates_presence_of :graph_id,:author_id,:author_name,:message,:updated_time - def self.from_api(json) - hash = JSON.parse(json) + def self.from_api(hash) #just keeping them in memory for now self.new( :graph_id => hash['id'], - :author_id => hash['from']['id'] + :author_id => hash['from']['id'], :author_name => hash['from']['name'], - :message => hash['message'] - :updated_time => Time.parse(hash['updated_time'] + :message => hash['message'], + :updated_time => Time.parse(hash['updated_time']) + ) end end diff --git a/app/views/aspects/public.html.haml b/app/views/aspects/public.html.haml index e6500e648..4399034f7 100644 --- a/app/views/aspects/public.html.haml +++ b/app/views/aspects/public.html.haml @@ -19,9 +19,9 @@ - for post in @posts = render type_partial(post), :post => post unless post.class == Album - if @logged_in - - MiniFB.get(@access_token, 'me', :type => "feed").each do |item| - - if item['type'] == 'status' - = render "fb_status", :post => FbStatus.from_api(item) + - MiniFB.get(@access_token, 'me', :type => "feed")[:data].each do |item| + - if item[:type] == 'status' + = render "fb_status/fb_status", :post => FbStatus.from_api(item) #pagination = will_paginate @posts diff --git a/app/views/fb_status/_fb_status.html.haml b/app/views/fb_status/_fb_status.html.haml index 30ec62652..d5a57bd22 100644 --- a/app/views/fb_status/_fb_status.html.haml +++ b/app/views/fb_status/_fb_status.html.haml @@ -3,7 +3,7 @@ -# the COPYRIGHT file. -%li.message{:id => post.id, :class => ("mine" if current_user.owns?(post))} +%li.message{:id => post.id} = image_tag( "http://graph.facebook.com/#{post.author_id}/picture" ) diff --git a/spec/models/fb_status_spec.rb b/spec/models/fb_status_spec.rb index a74506512..368f8bd16 100644 --- a/spec/models/fb_status_spec.rb +++ b/spec/models/fb_status_spec.rb @@ -5,7 +5,6 @@ require File.dirname(__FILE__) + '/../spec_helper' -require 'json' describe FbStatus do @@ -16,20 +15,20 @@ describe FbStatus do end describe '#from_api' do - let(:json_string) {File.open(File.dirname(__FILE__) + '/../fixtures/fb_status').read} + let!(:json_string) {File.open(File.dirname(__FILE__) + '/../fixtures/fb_status').read} let!(:json_object) { JSON.parse(json_string) } - let!(:status_from_json) {FbStatus.from_api(json_string)} + let!(:status_from_json) {FbStatus.from_api(json_object)} it 'has graph_id' do status_from_json.graph_id.should == json_object['id'] end it 'has author_id' do - status_from_json.graph_id.should == json_object['from']['id'] + status_from_json.author_id.should == json_object['from']['id'] end it 'has author_name' do - status_from_json.graph_id.should == json_object['from']['name'] + status_from_json.author_name.should == json_object['from']['name'] end it 'has message' do From f38bcc9eb34b02de5e057ea0ead0a678cf1e80ec Mon Sep 17 00:00:00 2001 From: ilya Date: Fri, 24 Sep 2010 15:54:53 -0700 Subject: [PATCH 38/46] tiny change in view --- app/views/shared/_aspect_friends.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_aspect_friends.haml b/app/views/shared/_aspect_friends.haml index 10a0da317..0a28a9676 100644 --- a/app/views/shared/_aspect_friends.haml +++ b/app/views/shared/_aspect_friends.haml @@ -8,7 +8,7 @@ - for friend in @friends = person_image_link(friend) - if @logged_in && (@aspect == :public) - Facebook Friends + %h3 Facebook Friends - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") - @fb_friends[:data].each do |friend| = image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" ) From 7b29e6ec269e322743f73e2bac738d7b81e8356a Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 27 Sep 2010 15:50:52 -0700 Subject: [PATCH 39/46] checking that a user is logged in before doing fb checking --- app/controllers/application_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 46b011a61..8817bc645 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -40,8 +40,10 @@ class ApplicationController < ActionController::Base end def fb_user_info - @access_token = env['warden'].session[:access_token] - @logged_in = @access_token.present? + if current_user + @access_token = env['warden'].session[:access_token] + @logged_in = @access_token.present? + end end end From 50234b095b2ca3b71699c380a4accf059bb87c88 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 27 Sep 2010 16:02:08 -0700 Subject: [PATCH 40/46] had to move translation around slightly, now the profile edit will be missing a template --- config/locales/diaspora/en.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 025aed149..838339641 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -101,6 +101,8 @@ en: aspect_not_empty: "Aspect not empty" users: edit: + editing_profile: "Editing profile" + profile: cancel: "Cancel" update_profile: "Update Profile" home: "Home" From a8f05244bae7a5b55076cd3c4668b1abe35ac917 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 27 Sep 2010 16:07:24 -0700 Subject: [PATCH 41/46] localization should be fixed --- config/locales/diaspora/cs.yml | 2 ++ config/locales/diaspora/cy.yml | 4 +++- config/locales/diaspora/de.yml | 2 ++ config/locales/diaspora/es.yml | 2 ++ config/locales/diaspora/fr-informal.yml | 2 ++ config/locales/diaspora/fr.yml | 2 ++ config/locales/diaspora/he.yml | 2 ++ config/locales/diaspora/it.yml | 2 ++ config/locales/diaspora/pt-BR.yml | 2 ++ config/locales/diaspora/ro.yml | 2 ++ config/locales/diaspora/ru.yml | 2 ++ 11 files changed, 23 insertions(+), 1 deletion(-) diff --git a/config/locales/diaspora/cs.yml b/config/locales/diaspora/cs.yml index 78666424c..898428db2 100644 --- a/config/locales/diaspora/cs.yml +++ b/config/locales/diaspora/cs.yml @@ -113,6 +113,8 @@ cs: aspect_not_empty: "Aspekt není prázdný" users: edit: + editing_profile: "Upravit profil" + profile: cancel: "Zrušit" update_profile: "Aktualizovat profil" home: "Domů" diff --git a/config/locales/diaspora/cy.yml b/config/locales/diaspora/cy.yml index 97b4fd3df..cd1c7dbd6 100644 --- a/config/locales/diaspora/cy.yml +++ b/config/locales/diaspora/cy.yml @@ -69,6 +69,8 @@ cy: success:"Cliciwch ar y plus ar y chwith i ddweud wrth Diaspora pwy all weld eich agwedd newydd." users: edit: + editing_profile: "Golygu proffil" + profile: cancel: "Cancel" update_profile: "Diweddaru Proffil" home: "Adref" @@ -139,4 +141,4 @@ cy: friends_since: "yn ffrindiau ers: %{how_long_ago}" save: "arbed" are_you_sure: "Ydych chi'n sicr?" - remove_friend: "dileu ffrind" \ No newline at end of file + remove_friend: "dileu ffrind" diff --git a/config/locales/diaspora/de.yml b/config/locales/diaspora/de.yml index dd3cead59..e277a5efd 100644 --- a/config/locales/diaspora/de.yml +++ b/config/locales/diaspora/de.yml @@ -100,6 +100,8 @@ de: aspect_not_empty: "Aspekt ist nicht leer" users: edit: + editing_profile: "Profil bearbeiten" + profile: cancel: "Abbrechen" update_profile: "Profil aktualisieren" home: "Startseite" diff --git a/config/locales/diaspora/es.yml b/config/locales/diaspora/es.yml index f62c20480..5a73715b9 100644 --- a/config/locales/diaspora/es.yml +++ b/config/locales/diaspora/es.yml @@ -101,6 +101,8 @@ es: aspect_not_empty: "Aspecto no vacio" users: edit: + editing_profile: "Editando perfil" + profile: cancel: "Cancelar" update_profile: "Actualizar Perfil" home: "Home" diff --git a/config/locales/diaspora/fr-informal.yml b/config/locales/diaspora/fr-informal.yml index 141584dad..1c7950fe5 100644 --- a/config/locales/diaspora/fr-informal.yml +++ b/config/locales/diaspora/fr-informal.yml @@ -100,6 +100,8 @@ fr-informal: aspect_not_empty: "L’aspect n’est pas vide" users: edit: + editing_profile: "Édition du profil" + profile: cancel: "Annuler" update_profile: "Mettre à jour le profil" home: "Accueil" diff --git a/config/locales/diaspora/fr.yml b/config/locales/diaspora/fr.yml index 8a44e6dac..bab6f3852 100644 --- a/config/locales/diaspora/fr.yml +++ b/config/locales/diaspora/fr.yml @@ -87,6 +87,8 @@ fr: success:"Cliquez sur plus situé sur le côté gauche afin d’en informer Diaspora qui peut voir votre nouvel aspect." users: edit: + editing_profile: "Édition du profil" + profile: cancel: "Annuler" update_profile: "Mettre à jour le profil" home: "Accueil" diff --git a/config/locales/diaspora/he.yml b/config/locales/diaspora/he.yml index 8b348b3c7..47f2a52c2 100644 --- a/config/locales/diaspora/he.yml +++ b/config/locales/diaspora/he.yml @@ -102,6 +102,8 @@ he: aspect_not_empty: "ההיסט אינו ריק" users: edit: + editing_profile: "עריכת הפרופיל" + profile: cancel: "ביטול" update_profile: "עדכון הפרופיל" home: "בית" diff --git a/config/locales/diaspora/it.yml b/config/locales/diaspora/it.yml index 707704d25..24681fbe0 100644 --- a/config/locales/diaspora/it.yml +++ b/config/locales/diaspora/it.yml @@ -100,6 +100,8 @@ it: aspect_not_empty: "Aspetto non vuoto" users: edit: + editing_profile: "Modifica del profilo" + profile: cancel: "Annulla" update_profile: "Aggiorna profilo" home: "Home" diff --git a/config/locales/diaspora/pt-BR.yml b/config/locales/diaspora/pt-BR.yml index 8e87425e9..e8ffcc8e1 100644 --- a/config/locales/diaspora/pt-BR.yml +++ b/config/locales/diaspora/pt-BR.yml @@ -100,6 +100,8 @@ pt-BR: aspect_not_empty: "Aspecto não está vazio" users: edit: + editing_profile: "Editando perfil" + profile: cancel: "Cancelar" update_profile: "Atualizar Perfil" home: "Home" diff --git a/config/locales/diaspora/ro.yml b/config/locales/diaspora/ro.yml index 5800f4a30..ed3234571 100644 --- a/config/locales/diaspora/ro.yml +++ b/config/locales/diaspora/ro.yml @@ -66,6 +66,8 @@ ro: success:"Click pe semnul plus în partea stângă pentru a indica cine poate accesa noul aspect." users: edit: + editing_profile: "Editare profil" + profile: cancel: "Renunță" update_profile: "Actualizează Profil" home: "Home" diff --git a/config/locales/diaspora/ru.yml b/config/locales/diaspora/ru.yml index cc76b9b42..daeb35915 100644 --- a/config/locales/diaspora/ru.yml +++ b/config/locales/diaspora/ru.yml @@ -69,6 +69,8 @@ ru: success:"Нажмите на плюс слева, для того, что-бы указать Diaspora тех, кто может видеть ваш новый аспект." users: edit: + editing_profile: "Редактирование профиля" + profile: cancel: "Отмена" update_profile: "Обновить профиль" home: "Домой" From d41b37063023cec4b61fb9a4c7be4107ff9a8107 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 27 Sep 2010 16:20:27 -0700 Subject: [PATCH 42/46] removing the fb feed for now --- app/views/aspects/public.html.haml | 4 ---- app/views/fb_status/_fb_status.html.haml | 13 ------------- 2 files changed, 17 deletions(-) delete mode 100644 app/views/fb_status/_fb_status.html.haml diff --git a/app/views/aspects/public.html.haml b/app/views/aspects/public.html.haml index 4399034f7..f04b63489 100644 --- a/app/views/aspects/public.html.haml +++ b/app/views/aspects/public.html.haml @@ -18,10 +18,6 @@ %ul#stream - for post in @posts = render type_partial(post), :post => post unless post.class == Album - - if @logged_in - - MiniFB.get(@access_token, 'me', :type => "feed")[:data].each do |item| - - if item[:type] == 'status' - = render "fb_status/fb_status", :post => FbStatus.from_api(item) #pagination = will_paginate @posts diff --git a/app/views/fb_status/_fb_status.html.haml b/app/views/fb_status/_fb_status.html.haml deleted file mode 100644 index d5a57bd22..000000000 --- a/app/views/fb_status/_fb_status.html.haml +++ /dev/null @@ -1,13 +0,0 @@ --# Copyright (c) 2010, Diaspora Inc. This file is --# licensed under the Affero General Public License version 3. See --# the COPYRIGHT file. - - -%li.message{:id => post.id} - - = image_tag( "http://graph.facebook.com/#{post.author_id}/picture" ) - - .content - %span.from - = post.author_name - = post.message From 52313b799b8e9aea4204e405ea99660d4e224a50 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 27 Sep 2010 16:31:05 -0700 Subject: [PATCH 43/46] added a warning, moved connected as into a partial, removed the publishing box from settings page --- app/helpers/application_helper.rb | 5 +++++ app/views/shared/_publisher.haml | 2 +- app/views/users/_services.haml | 12 ++++-------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 688ddb10b..7745ace96 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -66,4 +66,9 @@ module ApplicationHelper def post_yield_tag(post) (':' + post.id.to_s).to_sym end + + def connected_fb_as token + response_hash = MiniFB.get(token, 'me') + "Connected to facebook as #{response_hash[:name]}" + end end diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 5db168f6f..d1ad995df 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -10,7 +10,7 @@ %p %label{:for => "status_message_message"} Message = f.text_area :message, :rows => 2, :value => params[:prefill] - = "going to Facebook as #{MiniFB.get(@access_token, 'me')[:name]}" if @logged_in && @aspect == :public + = connected_fb_as(@access_token) if @logged_in && @aspect == :public = f.hidden_field( :public, :value => (params[:action] == 'public') ) %ul.aspect_selector{ :style => "display:none;"} diff --git a/app/views/users/_services.haml b/app/views/users/_services.haml index c6e31939a..f2d976a79 100644 --- a/app/views/users/_services.haml +++ b/app/views/users/_services.haml @@ -8,20 +8,16 @@ %h3 Facebook %p - if @logged_in - Connected to facebook as - - @response_hash = MiniFB.get(@access_token, 'me') - = @response_hash[:name] - + = connected_fb_as(@access_token) + + %p - @fb_friends = MiniFB.get(@access_token, 'me', :type => "friends") - @fb_friends[:data].each do |friend| = image_tag( "http://graph.facebook.com/#{friend[:id]}/picture" ) - - form_tag "/services/fb_post" do - = text_area_tag "message" - = submit_tag "send it off" = link_to "Disconnect from Facebook", services_destroy_path - else - = link_to "Connect to Facebook", @fb_access_url + = link_to "Connect to Facebook (DO NOT USE WITH A REAL ACCOUNT)", @fb_access_url #content_bottom .back From c2b84fd9c686beeb06449e45bf1972ee1b2abc77 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 27 Sep 2010 16:59:54 -0700 Subject: [PATCH 44/46] added a public key to post --- app/controllers/aspects_controller.rb | 2 +- app/models/post.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 722828a2e..33a33db71 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -52,7 +52,7 @@ class AspectsController < ApplicationController @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", :scope=>MiniFB.scopes.join(",")) - @posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' + @posts = current_user.raw_visible_posts.all(:public => true, :order => 'created_at DESC').paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' respond_with @aspect end diff --git a/app/models/post.rb b/app/models/post.rb index 983d0e68f..aba822160 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -13,6 +13,9 @@ class Post xml_accessor :_id xml_accessor :person, :as => Person + xml_reader :public + + key :public , Boolean, :default => false key :person_id, ObjectId key :user_refs, Integer, :default => 0 From 6e407572c43b006b5d8011566378fc59e1d381da Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 27 Sep 2010 17:27:49 -0700 Subject: [PATCH 45/46] removed unused repost method, going through the warden object --- app/controllers/application_controller.rb | 2 +- app/controllers/services_controller.rb | 6 +++--- app/models/user.rb | 6 ------ spec/models/user/posting_spec.rb | 9 --------- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8817bc645..52975730b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -41,7 +41,7 @@ class ApplicationController < ActionController::Base def fb_user_info if current_user - @access_token = env['warden'].session[:access_token] + @access_token = warden.session[:access_token] @logged_in = @access_token.present? end end diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index b39538d96..82a58c508 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -17,15 +17,15 @@ class ServicesController < ApplicationController # TODO: This is where you'd want to store the token in your database # but for now, we'll just keep it in the session so we don't need a database - env['warden'].session[:access_token] = @access_token + warden.session[:access_token] = @access_token flash[:success] = "Authentication successful." end redirect_to edit_user_url current_user end def destroy - env['warden'].session[:access_token] = nil - env['warden'].session[:user_id] = nil + warden.session[:access_token] = nil + warden.session[:user_id] = nil redirect_to edit_user_url current_user end diff --git a/app/models/user.rb b/app/models/user.rb index d89b8b59a..ca248a8f2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -114,12 +114,6 @@ class User post end - def repost( post, options = {} ) - aspect_ids = validate_aspect_permissions(options[:to]) - push_to_aspects(post, aspect_ids) - post - end - def update_post( post, post_hash = {} ) if self.owns? post post.update_attributes(post_hash) diff --git a/spec/models/user/posting_spec.rb b/spec/models/user/posting_spec.rb index 76f4243f7..d86433ad6 100644 --- a/spec/models/user/posting_spec.rb +++ b/spec/models/user/posting_spec.rb @@ -46,15 +46,6 @@ describe User do end end - describe '#repost' do - it 'should make the post visible in another aspect' do - status_message = user.post(:status_message, :message => "hello", :to => aspect.id) - user.repost(status_message, :to => aspect1.id) - aspect1.reload - aspect1.posts.count.should be 1 - end - end - describe '#update_post' do it 'should update fields' do album = user.post(:album, :name => "Profile Photos", :to => aspect.id) From 7852c346f2823e64ec1eaee21ca83d80ca039ffc Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 27 Sep 2010 18:31:37 -0700 Subject: [PATCH 46/46] mode the visible posts api more general and moved to it on the public controller --- app/controllers/aspects_controller.rb | 2 +- app/controllers/people_controller.rb | 2 +- lib/diaspora/user/querying.rb | 5 +++-- spec/models/user/visible_posts_spec.rb | 27 +++++++++++++++++++++++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 33a33db71..cf9cc1583 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -52,7 +52,7 @@ class AspectsController < ApplicationController @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create", :scope=>MiniFB.scopes.join(",")) - @posts = current_user.raw_visible_posts.all(:public => true, :order => 'created_at DESC').paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' + @posts = current_user.visible_posts(:public => true).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' respond_with @aspect end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index a8b8fffc0..be1f89991 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -21,7 +21,7 @@ class PeopleController < ApplicationController @profile = @person.profile @aspects_with_person = current_user.aspects_with_person(@person) @aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]} - @posts = current_user.visible_posts(:from => @person).paginate :page => params[:page], :order => 'created_at DESC' + @posts = current_user.visible_posts(:person_id => @person.id).paginate :page => params[:page], :order => 'created_at DESC' @latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last @post_count = @posts.count respond_with @person diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index 29f119238..7d74df4ed 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -11,12 +11,13 @@ module Diaspora end def visible_posts( opts = {} ) + opts[:order] ||= 'created_at DESC' if opts[:by_members_of] return raw_visible_posts if opts[:by_members_of] == :all aspect = self.aspects.find_by_id( opts[:by_members_of].id ) aspect.posts - elsif opts[:from] - self.raw_visible_posts.find_all_by_person_id(opts[:from].id, :order => 'created_at DESC') + else + self.raw_visible_posts.all(opts) end end diff --git a/spec/models/user/visible_posts_spec.rb b/spec/models/user/visible_posts_spec.rb index e0a3d5215..040fcd1bc 100644 --- a/spec/models/user/visible_posts_spec.rb +++ b/spec/models/user/visible_posts_spec.rb @@ -12,13 +12,38 @@ describe User do let!(:user2) { Factory(:user_with_aspect) } let!(:status_message1) { user2.post :status_message, :message => "hi", :to => user2.aspects.first.id } + let!(:status_message2) { user2.post :status_message, :message => "hey", :public => true , :to => user2.aspects.first.id } + let!(:status_message3) { user2.post :status_message, :message => "va", :to => user2.aspects.first.id } + let!(:status_message4) { user2.post :status_message, :message => "da", :public => true , :to => user2.aspects.first.id } + before do friend_users(user, first_aspect, user2, user2.aspects.first) end describe "#visible_posts" do - it "generates a stream for each aspect that includes only that aspect's posts" do + it "queries by person id" do + user2.visible_posts(:person_id => user2.person.id).include?(status_message1).should == true + user2.visible_posts(:person_id => user2.person.id).include?(status_message2).should == true + user2.visible_posts(:person_id => user2.person.id).include?(status_message3).should == true + user2.visible_posts(:person_id => user2.person.id).include?(status_message4).should == true + end + + it "selects public posts" do + user2.visible_posts(:public => true).include?(status_message2).should == true + user2.visible_posts(:public => true).include?(status_message4).should == true + end + + it "selects non public posts" do + user2.visible_posts(:public => false).include?(status_message1).should == true + user2.visible_posts(:public => false).include?(status_message3).should == true + end + + it "selects by message contents" do + user2.visible_posts(:message => "hi").include?(status_message1).should == true + end + + it "queries by aspect" do user3 = Factory(:user_with_aspect) status_message2 = user3.post :status_message, :message => "heyyyy", :to => user3.aspects.first.id user4 = Factory(:user_with_aspect)