Merge branch 'master' of github.com:diaspora/diaspora

This commit is contained in:
danielvincent 2010-09-27 19:07:01 -07:00
commit eb7244e07c
47 changed files with 514 additions and 118 deletions

View file

@ -19,6 +19,7 @@ gem 'will_paginate', '3.0.pre2'
gem 'roxml', :git => 'git://github.com/Empact/roxml.git' gem 'roxml', :git => 'git://github.com/Empact/roxml.git'
gem 'addressable', :require => 'addressable/uri' gem 'addressable', :require => 'addressable/uri'
gem 'json' gem 'json'
gem 'mini_fb'
#Standards #Standards
gem 'pubsubhubbub' gem 'pubsubhubbub'

View file

@ -158,6 +158,9 @@ GEM
mime-types mime-types
treetop (>= 1.4.5) treetop (>= 1.4.5)
mime-types (1.16) mime-types (1.16)
mini_fb (1.1.3)
hashie
rest-client
mini_magick (2.1) mini_magick (2.1)
subexec (~> 0.0.4) subexec (~> 0.0.4)
mocha (0.9.8) mocha (0.9.8)
@ -267,6 +270,7 @@ DEPENDENCIES
haml haml
json json
magent! magent!
mini_fb
mini_magick mini_magick
mocha mocha
mongo_mapper! mongo_mapper!

View file

@ -8,6 +8,7 @@ class ApplicationController < ActionController::Base
before_filter :set_friends_and_status, :except => [:create, :update] before_filter :set_friends_and_status, :except => [:create, :update]
before_filter :count_requests before_filter :count_requests
before_filter :fb_user_info
layout :layout_by_resource layout :layout_by_resource
@ -21,7 +22,9 @@ class ApplicationController < ActionController::Base
def set_friends_and_status def set_friends_and_status
if current_user 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 @aspect = :all
else else
@aspect = current_user.aspect_by_id( params[:aspect]) @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 @request_count = Request.for_user(current_user).size if current_user
end end
def fb_user_info
if current_user
@access_token = warden.session[:access_token]
@logged_in = @access_token.present?
end
end
end end

View file

@ -48,6 +48,15 @@ class AspectsController < ApplicationController
respond_with @aspect respond_with @aspect
end 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 def manage
@aspect = :manage @aspect = :manage
@remote_requests = Request.for_user(current_user).all @remote_requests = Request.for_user(current_user).all

View file

@ -21,7 +21,7 @@ class PeopleController < ApplicationController
@profile = @person.profile @profile = @person.profile
@aspects_with_person = current_user.aspects_with_person(@person) @aspects_with_person = current_user.aspects_with_person(@person)
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]} @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 @latest_status_message = current_user.raw_visible_posts.find_all_by__type_and_person_id("StatusMessage", params[:id]).last
@post_count = @posts.count @post_count = @posts.count
respond_with @person respond_with @person

View file

@ -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

View file

@ -13,6 +13,15 @@ class StatusMessagesController < ApplicationController
data = clean_hash params[:status_message] 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) @status_message = current_user.post(:status_message, data)
respond_with @status_message respond_with @status_message
end end
@ -32,7 +41,8 @@ class StatusMessagesController < ApplicationController
def clean_hash(params) def clean_hash(params)
return { return {
:message => params[:message], :message => params[:message],
:to => params[:to] :to => params[:to],
:public => params[:public]
} }
end end
end end

View file

@ -12,6 +12,9 @@ class UsersController < ApplicationController
@person = @user.person @person = @user.person
@profile = @user.person.profile @profile = @user.person.profile
@photos = Photo.find_all_by_person_id(@person.id).paginate :page => params[:page], :order => 'created_at DESC' @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 end
def update def update

View file

@ -66,4 +66,9 @@ module ApplicationHelper
def post_yield_tag(post) def post_yield_tag(post)
(':' + post.id.to_s).to_sym (':' + post.id.to_s).to_sym
end end
def connected_fb_as token
response_hash = MiniFB.get(token, 'me')
"Connected to facebook as #{response_hash[:name]}"
end
end end

