sco-fakebook 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +18 -0
- data/Manifest +20 -0
- data/README +74 -0
- data/Rakefile +35 -0
- data/TODO +16 -0
- data/bin/fakebook +97 -0
- data/fakebook.gemspec +39 -0
- data/lib/fakebook-assets/base.js +317 -0
- data/lib/fakebook-assets/canvas.css +17 -0
- data/lib/fakebook-assets/common.css +1599 -0
- data/lib/fakebook-assets/extended.js +49 -0
- data/lib/fakebook-assets/fakebook.js +122 -0
- data/lib/fakebook-assets/fbml.js +346 -0
- data/lib/fakebook-assets/navigator_bg.gif +0 -0
- data/lib/fakebook-assets/shadow_gray.gif +0 -0
- data/lib/fakebook-assets/string.js +61 -0
- data/lib/fakebook-assets/white.gif +0 -0
- data/lib/fakebook.rb +141 -0
- data/lib/node.rb +530 -0
- data/lib/templates/minimal.html.erb +22 -0
- data/lib/templates/standard.html.erb +62 -0
- data/lib/tokenizer.rb +105 -0
- metadata +86 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Copyright (c) 2008 Scott Raymond <sco@scottraymond.net>
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
7
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
8
|
+
subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
15
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
16
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
bin/fakebook
|
|
2
|
+
lib/fakebook-assets/base.js
|
|
3
|
+
lib/fakebook-assets/canvas.css
|
|
4
|
+
lib/fakebook-assets/common.css
|
|
5
|
+
lib/fakebook-assets/extended.js
|
|
6
|
+
lib/fakebook-assets/fakebook.js
|
|
7
|
+
lib/fakebook-assets/fbml.js
|
|
8
|
+
lib/fakebook-assets/navigator_bg.gif
|
|
9
|
+
lib/fakebook-assets/shadow_gray.gif
|
|
10
|
+
lib/fakebook-assets/string.js
|
|
11
|
+
lib/fakebook-assets/white.gif
|
|
12
|
+
lib/fakebook.rb
|
|
13
|
+
lib/node.rb
|
|
14
|
+
lib/templates/minimal.html.erb
|
|
15
|
+
lib/templates/standard.html.erb
|
|
16
|
+
lib/tokenizer.rb
|
|
17
|
+
LICENSE
|
|
18
|
+
Manifest
|
|
19
|
+
README
|
|
20
|
+
TODO
|
data/README
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
= Fakebook
|
|
2
|
+
|
|
3
|
+
Fakebook simulates the Facebook platform, to aid in developing Facebook canvas apps offline.
|
|
4
|
+
It takes a request and passes it to the app as a POST with the fb_sig_* params added, etc.
|
|
5
|
+
The response is returned with FBML parsed (sort of) and some chrome added.
|
|
6
|
+
|
|
7
|
+
In other words: you can work on Facebook canvas apps when you're on a plane.
|
|
8
|
+
|
|
9
|
+
To use, run 'fakebook' from the command line to start up a Fakebook proxy. For example, if you
|
|
10
|
+
have an app running on port 3000, and the callback path is "/", and the canvas path
|
|
11
|
+
is "myapp", you would run:
|
|
12
|
+
|
|
13
|
+
$ fakebook --callback="http://localhost:3000/" --canvas="myapp"
|
|
14
|
+
|
|
15
|
+
See "fakebook --help" for more options. By default, Fakebook will look for a config file at
|
|
16
|
+
./config/fakebook.yml. The file should look like this:
|
|
17
|
+
|
|
18
|
+
callback: http://localhost:3000/
|
|
19
|
+
canvas: myapp
|
|
20
|
+
secret: secret
|
|
21
|
+
user: 1
|
|
22
|
+
session: session_key
|
|
23
|
+
friends: 2, 3, 4
|
|
24
|
+
host: 0.0.0.0
|
|
25
|
+
port: 5000
|
|
26
|
+
|
|
27
|
+
You can also use the library directly with the Fakebook class, which eases testing:
|
|
28
|
+
|
|
29
|
+
require 'fakebook'
|
|
30
|
+
app = Fakebook.new :callback => "http://localhost:3000/",
|
|
31
|
+
:canvas => "myapp",
|
|
32
|
+
:secret => "secret",
|
|
33
|
+
:fb_params => { :user => 1, :session_key => 'session_key', :friends => [2, 3, 4] }
|
|
34
|
+
app.request("/")
|
|
35
|
+
|
|
36
|
+
Because Fakebook implements #call according to the Rack
|
|
37
|
+
specification[http://rack.rubyforge.org/doc/files/SPEC.html], you can create an HTTP server
|
|
38
|
+
that proxies to your application using your choice of server library (Mongrel, WEBrick, Thin,
|
|
39
|
+
etc.) For example:
|
|
40
|
+
|
|
41
|
+
require 'fakebook'
|
|
42
|
+
app = Fakebook.new # etc...
|
|
43
|
+
Rack::Handler::Mongrel.run app, :Port => 5000
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
== Getting started
|
|
47
|
+
|
|
48
|
+
To install via RubyGems:
|
|
49
|
+
|
|
50
|
+
$ sudo gem install sco-fakebook --source http://gems.github.com/
|
|
51
|
+
|
|
52
|
+
Run the executable to see the available options:
|
|
53
|
+
|
|
54
|
+
$ fakebook --help
|
|
55
|
+
|
|
56
|
+
To install the development version from the repository:
|
|
57
|
+
|
|
58
|
+
$ wget http://github.com/sco/fakebook/tarball/master
|
|
59
|
+
$ tar -xvf sco-fakebook-master.tar.gz
|
|
60
|
+
$ cd sco-fakebook-master
|
|
61
|
+
$ sudo rake install_gem
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
== Dependencies
|
|
65
|
+
|
|
66
|
+
Ruby
|
|
67
|
+
Rack >= 0.3.0
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
== Author
|
|
71
|
+
|
|
72
|
+
Scott Raymond <sco@scottraymond.net>
|
|
73
|
+
|
|
74
|
+
Thanks to PackRat[http://apps.facebook.com/packrat/], from which this code was extracted.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require 'rake'
|
|
2
|
+
require './lib/fakebook'
|
|
3
|
+
|
|
4
|
+
#begin
|
|
5
|
+
# require 'rubygems'
|
|
6
|
+
# gem 'echoe', '>=2.7'
|
|
7
|
+
# ENV['RUBY_FLAGS'] = ""
|
|
8
|
+
# require 'echoe'
|
|
9
|
+
#
|
|
10
|
+
# Echoe.new('fakebook') do |p|
|
|
11
|
+
# p.project = 'fakebook'
|
|
12
|
+
# p.rubyforge_name = 'fakebook'
|
|
13
|
+
# p.version = Fakebook::Version
|
|
14
|
+
# p.summary = "Simple Facebook platform simulator, to aid in developing Facebook canvas apps offline."
|
|
15
|
+
# p.description = "Simple Facebook platform simulator, to aid in developing Facebook canvas apps offline."
|
|
16
|
+
# p.url = "http://github.com/sco/fakebook/"
|
|
17
|
+
# p.author = 'Scott Raymond'
|
|
18
|
+
# p.email = "sco@scottraymond.net"
|
|
19
|
+
# p.dependencies << 'rack >=0.3.0'
|
|
20
|
+
# p.clean_pattern.delete('lib/*-*') # so that 'rake clean' won't clobber fakebook-assets
|
|
21
|
+
# end
|
|
22
|
+
#rescue LoadError => boom
|
|
23
|
+
# puts "You are missing a dependency required for meta-operations on this gem."
|
|
24
|
+
# puts "#{boom.to_s.capitalize}."
|
|
25
|
+
#end
|
|
26
|
+
#
|
|
27
|
+
#desc 'Install as a gem'
|
|
28
|
+
#task :install_gem do
|
|
29
|
+
# puts `rake manifest package && gem install pkg/fakebook-#{Fakebook::Version}.gem`
|
|
30
|
+
#end
|
|
31
|
+
#
|
|
32
|
+
|
|
33
|
+
task :install_gem do
|
|
34
|
+
puts `gem build fakebook.gemspec && gem install fakebook-#{Fakebook::Version}.gem && rm fakebook-#{Fakebook::Version}.gem`
|
|
35
|
+
end
|
data/TODO
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
- document how to use different templates; provide config/commandline option for specifying template
|
|
2
|
+
- parse_fbml needs to become a full-blown parser
|
|
3
|
+
- if-is-user
|
|
4
|
+
- is-logged-out
|
|
5
|
+
- iframe
|
|
6
|
+
- profile-pic
|
|
7
|
+
- comments
|
|
8
|
+
- possessive names
|
|
9
|
+
- share_button
|
|
10
|
+
- fb:header, create button, action link, help link, etc.
|
|
11
|
+
- fb:tabs
|
|
12
|
+
- fb:request_form
|
|
13
|
+
- better handling of API requests
|
|
14
|
+
- allow for per-user or per-environment configs?
|
|
15
|
+
- implement ajax, including the local proxy
|
|
16
|
+
- figure out what the license and attribution is for the HTML parsing stuff
|
data/bin/fakebook
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require File.dirname(__FILE__) + '/../lib/fakebook'
|
|
4
|
+
require 'optparse'
|
|
5
|
+
require 'rack'
|
|
6
|
+
|
|
7
|
+
begin
|
|
8
|
+
server = Rack::Handler::Mongrel
|
|
9
|
+
rescue LoadError => e
|
|
10
|
+
server = Rack::Handler::WEBrick
|
|
11
|
+
end
|
|
12
|
+
rack_options = { :Port => 5000, :Host => "0.0.0.0" }
|
|
13
|
+
fakebook_options = { :callback => "http://0.0.0.0:3000/", :canvas => "myapp", :secret => "secret", :fb_params => { :user => 1, :session_key => 'session_key', :friends => [2, 3, 4] } }
|
|
14
|
+
config_file = "config/fakebook.yml"
|
|
15
|
+
|
|
16
|
+
OptionParser.new do |opts|
|
|
17
|
+
opts.banner = "Fakebook #{Fakebook::Version}. Usage: fakebook [options]"
|
|
18
|
+
|
|
19
|
+
opts.separator ""
|
|
20
|
+
opts.separator "Options:"
|
|
21
|
+
|
|
22
|
+
opts.on("-f", "--config [PATH]", "path to a YAML config file (default: #{config_file})") { |v|
|
|
23
|
+
config_file = v
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
opts.on("-c", "--callback [URL]", "the callback URL of your application (default: #{fakebook_options[:callback]})") { |v|
|
|
27
|
+
fakebook_options[:callback] = v
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
opts.on("-a", "--canvas [PATH]", "the canvas path of your application (default: #{fakebook_options[:canvas]})") { |v|
|
|
31
|
+
fakebook_options[:canvas] = v
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
opts.on("-s", "--secret [SECRET]", "the application secret (default: #{fakebook_options[:secret]})") { |v|
|
|
35
|
+
fakebook_options[:secret] = v
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
opts.on("-u", "--user [USER_ID]", "the fb id of the user (default: #{fakebook_options[:fb_params][:user]})") { |v|
|
|
39
|
+
fakebook_options[:fb_params][:user] = v
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
opts.on("-k", "--session [SESSION_KEY]", "the user's session key (default: #{fakebook_options[:fb_params][:session_key]})") { |v|
|
|
43
|
+
fakebook_options[:fb_params][:session_key] = v
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
opts.on("--friends [FRIENDS]", "the user's friends (default: #{fakebook_options[:fb_params][:friends]})") { |v|
|
|
47
|
+
fakebook_options[:fb_params][:friends] = v
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
opts.on("-h", "--host [HOST]", "host to listen on (default: #{rack_options[:Host]})") { |host|
|
|
51
|
+
rack_options[:Host] = host
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
opts.on("-p", "--port [PORT]", "port to use (default: #{rack_options[:Port]})") { |port|
|
|
55
|
+
rack_options[:Port] = port
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
opts.on("--server [SERVER]", "web server to (e.g., webrick, mongrel. default: mongrel)") { |s|
|
|
59
|
+
case s
|
|
60
|
+
when "mongrel"
|
|
61
|
+
server = Rack::Handler::Mongrel
|
|
62
|
+
when "webrick"
|
|
63
|
+
server = Rack::Handler::WEBrick
|
|
64
|
+
end
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
opts.on_tail("--help", "Show this message") do
|
|
68
|
+
puts opts
|
|
69
|
+
exit
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
end.parse!
|
|
73
|
+
|
|
74
|
+
if File.exists?(config_file)
|
|
75
|
+
config = YAML.load_file(config_file) || {}
|
|
76
|
+
fakebook_options[:callback] = config['callback'] if config['callback']
|
|
77
|
+
fakebook_options[:canvas] = config['canvas'] if config['canvas']
|
|
78
|
+
fakebook_options[:secret] = config['secret'] if config['secret']
|
|
79
|
+
fakebook_options[:fb_params][:user] = config['user'] if config['user']
|
|
80
|
+
fakebook_options[:fb_params][:session_key] = config['session'] if config['session']
|
|
81
|
+
fakebook_options[:fb_params][:friends] = config['friends'] if config['friends']
|
|
82
|
+
rack_options[:Host] = config['host'] if config['host']
|
|
83
|
+
rack_options[:Port] = config['port'] if config['port']
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
fakebook = Fakebook.new(fakebook_options)
|
|
87
|
+
app = Rack::Builder.new {
|
|
88
|
+
use Rack::CommonLogger, STDERR
|
|
89
|
+
use Rack::ShowExceptions
|
|
90
|
+
use Rack::Lint
|
|
91
|
+
run fakebook
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
STDERR.puts "Starting Fakebook proxy from http://#{rack_options[:Host]}:#{rack_options[:Port]}/#{fakebook.canvas}/ to #{fakebook.callback}"
|
|
95
|
+
STDERR.puts " Using fb_params: #{fakebook.fb_params.inspect}"
|
|
96
|
+
|
|
97
|
+
server.run app, rack_options
|
data/fakebook.gemspec
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = "fakebook"
|
|
3
|
+
s.version = "0.1.0" # also see fakebook.rb
|
|
4
|
+
s.date = "2008-04-26"
|
|
5
|
+
s.summary = "Simple Facebook platform simulator, to aid in developing Facebook canvas apps offline."
|
|
6
|
+
s.homepage = "http://github.com/sco/fakebook"
|
|
7
|
+
s.author = "Scott Raymond"
|
|
8
|
+
s.email = "sco@scottraymond.net"
|
|
9
|
+
s.add_dependency "rack", ">=0.3.0"
|
|
10
|
+
s.has_rdoc = true
|
|
11
|
+
s.rdoc_options = ["--main", "README"]
|
|
12
|
+
s.extra_rdoc_files = ["Manifest", "TODO", "README", "LICENSE"]
|
|
13
|
+
s.executables = ['fakebook']
|
|
14
|
+
s.files = ["bin/fakebook",
|
|
15
|
+
"fakebook.gemspec",
|
|
16
|
+
"lib/fakebook-assets/base.js",
|
|
17
|
+
"lib/fakebook-assets/canvas.css",
|
|
18
|
+
"lib/fakebook-assets/common.css",
|
|
19
|
+
"lib/fakebook-assets/extended.js",
|
|
20
|
+
"lib/fakebook-assets/fakebook.js",
|
|
21
|
+
"lib/fakebook-assets/fbml.js",
|
|
22
|
+
"lib/fakebook-assets/navigator_bg.gif",
|
|
23
|
+
"lib/fakebook-assets/shadow_gray.gif",
|
|
24
|
+
"lib/fakebook-assets/string.js",
|
|
25
|
+
"lib/fakebook-assets/white.gif",
|
|
26
|
+
"lib/fakebook.rb",
|
|
27
|
+
"lib/node.rb",
|
|
28
|
+
"lib/templates/minimal.html.erb",
|
|
29
|
+
"lib/templates/standard.html.erb",
|
|
30
|
+
"lib/tokenizer.rb",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"Manifest",
|
|
33
|
+
"Rakefile",
|
|
34
|
+
"README",
|
|
35
|
+
"TODO",
|
|
36
|
+
]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
#
|