rplatform-rails 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +0 -0
- data/History.txt +2 -0
- data/Manifest.txt +22 -0
- data/README.txt +33 -0
- data/Rakefile +15 -0
- data/init.rb +22 -0
- data/lib/rplatform-rails.rb +45 -0
- data/lib/rplatform_rails/controller_extensions.rb +572 -0
- data/lib/rplatform_rails/model_extensions.rb +218 -0
- data/lib/rplatform_rails/session_extensions.rb +198 -0
- data/lib/rplatform_rails/status_manager.rb +312 -0
- data/lib/rplatform_rails/view_extensions.rb +93 -0
- data/tasks/all.rake +176 -0
- data/templates/debug_panel.rhtml +220 -0
- data/templates/exception_backtrace.rhtml +105 -0
- data/test/api_test.rb +203 -0
- data/test/controller_test.rb +257 -0
- data/test/initialization_test.rb +29 -0
- data/test/model_test.rb +142 -0
- data/test/session_test.rb +64 -0
- data/test/test_helper.rb +105 -0
- data/test/view_test.rb +30 -0
- metadata +92 -0
@@ -0,0 +1,93 @@
|
|
1
|
+
# AUTHORS:
|
2
|
+
# - Curtis Edmond (www.okwithfailure.com)
|
3
|
+
# thanks to matt for rfacebook
|
4
|
+
# - Matt Pizzimenti (www.livelearncode.com)
|
5
|
+
|
6
|
+
# LICENSE:
|
7
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
8
|
+
# are permitted provided that the following conditions are met:
|
9
|
+
#
|
10
|
+
# Redistributions of source code must retain the above copyright notice,
|
11
|
+
# this list of conditions and the following disclaimer.
|
12
|
+
#
|
13
|
+
# Redistributions in binary form must reproduce the above copyright notice,
|
14
|
+
# this list of conditions and the following disclaimer in the documentation
|
15
|
+
# and/or other materials provided with the distribution.
|
16
|
+
#
|
17
|
+
# Neither the name of the original author nor the names of contributors
|
18
|
+
# may be used to endorse or promote products derived from this software
|
19
|
+
# without specific prior written permission.
|
20
|
+
#
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
22
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
23
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
24
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
25
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
26
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
27
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
28
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
29
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
30
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
31
|
+
|
32
|
+
module RPlatform
|
33
|
+
module Rails
|
34
|
+
module ViewExtensions
|
35
|
+
|
36
|
+
# returns true if the user is viewing the canvas
|
37
|
+
def self.shit
|
38
|
+
p 'AAIIEEE'
|
39
|
+
end
|
40
|
+
|
41
|
+
def in_facebook_canvas?
|
42
|
+
@controller.in_facebook_canvas?
|
43
|
+
end
|
44
|
+
|
45
|
+
# returns true if the user is in an iframe
|
46
|
+
def in_facebook_frame?
|
47
|
+
@controller.in_facebook_frame?
|
48
|
+
end
|
49
|
+
|
50
|
+
# returns true if the render is using mock ajax
|
51
|
+
def in_mock_ajax?
|
52
|
+
@controller.in_mock_ajax?
|
53
|
+
end
|
54
|
+
|
55
|
+
# returns true if the render is using mock ajax
|
56
|
+
def in_ajax?
|
57
|
+
@controller.in_ajax?
|
58
|
+
end
|
59
|
+
|
60
|
+
# returns the current fb_sig_params (only if they validated properly)
|
61
|
+
def fbparams
|
62
|
+
@controller.fbparams
|
63
|
+
end
|
64
|
+
|
65
|
+
# returns the current user's Facebook session (an instance of FacebookWebSession)
|
66
|
+
def fbsession
|
67
|
+
@controller.fbsession
|
68
|
+
end
|
69
|
+
|
70
|
+
# overrides the path_to_image method to ensure that all images are written
|
71
|
+
# with absolute paths
|
72
|
+
def image_path(*params)
|
73
|
+
path = super(*params)
|
74
|
+
if ((in_facebook_canvas? or in_mock_ajax? or in_ajax?) and !(/(\w+)(\:\/\/)([\w0-9\.]+)([\:0-9]*)(.*)/.match(path)))
|
75
|
+
path = "#{request.protocol}#{request.host_with_port}#{path}"
|
76
|
+
end
|
77
|
+
return path
|
78
|
+
end
|
79
|
+
|
80
|
+
# Aliases to path_to_image for Rails 1.0 backwards compatibility
|
81
|
+
# def image_path(*params)
|
82
|
+
# path_to_image(*params)
|
83
|
+
# end
|
84
|
+
|
85
|
+
# renders the RFacebook debug panel
|
86
|
+
def facebook_debug_panel(options={}) # :nodoc:
|
87
|
+
RAILS_DEFAULT_LOGGER.info "** RFACEBOOK DEPRECATION WARNING: 'facebook_debug_panel' is deprecated in ActionViews"
|
88
|
+
return @controller.facebook_debug_panel(options)
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
data/tasks/all.rake
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
# AUTHORS:
|
2
|
+
# - Matt Pizzimenti (www.livelearncode.com)
|
3
|
+
# - Evan Weaver (http://blog.evanweaver.com)
|
4
|
+
|
5
|
+
# LICENSE:
|
6
|
+
# Redistribution and use in source and binary forms, with or without modification,
|
7
|
+
# are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# Redistributions of source code must retain the above copyright notice,
|
10
|
+
# this list of conditions and the following disclaimer.
|
11
|
+
#
|
12
|
+
# Redistributions in binary form must reproduce the above copyright notice,
|
13
|
+
# this list of conditions and the following disclaimer in the documentation
|
14
|
+
# and/or other materials provided with the distribution.
|
15
|
+
#
|
16
|
+
# Neither the name of the original author nor the names of contributors
|
17
|
+
# may be used to endorse or promote products derived from this software
|
18
|
+
# without specific prior written permission.
|
19
|
+
#
|
20
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
21
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
24
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
26
|
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
27
|
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
28
|
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
29
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
# Rake tasks modified from Evan Weaver's article
|
32
|
+
# http://blog.evanweaver.com/articles/2007/07/13/developing-a-facebook-app-locally
|
33
|
+
|
34
|
+
namespace "facebook" do
|
35
|
+
|
36
|
+
######################################################################################
|
37
|
+
######################################################################################
|
38
|
+
desc "Sets up the RFacebook Rails Plugin. Right now, this simply copies facebook.yml into your config directory."
|
39
|
+
task "setup" do
|
40
|
+
|
41
|
+
filename = "#{RAILS_ROOT}/config/facebook.yml"
|
42
|
+
puts "======================================================"
|
43
|
+
puts "Setting up RFacebook on Rails Plugin"
|
44
|
+
|
45
|
+
###### Install sample facebook.yml
|
46
|
+
file = File.new(filename, "w")
|
47
|
+
file <<
|
48
|
+
"
|
49
|
+
development:
|
50
|
+
facebook:
|
51
|
+
key: YOUR_API_KEY_HERE
|
52
|
+
secret: YOUR_API_SECRET_HERE
|
53
|
+
canvas_path: /yourfbAppName/
|
54
|
+
callback_path: /path/to/your/fbcallback/
|
55
|
+
tunnel:
|
56
|
+
username: yourLoginName
|
57
|
+
host: www.yourexternaldomain.com
|
58
|
+
port: 1234
|
59
|
+
local_port: 5678
|
60
|
+
bebo:
|
61
|
+
key: YOUR_API_KEY_HERE
|
62
|
+
secret: YOUR_API_SECRET_HERE
|
63
|
+
canvas_path: /yourbeboAppName/
|
64
|
+
callback_path: /path/to/your/bebocallback/
|
65
|
+
tunnel:
|
66
|
+
username: yourLoginName
|
67
|
+
host: www.yourexternaldomain.com
|
68
|
+
port: 1234
|
69
|
+
local_port: 5678
|
70
|
+
|
71
|
+
test:
|
72
|
+
facebook:
|
73
|
+
key: YOUR_API_KEY_HERE
|
74
|
+
secret: YOUR_API_SECRET_HERE
|
75
|
+
canvas_path: /yourfbAppName/
|
76
|
+
callback_path: /path/to/your/fbcallback/
|
77
|
+
tunnel:
|
78
|
+
username: yourLoginName
|
79
|
+
host: www.yourexternaldomain.com
|
80
|
+
port: 1234
|
81
|
+
local_port: 5678
|
82
|
+
bebo:
|
83
|
+
key: YOUR_API_KEY_HERE
|
84
|
+
secret: YOUR_API_SECRET_HERE
|
85
|
+
canvas_path: /yourbeboAppName/
|
86
|
+
callback_path: /path/to/your/bebocallback/
|
87
|
+
tunnel:
|
88
|
+
username: yourLoginName
|
89
|
+
host: www.yourexternaldomain.com
|
90
|
+
port: 1234
|
91
|
+
local_port: 5678
|
92
|
+
|
93
|
+
production:
|
94
|
+
facebook:
|
95
|
+
key: YOUR_API_KEY_HERE
|
96
|
+
secret: YOUR_API_SECRET_HERE
|
97
|
+
canvas_path: /yourfbAppName/
|
98
|
+
callback_path: /path/to/your/fbcallback/
|
99
|
+
tunnel:
|
100
|
+
username: yourLoginName
|
101
|
+
host: www.yourexternaldomain.com
|
102
|
+
port: 1234
|
103
|
+
local_port: 5678
|
104
|
+
bebo:
|
105
|
+
key: YOUR_API_KEY_HERE
|
106
|
+
secret: YOUR_API_SECRET_HERE
|
107
|
+
canvas_path: /yourbeboAppName/
|
108
|
+
callback_path: /path/to/your/bebocallback/
|
109
|
+
tunnel:
|
110
|
+
username: yourLoginName
|
111
|
+
host: www.yourexternaldomain.com
|
112
|
+
port: 1234
|
113
|
+
local_port: 5678
|
114
|
+
"
|
115
|
+
file.close_write
|
116
|
+
puts " [1] Created config/facebook.yml <-- BE SURE TO CHANGE THE API KEY AND SECRET"
|
117
|
+
|
118
|
+
###### Finished
|
119
|
+
puts "Done."
|
120
|
+
puts "======================================================"
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
namespace "tunnel" do
|
125
|
+
|
126
|
+
######################################################################################
|
127
|
+
######################################################################################
|
128
|
+
## TODO: let this take in a network, like "facebook" or "bebo"
|
129
|
+
desc "Start a reverse tunnel to develop from localhost. Please ensure that you have a properly configured config/facebook.yml file."
|
130
|
+
task "start" => "environment" do
|
131
|
+
puts FACEBOOK.inspect
|
132
|
+
remoteUsername = FACEBOOK['facebook']['tunnel']['username']
|
133
|
+
remoteHost = FACEBOOK['facebook']['tunnel']['host']
|
134
|
+
remotePort = FACEBOOK['facebook']['tunnel']['port']
|
135
|
+
localPort = FACEBOOK['facebook']['tunnel']['local_port']
|
136
|
+
sshPort = FACEBOOK['facebook']['tunnel']['ssh_port'] || "22"
|
137
|
+
|
138
|
+
puts "======================================================"
|
139
|
+
puts "Tunneling #{remoteHost}:#{remotePort} to 0.0.0.0:#{localPort}"
|
140
|
+
|
141
|
+
puts
|
142
|
+
puts "NOTES:"
|
143
|
+
puts "* ensure that you have Rails running on your local machine at port #{localPort}"
|
144
|
+
puts "* once logged in to the tunnel, you can visit http://#{remoteHost}:#{remotePort} to view your site"
|
145
|
+
puts "* use ctrl-c to quit the tunnel"
|
146
|
+
puts "* if you have problems creating the tunnel, you may need to add the following to /etc/ssh/sshd_config on your server:"
|
147
|
+
puts "
|
148
|
+
GatewayPorts clientspecified
|
149
|
+
|
150
|
+
"
|
151
|
+
puts "* if you have problems with #{remoteHost} timing out your ssh connection, add the following lines to your '~/.ssh/config' file:"
|
152
|
+
puts "
|
153
|
+
Host #{remoteHost}
|
154
|
+
ServerAliveInterval 120
|
155
|
+
|
156
|
+
"
|
157
|
+
puts "======================================================"
|
158
|
+
exec "ssh -p #{sshPort} -nNT -g -R *:#{remotePort}:0.0.0.0:#{localPort} #{remoteUsername}@#{remoteHost}"
|
159
|
+
end
|
160
|
+
|
161
|
+
######################################################################################
|
162
|
+
######################################################################################
|
163
|
+
desc "Check if reverse tunnel is running"
|
164
|
+
task "status" => "environment" do
|
165
|
+
sshPort = FACEBOOK['tunnel']['ssh_port'] || "22"
|
166
|
+
if `ssh -p #{sshPort} #{FACEBOOK['tunnel']['username']}@#{FACEBOOK['tunnel']['host']} netstat -an |
|
167
|
+
egrep "tcp.*:#{FACEBOOK['tunnel']['port']}.*LISTEN" | wc`.to_i > 0
|
168
|
+
puts "Tunnel still running"
|
169
|
+
else
|
170
|
+
puts "Tunnel is down"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
end
|
@@ -0,0 +1,220 @@
|
|
1
|
+
<style type="text/css">
|
2
|
+
|
3
|
+
.RFacebook .environment
|
4
|
+
{
|
5
|
+
padding: 30px;
|
6
|
+
|
7
|
+
background: #F7F7F7;
|
8
|
+
border-bottom: 1px solid #B7B7B7;
|
9
|
+
}
|
10
|
+
|
11
|
+
.RFacebook .environment a
|
12
|
+
{
|
13
|
+
color: #3F5A95;
|
14
|
+
}
|
15
|
+
|
16
|
+
.RFacebook .environment table
|
17
|
+
{
|
18
|
+
margin: 0px auto 5px auto;
|
19
|
+
width: 100%;
|
20
|
+
|
21
|
+
border-collapse: collapse;
|
22
|
+
}
|
23
|
+
|
24
|
+
.RFacebook .environment td
|
25
|
+
{
|
26
|
+
padding: 5px;
|
27
|
+
padding-left: 10px;
|
28
|
+
border-width: 1px 0px 1px 0px;
|
29
|
+
|
30
|
+
border-color: #ccc;
|
31
|
+
border-style: solid;
|
32
|
+
font-size: 0.9em;
|
33
|
+
}
|
34
|
+
|
35
|
+
.RFacebook .environment td.value
|
36
|
+
{
|
37
|
+
width: 100%;
|
38
|
+
|
39
|
+
color: #777;
|
40
|
+
}
|
41
|
+
|
42
|
+
.RFacebook .environment td.header
|
43
|
+
{
|
44
|
+
padding-top: 10px;
|
45
|
+
padding-left: 0px;
|
46
|
+
border-top-width: 0px;
|
47
|
+
|
48
|
+
font-weight: bold;
|
49
|
+
font-size: 1.3em;
|
50
|
+
}
|
51
|
+
|
52
|
+
.RFacebook .environment h1
|
53
|
+
{
|
54
|
+
margin: 0px 0px 5px 0px;
|
55
|
+
padding: 0px;
|
56
|
+
|
57
|
+
color: #3F5A95;
|
58
|
+
font-size: 1.6em;
|
59
|
+
}
|
60
|
+
|
61
|
+
.RFacebook .environment p
|
62
|
+
{
|
63
|
+
padding: 5px;
|
64
|
+
margin: 0px 0px 20px 0px;
|
65
|
+
|
66
|
+
color: #777;
|
67
|
+
}
|
68
|
+
|
69
|
+
.RFacebook .error
|
70
|
+
{
|
71
|
+
color: red;
|
72
|
+
margin: 0px;
|
73
|
+
padding: 2px;
|
74
|
+
color: #FF9A8D;
|
75
|
+
background-color: #900;
|
76
|
+
}
|
77
|
+
|
78
|
+
.RFacebook .valid
|
79
|
+
{
|
80
|
+
margin: 0px;
|
81
|
+
padding: 2px;
|
82
|
+
color: #B2FE8C;
|
83
|
+
background-color: #06B012;
|
84
|
+
}
|
85
|
+
|
86
|
+
.RFacebook table.details
|
87
|
+
{
|
88
|
+
border-collapse: collapse;
|
89
|
+
width: auto;
|
90
|
+
}
|
91
|
+
|
92
|
+
.RFacebook table.details td
|
93
|
+
{
|
94
|
+
border: none;
|
95
|
+
padding: 0px;
|
96
|
+
color: #777;
|
97
|
+
}
|
98
|
+
|
99
|
+
.RFacebook table.details td.value
|
100
|
+
{
|
101
|
+
width: 100%;
|
102
|
+
padding-left: 10px;
|
103
|
+
color: black;
|
104
|
+
}
|
105
|
+
|
106
|
+
.RFacebook .backtrace
|
107
|
+
{
|
108
|
+
border-collapse: collapse;
|
109
|
+
background-color: #3B5998;
|
110
|
+
color: white;
|
111
|
+
}
|
112
|
+
|
113
|
+
.RFacebook .backtrace
|
114
|
+
{
|
115
|
+
padding: 30px;
|
116
|
+
background: #3B5998;
|
117
|
+
}
|
118
|
+
|
119
|
+
.RFacebook .backtrace h1
|
120
|
+
{
|
121
|
+
margin: 0px 0px 5px 0px;
|
122
|
+
padding: 0px;
|
123
|
+
|
124
|
+
color: white;
|
125
|
+
font-size: 1.6em;
|
126
|
+
}
|
127
|
+
|
128
|
+
/*
|
129
|
+
.RFacebook table.backtrace td
|
130
|
+
{
|
131
|
+
padding: 10px 2px 10px 2px;
|
132
|
+
border-width: 1px 0px 1px 0px;
|
133
|
+
|
134
|
+
border-style: solid;
|
135
|
+
border-color: #ccc;
|
136
|
+
}
|
137
|
+
*/
|
138
|
+
|
139
|
+
.RFacebook .backtrace div.summary
|
140
|
+
{
|
141
|
+
font-size: 1.2em;
|
142
|
+
padding: 2px;
|
143
|
+
color: white;
|
144
|
+
}
|
145
|
+
|
146
|
+
.RFacebook .backtrace div.rawsummary
|
147
|
+
{
|
148
|
+
font-size: 0.7em;
|
149
|
+
color: #6D84B4;
|
150
|
+
padding-left: 5px;
|
151
|
+
}
|
152
|
+
|
153
|
+
.RFacebook ul
|
154
|
+
{
|
155
|
+
margin: 0px;
|
156
|
+
padding: 0px;
|
157
|
+
list-style-type: none;
|
158
|
+
}
|
159
|
+
|
160
|
+
.RFacebook ul li
|
161
|
+
{
|
162
|
+
list-style-type: none;
|
163
|
+
padding: 5px;
|
164
|
+
}
|
165
|
+
|
166
|
+
</style>
|
167
|
+
|
168
|
+
<div class="RFacebook">
|
169
|
+
|
170
|
+
<div class="environment">
|
171
|
+
|
172
|
+
<h1>RFacebook <span style="font-weight: normal; color: #777">environment information</span></h1>
|
173
|
+
<p>
|
174
|
+
This shows you at a glance the information that RFacebook has populated
|
175
|
+
for you.
|
176
|
+
<br/>
|
177
|
+
More information at <a href="http://rfacebook.rubyforge.org">rfacebook.rubyforge.org</a>.
|
178
|
+
Please report RFacebook bugs <a href="http://rubyforge.org/tracker/?func=add&group_id=3607&atid=13796">here</a>.
|
179
|
+
|
180
|
+
</p>
|
181
|
+
|
182
|
+
<table>
|
183
|
+
|
184
|
+
<!-- ####################### ActionController ####################### -->
|
185
|
+
<tr>
|
186
|
+
<td colspan="3" class="header"><%= self.class %></td>
|
187
|
+
</tr>
|
188
|
+
|
189
|
+
<% facebook_status_manager.each_status_check do |statusCheck| %>
|
190
|
+
<tr>
|
191
|
+
<td class="title"><%= statusCheck.title %></td>
|
192
|
+
<td class="rstatus">
|
193
|
+
<% if statusCheck.valid? %>
|
194
|
+
<span class="valid">OK</span>
|
195
|
+
<% else %>
|
196
|
+
<span class="error">PROBLEM</span>
|
197
|
+
<% end %>
|
198
|
+
</td>
|
199
|
+
<td class="value">
|
200
|
+
<% if statusCheck.message.is_a? String %>
|
201
|
+
<%= statusCheck.message %>
|
202
|
+
<% elsif statusCheck.message.is_a? Hash %>
|
203
|
+
<table class="details">
|
204
|
+
<% statusCheck.message.each do |k,v| %>
|
205
|
+
<tr>
|
206
|
+
<td><%= k %></td>
|
207
|
+
<td class="value"><%= v %></td>
|
208
|
+
</tr>
|
209
|
+
<% end %>
|
210
|
+
</table>
|
211
|
+
<% end %>
|
212
|
+
</td>
|
213
|
+
</tr>
|
214
|
+
<% end %>
|
215
|
+
|
216
|
+
|
217
|
+
</table>
|
218
|
+
|
219
|
+
</div>
|
220
|
+
</div>
|