Skip to content

Commit 9b9ef9a

Browse files
Corey Innismmangino
Corey Innis
authored andcommitted
initial experiment at getting generators to load from gem
1 parent 727aa70 commit 9b9ef9a

File tree

6 files changed

+166
-1
lines changed

6 files changed

+166
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pkg

Manifest.txt

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ README.txt
77
Rakefile
88
TODO.txt
99
facebooker.yml.tpl
10+
generators/facebooker/facebooker_generator.rb
11+
generators/facebooker/templates/config/facebooker.yml.tmpl
12+
generators/facebooker/templates/public/javascripts/facebooker.js
1013
generators/publisher/publisher_generator.rb
1114
generators/publisher/templates/publisher.rb
1215
generators/controller/USAGE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class FacebookerGenerator < Rails::Generator::Base
2+
def manifest
3+
record do |m|
4+
m.file 'config/facebooker.yml.tmpl', 'config/facebooker.yml'
5+
m.file 'public/javascripts/facebooker.js', 'public/javascripts/facebooker.js'
6+
end
7+
end
8+
9+
protected
10+
11+
def banner
12+
"Usage: #{$0} facebooker"
13+
end
14+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# The api key, secret key, and canvas page name are required to get started
2+
# Tunnel configuration is only needed if you are going to use the facebooker:tunnel Rake tasks
3+
# Your callback url in Facebook should be set to http://public_host:public_port
4+
# To develop for the new profile design, add the following key..
5+
# api: new
6+
# remove the key or set it to anything else to use the old facebook design.
7+
# This should only be necessary until the final version of the new profile is released.
8+
9+
development:
10+
api_key:
11+
secret_key:
12+
canvas_page_name:
13+
callback_url:
14+
pretty_errors: true
15+
tunnel:
16+
public_host_username:
17+
public_host:
18+
public_port: 4007
19+
local_port: 3000
20+
21+
test:
22+
api_key:
23+
secret_key:
24+
canvas_page_name:
25+
callback_url:
26+
tunnel:
27+
public_host_username:
28+
public_host:
29+
public_port: 4007
30+
local_port: 3000
31+
32+
production:
33+
api_key:
34+
secret_key:
35+
canvas_page_name:
36+
callback_url:
37+
tunnel:
38+
public_host_username:
39+
public_host:
40+
public_port: 4007
41+
local_port: 3000
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
2+
function $(element) {
3+
if (typeof element == "string") {
4+
element=document.getElementById(element);
5+
}
6+
if (element)
7+
extend_instance(element,Element);
8+
return element;
9+
}
10+
11+
function extend_instance(instance,hash) {
12+
for (var name in hash) {
13+
instance[name] = hash[name];
14+
}
15+
}
16+
17+
var Element = {
18+
"hide": function () {
19+
this.setStyle("display","none")
20+
},
21+
"show": function () {
22+
this.setStyle("display","block")
23+
},
24+
"visible": function () {
25+
return (this.getStyle("display") != "none");
26+
},
27+
"toggle": function () {
28+
if (this.visible) {
29+
this.hide();
30+
} else {
31+
this.show();
32+
}
33+
}
34+
};
35+
36+
function encodeURIComponent(str) {
37+
if (typeof(str) == "string") {
38+
return str.replace(/=/g,'%3D').replace(/&/g,'%26');
39+
}
40+
//checkboxes and radio buttons return objects instead of a string
41+
else if(typeof(str) == "object"){
42+
for (prop in str)
43+
{
44+
return str[prop].replace(/=/g,'%3D').replace(/&/g,'%26');
45+
}
46+
}
47+
};
48+
49+
var Form = {};
50+
Form.serialize = function(form_element) {
51+
elements=$(form_element).serialize();
52+
param_string="";
53+
for (var name in elements) {
54+
if (param_string)
55+
param_string += "&";
56+
param_string += encodeURIComponent(name)+"="+encodeURIComponent(elements[name]);
57+
}
58+
return param_string;
59+
};
60+
61+
Ajax.Updater = function (container,url,options) {
62+
this.container = container;
63+
this.url=url;
64+
this.ajax = new Ajax();
65+
this.ajax.requireLogin = 1;
66+
if (options["onSuccess"]) {
67+
this.ajax.responseType = Ajax.JSON;
68+
this.ajax.ondone = options["onSuccess"];
69+
} else {
70+
this.ajax.responseType = Ajax.FBML;
71+
this.ajax.ondone = function(data) {
72+
$(container).setInnerFBML(data);
73+
}
74+
}
75+
if (options["onFailure"]) {
76+
this.ajax.onerror = options["onFailure"];
77+
}
78+
79+
// Yes, this is an excercise in undoing what we just did
80+
// FB doesn't provide encodeURI, but they will encode things passed as a hash
81+
// so we turn it into a string, esaping & and =
82+
// then we split it all back out here
83+
// this could be killed if encodeURIComponent was available
84+
parameters={};
85+
if (options['parameters']) {
86+
pairs=options['parameters'].split('&');
87+
for (var i=0; i<pairs.length; i++) {
88+
kv=pairs[i].split('=');
89+
key=kv[0].replace(/%3D/g,'=').replace(/%26/g,'&');
90+
val=kv[1].replace(/%3D/g,'=').replace(/%26/g,'&');
91+
parameters[key]=val;
92+
}
93+
}
94+
this.ajax.post(url,parameters);
95+
if (options["onLoading"]) {
96+
options["onLoading"].call()
97+
}
98+
};
99+
Ajax.Request = function(url,options) {
100+
Ajax.Updater('unused',url,options);
101+
};
102+
103+
PeriodicalExecuter = function (callback, frequency) {
104+
setTimeout(callback, frequency *1000);
105+
setTimeout(function() { new PeriodicalExecuter(callback,frequency); }, frequency*1000);
106+
};

rails/init.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
require File.join(File.dirname(__FILE__),'../init.rb')
1+
require File.join(File.dirname(__FILE__),'../init.rb')

0 commit comments

Comments
 (0)