-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
111 lines (92 loc) · 2.73 KB
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
require 'rubygems'
require 'sinatra'
require 'koala'
require 'pg'
require 'data_mapper'
require 'time'
require File.join(File.dirname(__FILE__), "urllist.rb")
include Koala
enable :sessions
#facebook
APP_ID = 541378595892777
APP_SECRET = '10222e30a7db20399a5a10b882b30bcf'
SITE_URL = 'http://14.63.164.245/'
url = 'postgres://mpgapjicswidul:Kc53rL4M4jbRm1CgRg5t9onrAr@ec2-54-225-105-169.compute-1.amazonaws.com:5432/d9698rcak6lu5h'
DataMapper.setup(:default, url)
class Account
include DataMapper::Resource
property :accountid, Text ,:key =>true
property :password, Text
property :updated_at, DateTime
has n, :users
has n, :relations
validates_uniqueness_of :accountid, :message => "There's already a registration of that ID"
end
class User
include DataMapper::Resource
belongs_to :account
property :userid, Text , :key =>true
property :name, Text
property :sex, Text
has n, :photos
validates_uniqueness_of :userid, :message => "There's already a registration of that ID"
end
class Photo
include DataMapper::Resource
belongs_to :user
property :id, Serial
property :url , Text
end
class Info
include DataMapper::Resource
property :name, Text
property :userid, Text, :key =>true
property :url, Text
property :photopath, Text
end
SITE_TITLE = "Architect for the World"
set :bind, '0.0.0.0'
@myfirstphoto = nil
get '/' do
@title = 'EVA'
unless session['access_token'] == nil
graph = Koala::Facebook::API.new(session['access_token'])
profile = graph.get_object("me")
myuid = profile["id"]
session['id'] = myuid
sess = session[:id]
@myfirstphoto = 'http://res.cloudinary.com/dobny9ati/image/facebook/w_70,h_70,c_fill/'+profile["id"]+'.jpg'
end
urlclass = Memberurl.new
@photoaddress = urlclass.geturl
p @photoaddress
erb :main
end
get '/callback' do
session['access_token'] = session['oauth'].get_access_token(params[:code])
redirect '/login'
end
get '/admin' do
# generate a new oauth object with your app data and your callback url
session['oauth'] = Facebook::OAuth.new(APP_ID, APP_SECRET, SITE_URL + 'callback')
session['fb_access_token'] = session['oauth'].get_app_access_token
@graph = Koala::Facebook::API.new(session['oauth'].get_app_access_token)
redirect session['oauth'].url_for_oauth_code(:permissions => "publish_stream")
end
get '/login' do
graph = Koala::Facebook::API.new(session['access_token'])
profile = graph.get_object("me")
session['id'] = profile["id"]
session['name'] = profile["name"]
sess = session[:id]
redirect '/edit_account'
# "url" => 'http://res.cloudinary.com/dobny9ati/image/facebook/w_405,h_480,c_fill/'+url['user_userid'].to_s+'.jpg'
end
get '/edit_account' do
session['id']
@yourname = session['name'].to_s
erb :editaccount
end
get '/presentation' do
erb :presentaion
end