31
app/models/fb_status.rb Normal file
View file

@ -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

View file

@ -13,6 +13,9 @@ class Post
xml_accessor :_id xml_accessor :_id
xml_accessor :person, :as => Person xml_accessor :person, :as => Person
xml_reader :public
key :public , Boolean, :default => false
key :person_id, ObjectId key :person_id, ObjectId
key :user_refs, Integer, :default => 0 key :user_refs, Integer, :default => 0

View file

@ -114,12 +114,6 @@ class User
post post
end 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 = {} ) def update_post( post, post_hash = {} )
if self.owns? post if self.owns? post
post.update_attributes(post_hash) post.update_attributes(post_hash)

View file

@ -0,0 +1,24 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
- 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

View file

@ -6,8 +6,12 @@
= owner_image_link = owner_image_link
- for friend in @friends - for friend in @friends
= person_image_link(friend) = person_image_link(friend)
- if @logged_in && (@aspect == :public)
-unless @aspect == :all %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' = link_to (image_tag('add_friend_button.png', :height => "50px", :width => "50px")), "#add_request_pane", :id => 'add_request_button'
.yo{:style => 'display:none'} .yo{:style => 'display:none'}

View file

@ -7,11 +7,13 @@
- for aspect in @aspects - for aspect in @aspects
%li{:class => ("selected" if current_aspect?(aspect))} %li{:class => ("selected" if current_aspect?(aspect))}
= link_for_aspect aspect = link_for_aspect aspect
%ul{ :style => "position:absolute;right:0;bottom:0.01em;"}
%li{:class => ("selected" if @aspect == :all)} %li{:class => ("selected" if @aspect == :all)}
= link_to t('.all_aspects'), root_url = 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)} %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') = 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')

View file

@ -10,12 +10,13 @@
%p %p
%label{:for => "status_message_message"} Message %label{:for => "status_message_message"} Message
= f.text_area :message, :rows => 2, :value => params[:prefill] = 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;"} %ul.aspect_selector{ :style => "display:none;"}
going to... going to...
- for aspect in @aspects - for aspect in @aspects
%li %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 = aspect.name
= f.submit t('.share') = f.submit t('.share')

View file

@ -8,6 +8,8 @@
%h1 %h1
- if @aspect == :all - if @aspect == :all
= link_to t('.all_aspects'), root_path = link_to t('.all_aspects'), root_path
- elsif @aspect == :public
= "Public"
- elsif @aspect == :manage - elsif @aspect == :manage
= link_to t('.manage_aspects'), root_path = link_to t('.manage_aspects'), root_path
- else - else

View file

@ -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

View file

@ -0,0 +1,24 @@
-# Copyright (c) 2010, Diaspora Inc. This file is
-# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file.
%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

View file

@ -2,60 +2,29 @@
-# licensed under the Affero General Public License version 3. See -# licensed under the Affero General Public License version 3. See
-# the COPYRIGHT file. -# 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 - content_for :publish do
%h1="#{t('.editing_profile')}" %h1="#{t('.editing_profile')}"
- content_for :left_pane do - 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| #profile.settings_pane{:style=>"display:block;"}
= f.error_messages = 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

View file

@ -147,6 +147,7 @@ namespace :db do
purge purge
backer_seed backer_seed
tom_seed tom_seed
deploy::restart
end end
end end

View file

@ -6,7 +6,7 @@ cross_server:
deploy_to: '/usr/local/app/diaspora' deploy_to: '/usr/local/app/diaspora'
user: 'root' user: 'root'
repo: 'git://github.com/diaspora/diaspora.git' repo: 'git://github.com/diaspora/diaspora.git'
branch: 'private_key_user_refactor' branch: 'fb'
default_env: 'development' default_env: 'development'
servers: servers:
tom: tom:

View file

@ -6,6 +6,14 @@
require File.expand_path('../application', __FILE__) require File.expand_path('../application', __FILE__)
Haml::Template.options[:format] = :html5 Haml::Template.options[:format] = :html5
Haml::Template.options[:escape_html] = true 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 # Initialize the rails application
Diaspora::Application.initialize! Diaspora::Application.initialize!

