20 |
|
|
21 |
# UI elements |
# UI elements |
22 |
|
|
23 |
|
my $facebook = WWW::Facebook::API->new( |
24 |
|
api_key => $api_key, |
25 |
|
secret => $secret, |
26 |
|
app_path => $app_path, |
27 |
|
parse => 1, |
28 |
|
); |
29 |
|
|
30 |
|
warn dump($facebook); |
31 |
|
|
32 |
sub dashboard { |
sub dashboard { |
33 |
print qq| |
print qq| |
34 |
<fb:dashboard> |
<fb:dashboard> |
35 |
<fb:action href=/$app_path/>Search</fb:action> |
<fb:action href=/$app_path/>Search</fb:action> |
|
<fb:action href=/$app_path/info>info</fb:action> |
|
36 |
</fb:dashboard> |
</fb:dashboard> |
37 |
|; |
|; |
38 |
''; |
''; |
52 |
''; |
''; |
53 |
} |
} |
54 |
|
|
55 |
|
# dispatcher |
|
my $facebook = WWW::Facebook::API->new( |
|
|
api_key => $api_key, |
|
|
secret => $secret, |
|
|
app_path => $app_path, |
|
|
parse => 1, |
|
|
); |
|
56 |
|
|
57 |
our %action_map = ( |
our %action_map = ( |
58 |
'' => \&index_page, |
'' => \&index_page, |
85 |
|
|
86 |
my ( $action, $param ) = ( $q->path_info =~ m!^/(\w+)/?(.*)! ); |
my ( $action, $param ) = ( $q->path_info =~ m!^/(\w+)/?(.*)! ); |
87 |
|
|
|
if ( my $s = $action_map{$action} ) { |
|
88 |
print dashboard; |
print dashboard; |
89 |
|
|
90 |
|
if ( my $s = $action_map{$action} ) { |
91 |
print qq|<div style='padding-left: 2em'>|; |
print qq|<div style='padding-left: 2em'>|; |
92 |
$s->( $q, $params ); |
$s->( $q, $params ); |
93 |
print qq|</div>|; |
print qq|</div>|; |
94 |
} |
} |
95 |
else { |
else { |
96 |
div_error("Action unknown"); |
print "Action <tt>$action</tt> unknown"; |
97 |
|
warn "unknown action $action"; |
98 |
} |
} |
99 |
|
|
100 |
# Clear session_key (for if running under FastCGI). |
# Clear session_key (for if running under FastCGI). |
104 |
sub index_page { |
sub index_page { |
105 |
my ( $q, $params ) = @_; |
my ( $q, $params ) = @_; |
106 |
|
|
107 |
|
warn dump($params); |
108 |
|
|
109 |
form($q); |
form($q); |
110 |
|
|
111 |
=for later |
=for later |
120 |
} |
} |
121 |
print "$name ", ( $params ? "have" : "have't" ), |
print "$name ", ( $params ? "have" : "have't" ), |
122 |
" added this application. Some <a href='info'>info</a>."; |
" added this application. Some <a href='info'>info</a>."; |
123 |
|
=cut |
124 |
|
|
125 |
if ( !$params ) { |
if ( !$params ) { |
126 |
print "<a href='", $facebook->get_add_url, |
print "<a href='", $facebook->get_add_url, |
127 |
"'>Add this application</a>."; |
"'>Add this application</a>."; |
128 |
} |
} |
129 |
|
|
|
=cut |
|
130 |
|
|
131 |
|
|
132 |
} |
} |