File Coverage

blib/lib/CatalystX/FacebookURI.pm
Criterion Covered Total %
statement 1 3 33.3
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 2 4 50.0


line stmt bran cond sub pod time code
1             package CatalystX::FacebookURI;
2 1     1   21480 use Moose::Role;
  0            
  0            
3             use URI::http;
4             requires 'facebook';
5              
6             our $VERSION = '0.02';
7              
8             =head1 NAME
9              
10             CatalystX::FacebookURI - Automatically compose uri_for URIs to be within your Facebook application
11              
12             =head1 VERSION
13              
14             Version 0.02
15              
16             =head1 SYNOPSIS
17              
18             Quick summary of what the module does.
19              
20             Perhaps a little code snippet.
21              
22             package MyApp;
23             use Moose;
24             BEGIN {
25             extends 'Catalyst';
26              
27             use Catalyst::Runtime 5.80;
28             use Catalyst qw(
29             ...
30             Facebook
31             );
32             with 'CatalystX::FacebookURI';
33             }
34              
35             __PACKAGE__->config(
36             facebook => {
37             api_key => 'my_key',
38             secret => 'my_s33krit',
39             name => 'myapp' # Used as app name in URIs
40             }
41             );
42             ...
43              
44             my $uri = $c->uri_for('/some/path'); # returns http://apps.facebook.com/myapp/some/path
45              
46             =cut
47              
48             after prepare_path => sub {
49             my $c = shift;
50             my $is_ajax = $c->req->param('fb_sig_is_ajax');
51             my $is_frame = $c->facebook->canvas->in_frame();
52             my $is_canvas = $c->facebook->canvas->in_fb_canvas();
53              
54             my $app_name = $c->config->{facebook}{name};
55              
56             $c->req->base(URI->new("http://apps.facebook.com/$app_name/"))
57             if $is_ajax or $is_frame or $is_canvas;
58             };
59              
60              
61             =head1 AUTHOR
62              
63             Michael Nachbaur, C<< <mike at nachbaur.com> >>
64              
65             =head1 BUGS
66              
67             Please report any bugs or feature requests to C<bug-catalystx-facebookuri at rt.cpan.org>, or through
68             the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-FacebookURI>. I will be notified, and then you'll
69             automatically be notified of progress on your bug as I make changes.
70              
71             This project is available via Git at http://github.com/NachoMan/CatalystX-FacebookURI
72              
73              
74             =head1 SUPPORT
75              
76             You can find documentation for this module with the perldoc command.
77              
78             perldoc CatalystX::FacebookURI
79              
80              
81             You can also look for information at:
82              
83             =over 4
84              
85             =item * RT: CPAN's request tracker
86              
87             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=CatalystX-FacebookURI>
88              
89             =item * AnnoCPAN: Annotated CPAN documentation
90              
91             L<http://annocpan.org/dist/CatalystX-FacebookURI>
92              
93             =item * CPAN Ratings
94              
95             L<http://cpanratings.perl.org/d/CatalystX-FacebookURI>
96              
97             =item * Search CPAN
98              
99             L<http://search.cpan.org/dist/CatalystX-FacebookURI/>
100              
101             =back
102              
103             =head1 COPYRIGHT & LICENSE
104              
105             Copyright 2010 Michael Nachbaur.
106              
107             This program is free software; you can redistribute it and/or modify it
108             under the terms of either: the GNU General Public License as published
109             by the Free Software Foundation; or the Artistic License.
110              
111             See http://dev.perl.org/licenses/ for more information.
112              
113              
114             =cut
115              
116             1; # End of CatalystX::FacebookURI