4
config/fb_config.yml Normal file
View file

@ -0,0 +1,4 @@
fb_api_key: {dcf4e90df086cf6d3e531b31e043ff32}
fb_secret: {7fe864834726f8a5e65bc93928b99a53}
fb_app_id: {120373411325347}
host: http://localhost:3000/

View file

@ -113,6 +113,8 @@ cs:
aspect_not_empty: "Aspekt není prázdný" aspect_not_empty: "Aspekt není prázdný"
users: users:
edit: edit:
editing_profile: "Upravit profil"
profile:
cancel: "Zrušit" cancel: "Zrušit"
update_profile: "Aktualizovat profil" update_profile: "Aktualizovat profil"
home: "Domů" home: "Domů"

View file

@ -69,6 +69,8 @@ cy:
success:"Cliciwch ar y plus ar y chwith i ddweud wrth Diaspora pwy all weld eich agwedd newydd." success:"Cliciwch ar y plus ar y chwith i ddweud wrth Diaspora pwy all weld eich agwedd newydd."
users: users:
edit: edit:
editing_profile: "Golygu proffil"
profile:
cancel: "Cancel" cancel: "Cancel"
update_profile: "Diweddaru Proffil" update_profile: "Diweddaru Proffil"
home: "Adref" home: "Adref"

View file

@ -100,6 +100,8 @@ de:
aspect_not_empty: "Aspekt ist nicht leer" aspect_not_empty: "Aspekt ist nicht leer"
users: users:
edit: edit:
editing_profile: "Profil bearbeiten"
profile:
cancel: "Abbrechen" cancel: "Abbrechen"
update_profile: "Profil aktualisieren" update_profile: "Profil aktualisieren"
home: "Startseite" home: "Startseite"

View file

@ -101,6 +101,8 @@ en:
aspect_not_empty: "Aspect not empty" aspect_not_empty: "Aspect not empty"
users: users:
edit: edit:
editing_profile: "Editing profile"
profile:
cancel: "Cancel" cancel: "Cancel"
update_profile: "Update Profile" update_profile: "Update Profile"
home: "Home" home: "Home"

View file

@ -101,6 +101,8 @@ es:
aspect_not_empty: "Aspecto no vacio" aspect_not_empty: "Aspecto no vacio"
users: users:
edit: edit:
editing_profile: "Editando perfil"
profile:
cancel: "Cancelar" cancel: "Cancelar"
update_profile: "Actualizar Perfil" update_profile: "Actualizar Perfil"
home: "Home" home: "Home"

View file

@ -100,6 +100,8 @@ fr-informal:
aspect_not_empty: "Laspect nest pas vide" aspect_not_empty: "Laspect nest pas vide"
users: users:
edit: edit:
editing_profile: "Édition du profil"
profile:
cancel: "Annuler" cancel: "Annuler"
update_profile: "Mettre à jour le profil" update_profile: "Mettre à jour le profil"
home: "Accueil" home: "Accueil"

View file

@ -87,6 +87,8 @@ fr:
success:"Cliquez sur plus situé sur le côté gauche afin den informer Diaspora qui peut voir votre nouvel aspect." success:"Cliquez sur plus situé sur le côté gauche afin den informer Diaspora qui peut voir votre nouvel aspect."
users: users:
edit: edit:
editing_profile: "Édition du profil"
profile:
cancel: "Annuler" cancel: "Annuler"
update_profile: "Mettre à jour le profil" update_profile: "Mettre à jour le profil"
home: "Accueil" home: "Accueil"

View file

@ -102,6 +102,8 @@ he:
aspect_not_empty: "ההיסט אינו ריק" aspect_not_empty: "ההיסט אינו ריק"
users: users:
edit: edit:
editing_profile: "עריכת הפרופיל"
profile:
cancel: "ביטול" cancel: "ביטול"
update_profile: "עדכון הפרופיל" update_profile: "עדכון הפרופיל"
home: "בית" home: "בית"

View file

