basic setup

This commit is contained in:
danielvincent 2010-09-21 12:29:39 -07:00
parent 08df7e1250
commit 9571ade89c
8 changed files with 69 additions and 16 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

4
config/fb_config.yml Normal file
View file

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

View file

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