diff --git a/Gemfile b/Gemfile index 55e340dec..16788eeb3 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,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 a56760270..8534f580a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -158,6 +158,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) @@ -267,6 +270,7 @@ DEPENDENCIES haml json magent! + mini_fb mini_magick mocha mongo_mapper! diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a39d827e4..52975730b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,6 +8,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 @@ -21,7 +22,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]) @@ -36,4 +39,11 @@ class ApplicationController < ActionController::Base @request_count = Request.for_user(current_user).size if current_user end + def fb_user_info + if current_user + @access_token = warden.session[:access_token] + @logged_in = @access_token.present? + end + end + end diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index 2bfdee238..cf9cc1583 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -48,6 +48,15 @@ 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(:public => true).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC' + + respond_with @aspect + end + def manage @aspect = :manage @remote_requests = Request.for_user(current_user).all 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/app/controllers/services_controller.rb b/app/controllers/services_controller.rb new file mode 100644 index 000000000..82a58c508 --- /dev/null +++ b/app/controllers/services_controller.rb @@ -0,0 +1,40 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3. See +# the COPYRIGHT file. + + +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, APP_CONFIG[:pod_url] + "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 session so we don't need a database + warden.session[:access_token] = @access_token + flash[:success] = "Authentication successful." + end + redirect_to edit_user_url current_user + end + + def destroy + warden.session[:access_token] = nil + warden.session[:user_id] = nil + 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 edit_user_url current_user + end + +end diff --git a/app/controllers/status_messages_controller.rb b/app/controllers/status_messages_controller.rb index ef519a1a4..b072564bb 100644 --- a/app/controllers/status_messages_controller.rb +++ b/app/controllers/status_messages_controller.rb @@ -12,6 +12,15 @@ class StatusMessagesController < ApplicationController params[:status_message][:to] = params[:aspect_ids] data = clean_hash params[:status_message] + + 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 @status_message = current_user.post(:status_message, data) respond_with @status_message @@ -32,7 +41,8 @@ class StatusMessagesController < ApplicationController def clean_hash(params) return { :message => params[:message], - :to => params[:to] + :to => params[:to], + :public => params[:public] } end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index dea449935..ac284a219 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -12,6 +12,9 @@ class UsersController < ApplicationController @person = @user.person @profile = @user.person.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, APP_CONFIG[:pod_url] + "services/create", + :scope=>MiniFB.scopes.join(",")) end def update 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/models/fb_status.rb b/app/models/fb_status.rb new file mode 100644 index 000000000..fd190c2c7 --- /dev/null +++ b/app/models/fb_status.rb @@ -0,0 +1,31 @@ +# 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, Time + + timestamps! + + validates_presence_of :graph_id,:author_id,:author_name,:message,:updated_time + + def self.from_api(hash) + #just keeping them in memory for now + self.new( + :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/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 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/app/views/aspects/public.html.haml b/app/views/aspects/public.html.haml new file mode 100644 index 000000000..f04b63489 --- /dev/null +++ b/app/views/aspects/public.html.haml @@ -0,0 +1,24 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3. See +-# the COPYRIGHT file. + + +- 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 + - if @logged_in + = render "shared/publisher", :aspect_ids => :public + - else + = render "shared/publisher", :aspect_ids => :all + +%ul#stream + - for post in @posts + = render type_partial(post), :post => post unless post.class == Album + +#pagination + = will_paginate @posts + diff --git a/app/views/shared/_aspect_friends.haml b/app/views/shared/_aspect_friends.haml index b4927edc6..f8e635f8d 100644 --- a/app/views/shared/_aspect_friends.haml +++ b/app/views/shared/_aspect_friends.haml @@ -6,8 +6,12 @@ = owner_image_link - for friend in @friends = person_image_link(friend) - - -unless @aspect == :all + - if @logged_in && (@aspect == :public) + %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" ) + -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/_aspect_nav.haml b/app/views/shared/_aspect_nav.haml index a0a0ee0ad..4c4a501d2 100644 --- a/app/views/shared/_aspect_nav.haml +++ b/app/views/shared/_aspect_nav.haml @@ -7,11 +7,13 @@ - 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 t('.all_aspects'), root_url + %ul{ :style => "position:absolute;right:0;bottom:0.01em;"} + %li{:class => ("selected" if @aspect == :public)} + = link_to "Public", aspects_public_path + %li{ :style => "margin-right:0;", :class => ("selected" if @aspect == :manage)} = link_to ( (@request_count == 0)? t('.manage') : "#{t('.manage')} (#{@request_count})"), {:controller => :aspects, :action => :manage}, :class => "edit_aspect_button", :class => new_request(@request_count), :title => t('.manage_your_aspects') diff --git a/app/views/shared/_publisher.haml b/app/views/shared/_publisher.haml index 1a440b838..d1ad995df 100644 --- a/app/views/shared/_publisher.haml +++ b/app/views/shared/_publisher.haml @@ -10,12 +10,13 @@ %p %label{:for => "status_message_message"} Message = f.text_area :message, :rows => 2, :value => params[:prefill] + = connected_fb_as(@access_token) 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, @aspect == :all || current_aspect?(aspect) ) + = check_box_tag("aspect_ids[]", aspect.id, @aspect == :public || @aspect == :all || current_aspect?(aspect) ) = aspect.name - = f.submit t('.share') diff --git a/app/views/shared/_sub_header.haml b/app/views/shared/_sub_header.haml index d8ad6c603..227b63d4e 100644 --- a/app/views/shared/_sub_header.haml +++ b/app/views/shared/_sub_header.haml @@ -8,6 +8,8 @@ %h1 - if @aspect == :all = link_to t('.all_aspects'), root_path + - elsif @aspect == :public + = "Public" - elsif @aspect == :manage = link_to t('.manage_aspects'), root_path - else diff --git a/app/views/users/_profile.haml b/app/views/users/_profile.haml new file mode 100644 index 000000000..2b26eead0 --- /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="#{t('.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 + =t('.you_dont_have_any_photos') + = link_to t('.albums'), albums_path(:aspect => 'all') + =t('.page_to_upload_some') + + =will_paginate @photos + + %br + + %h3="#{t('.info')}" + + %p + %b + ="#{t('.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 t('.cancel'), root_path + or + = f.submit t('.update_profile') + +#content_bottom + .back + = link_to "⇧ #{t('.home')}", root_path + diff --git a/app/views/users/_services.haml b/app/views/users/_services.haml new file mode 100644 index 000000000..f2d976a79 --- /dev/null +++ b/app/views/users/_services.haml @@ -0,0 +1,24 @@ +-# Copyright (c) 2010, Diaspora Inc. This file is +-# licensed under the Affero General Public License version 3. See +-# the COPYRIGHT file. + + +%h2 Services + +%h3 Facebook +%p + - if @logged_in + = 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" ) + + = link_to "Disconnect from Facebook", services_destroy_path + - else + = link_to "Connect to Facebook (DO NOT USE WITH A REAL ACCOUNT)", @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 3385cb5ea..a3f090027 100644 --- a/app/views/users/edit.html.haml +++ b/app/views/users/edit.html.haml @@ -2,60 +2,29 @@ -# licensed under the Affero General Public License version 3. See -# 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="#{t('.editing_profile')}" - content_for :left_pane do - \. + %ul#settings_nav + %li=link_to 'Profile', '#', :class => 'profile' + %li=link_to 'Services', '#', :class => 'services' -= form_for @user do |f| - = f.error_messages +#profile.settings_pane{:style=>"display:block;"} + = render 'users/profile' - = f.fields_for :profile do |p| +#services.settings_pane + = render 'users/services' + - %h3="#{t('.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 - =t('.you_dont_have_any_photos') - = link_to t('.albums'), albums_path(:aspect => 'all') - =t('.page_to_upload_some') - - =will_paginate @photos - - %br - - %h3="#{t('.info')}" - - %p - %b - ="#{t('.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 t('.cancel'), root_path - or - = f.submit t('.update_profile') - -#content_bottom - .back - = link_to "⇧ #{t('.home')}", root_path diff --git a/config/deploy.rb b/config/deploy.rb index ab240e18c..98d8971f7 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -147,6 +147,7 @@ namespace :db do purge backer_seed tom_seed + deploy::restart end end diff --git a/config/deploy_config.yml b/config/deploy_config.yml index 6443a51ac..b6cba3056 100644 --- a/config/deploy_config.yml +++ b/config/deploy_config.yml @@ -6,7 +6,7 @@ cross_server: deploy_to: '/usr/local/app/diaspora' user: 'root' repo: 'git://github.com/diaspora/diaspora.git' - branch: 'private_key_user_refactor' + branch: 'fb' default_env: 'development' servers: tom: diff --git a/config/environment.rb b/config/environment.rb index 5bde8792b..6b960209f 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -6,6 +6,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..4c3309fac --- /dev/null +++ b/config/fb_config.yml @@ -0,0 +1,4 @@ +fb_api_key: {dcf4e90df086cf6d3e531b31e043ff32} +fb_secret: {7fe864834726f8a5e65bc93928b99a53} +fb_app_id: {120373411325347} +host: http://localhost:3000/ 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/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" 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: "Домой" diff --git a/config/routes.rb b/config/routes.rb index 4d227a0a1..0a8aa2630 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,31 +3,35 @@ # the COPYRIGHT file. Diaspora::Application.routes.draw do - resources :people, :only => [:index, :show, :destroy] - resources :users, :except => [:create, :new, :show] - resources :status_messages - 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' + match 'aspects/public', :to => 'aspects#public' + resources :aspects, :except => [:edit] - 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 '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" + 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 diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index bc63a81a9..c4805eae8 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -41,8 +41,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 3f8c4810f..5c418c8db 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -7,8 +7,8 @@ require File.join(File.dirname(__FILE__), "..", "..", "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 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/public/stylesheets/application.css b/public/stylesheets/application.css index 1ef65078a..53da697cc 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 e9f9b2188..2a3136393 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 + diff --git a/spec/factories.rb b/spec/factories.rb index 9f8efc4c3..3444cf9e1 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..368f8bd16 --- /dev/null +++ b/spec/models/fb_status_spec.rb @@ -0,0 +1,43 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3. See +# the COPYRIGHT file. + + + +require File.dirname(__FILE__) + '/../spec_helper' + +describe 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_object)} + + it 'has graph_id' do + status_from_json.graph_id.should == json_object['id'] + end + + it 'has author_id' do + status_from_json.author_id.should == json_object['from']['id'] + end + + it 'has author_name' do + status_from_json.author_name.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 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) 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)