@ -100,6 +100,8 @@ it:
aspect_not_empty: "Aspetto non vuoto" aspect_not_empty: "Aspetto non vuoto"
users: users:
edit: edit:
editing_profile: "Modifica del profilo"
profile:
cancel: "Annulla" cancel: "Annulla"
update_profile: "Aggiorna profilo" update_profile: "Aggiorna profilo"
home: "Home" home: "Home"

View file

@ -100,6 +100,8 @@ pt-BR:
aspect_not_empty: "Aspecto não está vazio" aspect_not_empty: "Aspecto não está vazio"
users: users:
edit: edit:
editing_profile: "Editando perfil"
profile:
cancel: "Cancelar" cancel: "Cancelar"
update_profile: "Atualizar Perfil" update_profile: "Atualizar Perfil"
home: "Home" home: "Home"

View file

@ -66,6 +66,8 @@ ro:
success:"Click pe semnul plus în partea stângă pentru a indica cine poate accesa noul aspect." success:"Click pe semnul plus în partea stângă pentru a indica cine poate accesa noul aspect."
users: users:
edit: edit:
editing_profile: "Editare profil"
profile:
cancel: "Renunță" cancel: "Renunță"
update_profile: "Actualizează Profil" update_profile: "Actualizează Profil"
home: "Home" home: "Home"

View file

@ -69,6 +69,8 @@ ru:
success:"Нажмите на плюс слева, для того, что-бы указать Diaspora тех, кто может видеть ваш новый аспект." success:"Нажмите на плюс слева, для того, что-бы указать Diaspora тех, кто может видеть ваш новый аспект."
users: users:
edit: edit:
editing_profile: "Редактирование профиля"
profile:
cancel: "Отмена" cancel: "Отмена"
update_profile: "Обновить профиль" update_profile: "Обновить профиль"
home: "Домой" home: "Домой"

View file

@ -5,7 +5,7 @@
Diaspora::Application.routes.draw do Diaspora::Application.routes.draw do
resources :people, :only => [:index, :show, :destroy] resources :people, :only => [:index, :show, :destroy]
resources :users, :except => [:create, :new, :show] resources :users, :except => [:create, :new, :show]
resources :status_messages resources :status_messages, :only => [:create, :destroy, :show]
resources :comments, :except => [:index] resources :comments, :except => [:index]
resources :requests, :except => [:edit, :update] resources :requests, :except => [:edit, :update]
resources :photos, :except => [:index] resources :photos, :except => [:index]
@ -14,14 +14,18 @@ Diaspora::Application.routes.draw do
match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends' match 'aspects/move_friends', :to => 'aspects#move_friends', :as => 'move_friends'
match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend' match 'aspects/move_friend', :to => 'aspects#move_friend', :as => 'move_friend'
match 'aspects/manage', :to => 'aspects#manage' match 'aspects/manage', :to => 'aspects#manage'
match 'aspects/public', :to => 'aspects#public'
resources :aspects, :except => [:edit] resources :aspects, :except => [:edit]
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 'warzombie', :to => "dev_utilities#warzombie"
match 'zombiefriends', :to => "dev_utilities#zombiefriends" match 'zombiefriends', :to => "dev_utilities#zombiefriends"
match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept" match 'zombiefriendaccept', :to => "dev_utilities#zombiefriendaccept"
match 'set_backer_number', :to => "dev_utilities#set_backer_number" match 'set_backer_number', :to => "dev_utilities#set_backer_number"
match 'set_profile_photo', :to => "dev_utilities#set_profile_photo" 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, #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 #non mutable stuff in anohter file
devise_for :users, :controllers => {:registrations => "registrations"} devise_for :users, :controllers => {:registrations => "registrations"}

View file

@ -41,8 +41,8 @@ end
def set_app_config username def set_app_config username
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example'))) 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] ||= {}
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config[Rails.env.to_s]['pod_url'] = "http://#{username}.joindiaspora.com/"
current_config['default']['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "http://#{username}.joindiaspora.com/"
file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w') file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w')
file.write(current_config.to_yaml) file.write(current_config.to_yaml)
file.close file.close

View file

