File Coverage

blib/lib/Template/Plugin/Thumbalizr.pm
Criterion Covered Total %
statement 14 21 66.6
branch 0 4 0.0
condition n/a
subroutine 5 7 71.4
pod 2 2 100.0
total 21 34 61.7


line stmt bran cond sub pod time code
1             package Template::Plugin::Thumbalizr;
2              
3 1     1   66427 use 5.016003;
  1         4  
4 1     1   6 use strict;
  1         1  
  1         19  
5 1     1   5 use warnings;
  1         10  
  1         40  
6              
7 1     1   6 use base 'Template::Plugin';
  1         2  
  1         557  
8 1     1   5379 use WebService::Thumbalizr;
  1         136693  
  1         165  
9              
10             our $VERSION = '1.0.1';
11              
12              
13              
14              
15             =head1 NAME
16              
17             Template::Plugin::Thumbalizr - A Thumbalizr (https://thumbalizr.com) plugin for Template::Toolkit. This allows you to easily embed live screenshots into your website.
18              
19             =head1 SYNOPSIS
20              
21             [% USE thumbalizr = Thumbalizr('api_key', 'secret') %]
22            
23              
24             =head1 DESCRIPTION
25              
26             Thumbalizr (L) is a web service to easily embed live screenshots of any URL in your website. Thumbalizr has full support for Flash, JavaScript, CSS, & HTML5.
27              
28             The latest API version is detailed at L. WebService::Thumbalizr.
29              
30             The source code is available on github at L.
31              
32              
33             =head1 METHODS
34              
35             =head2 new()
36              
37             [% USE thumbalizr = Thumbalizr('api_key', 'secret') %]
38              
39             Initialize the Thumbalizr plugin. You must pass your API secret (login to your Thumbalizr account to display your secret).
40              
41             Arguments:
42              
43             =over 4
44              
45             =item api_key
46              
47             Required. Embed API key.
48              
49             =item secret
50              
51             Required. Thumbalizr secret.
52              
53             =back
54              
55             =cut
56              
57             sub new {
58 0     0 1   my ($class, $context, $api_key, $secret) = @_;
59            
60 0 0         return $class->fail("API key missing")
61             unless $api_key;
62            
63 0 0         return $class->fail("Secret missing")
64             unless $secret;
65            
66 0           my $thumbalizr = WebService::Thumbalizr->new(key => $api_key, secret => $secret);
67            
68            
69 0           bless {
70             _CONTEXT => $context,
71             _thumbalizr => $thumbalizr,
72             }, $class;
73            
74             }
75              
76              
77             =head2 url()
78              
79            
80              
81             Display the URL of the Thumbalizr screenshot. You can use it as the src attribute of your img tag.
82              
83             Arguments:
84              
85             =over 4
86              
87             =item url
88              
89             Required. URL of the website to create a screenshot of.
90              
91             =back
92              
93             =cut
94             sub url {
95 0     0 1   my ($self, $url, %args) = @_;
96              
97 0           return $self->{_thumbalizr}->url($url, %args);
98             }
99              
100              
101             1;
102             __END__