@ -7,8 +7,8 @@ require File.join(File.dirname(__FILE__), "..", "..", "config", "environment")
def set_app_config username def set_app_config username
current_config = YAML.load(File.read(Rails.root.join('config', 'app_config.yml.example'))) 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] ||= {}
current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config[Rails.env.to_s]['pod_url'] = "http://#{username}.joindiaspora.com/"
current_config['default']['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "http://#{username}.joindiaspora.com/"
file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w') file = File.new(Rails.root.join('..','..','shared','app_config.yml'),'w')
file.write(current_config.to_yaml) file.write(current_config.to_yaml)
file.close file.close

View file

@ -11,12 +11,13 @@ module Diaspora
end end
def visible_posts( opts = {} ) def visible_posts( opts = {} )
opts[:order] ||= 'created_at DESC'
if opts[:by_members_of] if opts[:by_members_of]
return raw_visible_posts if opts[:by_members_of] == :all return raw_visible_posts if opts[:by_members_of] == :all
aspect = self.aspects.find_by_id( opts[:by_members_of].id ) aspect = self.aspects.find_by_id( opts[:by_members_of].id )
aspect.posts aspect.posts
elsif opts[:from] else
self.raw_visible_posts.find_all_by_person_id(opts[:from].id, :order => 'created_at DESC') self.raw_visible_posts.all(opts)
end end
end end

View file

@ -659,15 +659,19 @@ h1.big_text {
-moz-box-shadow: 0 2px 4px #333333; -moz-box-shadow: 0 2px 4px #333333;
opacity: 0.9; } opacity: 0.9; }
#notification_badge { ul#settings_nav {
position: fixed; list-style: none;
bottom: 0; padding: 0;
margin-left: 854px; } marign: 0;
#notification_badge a { font-size: larger; }
background-color: #eeeeee; ul#settings_nav > li a {
border: 1px solid #cccccc; display: block;
border-bottom: none; height: 100%;
padding: 3px 10px; } border-bottom: 1px solid #eeeeee;
padding: 5px 0; }
.settings_pane {
display: none; }
#fancybox-close:hover { #fancybox-close:hover {
background-color: transparent; } background-color: transparent; }

View file

@ -839,21 +839,30 @@ h1.big_text
:-moz-box-shadow 0 2px 4px #333 :-moz-box-shadow 0 2px 4px #333
:opacity 0.9 :opacity 0.9
#notification_badge ul#settings_nav
:position fixed :list
:bottom 0 :style none
:margin :padding 0
:left 854px :marign 0
:font
:size larger
> li
a a
:background :display block
:color #eee :height 100%
:border
:bottom 1px solid #eee
:padding 5px 0
:border 1px solid #ccc
:bottom none
:padding 3px 10px .settings_pane
:display none
#fancybox-close:hover #fancybox-close:hover
:background :background
:color transparent :color transparent

View file

@ -69,3 +69,11 @@ Factory.define :photo do |p|
end end
Factory.define(:comment) {} 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

79
spec/fixtures/fb_status vendored Normal file
View file

@ -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"
}
}
}

View file

@ -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

View file

@ -46,15 +46,6 @@ describe User do
end end
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 describe '#update_post' do
it 'should update fields' do it 'should update fields' do
album = user.post(:album, :name => "Profile Photos", :to => aspect.id) album = user.post(:album, :name => "Profile Photos", :to => aspect.id)

View file

@ -12,13 +12,38 @@ describe User do
let!(:user2) { Factory(:user_with_aspect) } let!(:user2) { Factory(:user_with_aspect) }
let!(:status_message1) { user2.post :status_message, :message => "hi", :to => user2.aspects.first.id } 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 before do
friend_users(user, first_aspect, user2, user2.aspects.first) friend_users(user, first_aspect, user2, user2.aspects.first)
end end
describe "#visible_posts" do 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) user3 = Factory(:user_with_aspect)
status_message2 = user3.post :status_message, :message => "heyyyy", :to => user3.aspects.first.id status_message2 = user3.post :status_message, :message => "heyyyy", :to => user3.aspects.first.id
user4 = Factory(:user_with_aspect) user4 = Factory(:user_with_aspect)