line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.006; use strict; use warnings; our $VERSION = '0.02'; |
3
|
2
|
|
|
2
|
|
1719241
|
|
|
2
|
|
|
2
|
|
13
|
|
|
2
|
|
|
2
|
|
11
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
44
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
116
|
|
4
|
|
|
|
|
|
|
use HTML::SocialMeta; |
5
|
2
|
|
|
2
|
|
939
|
|
|
2
|
|
|
|
|
504301
|
|
|
2
|
|
|
|
|
544
|
|
6
|
|
|
|
|
|
|
my $self = shift; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
0
|
29027
|
my $c = $self->next::method(@_); |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
|
|
23
|
my $config = $c->config->{'Plugin::SocialMeta'}; |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
|
|
21104
|
return $c unless $config; |
13
|
|
|
|
|
|
|
|
14
|
2
|
50
|
|
|
|
225
|
$c->socialmeta(); |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
|
|
13
|
return $c; |
17
|
|
|
|
|
|
|
} |
18
|
2
|
|
|
|
|
13
|
|
19
|
|
|
|
|
|
|
my ($c, %data) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $return = delete $data{return}; |
22
|
3
|
|
|
3
|
1
|
3216
|
|
23
|
|
|
|
|
|
|
my $config = $c->config->{'Plugin::SocialMeta'} || {}; |
24
|
3
|
|
|
|
|
14
|
%data = (%{$config}, %data); |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
50
|
|
|
17
|
my $provider = defined $data{meta_provider} |
27
|
3
|
|
|
|
|
291
|
? delete $data{meta_provider} |
|
3
|
|
|
|
|
53
|
|
28
|
|
|
|
|
|
|
: 'all'; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $card_type = defined $data{card_type} |
31
|
3
|
50
|
|
|
|
19
|
? delete $data{card_type} |
32
|
|
|
|
|
|
|
: 'summary'; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $social_meta = HTML::SocialMeta->new(\%data); |
35
|
3
|
50
|
|
|
|
46
|
|
36
|
|
|
|
|
|
|
my $tags; |
37
|
3
|
|
|
|
|
73
|
if ($provider eq 'all') { |
38
|
|
|
|
|
|
|
$tags = $social_meta->create($card_type); |
39
|
3
|
|
|
|
|
15894
|
} else { |
40
|
3
|
50
|
|
|
|
16
|
$tags = $social_meta->$provider->create($card_type); |
41
|
3
|
|
|
|
|
65
|
} |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
0
|
if ($return) { |
44
|
|
|
|
|
|
|
return $tags; |
45
|
|
|
|
|
|
|
} |
46
|
3
|
50
|
|
|
|
64440
|
|
47
|
0
|
|
|
|
|
0
|
$c->stash(socialmeta => $tags); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
return 1; |
50
|
3
|
|
|
|
|
40
|
} |
51
|
|
|
|
|
|
|
|
52
|
3
|
|
|
|
|
480
|
1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 NAME |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Catalyst::Plugin::SocialMeta - Generate social media meta tags for your catalyst application. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 VERSION |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Version 0.02 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 SYNOPSIS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Quick summary of what the module does. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Perhaps a little code snippet. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
... MyApp.pm ... |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
package MyApp; |
74
|
|
|
|
|
|
|
use Moose; |
75
|
|
|
|
|
|
|
use namespace::autoclean; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
use Catalyst::Runtime 5.80; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
use Catalyst qw/ |
80
|
|
|
|
|
|
|
SocialMeta |
81
|
|
|
|
|
|
|
/; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
extends 'Catalyst'; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
__PACKAGE__->config( |
88
|
|
|
|
|
|
|
name => 'MyApp', |
89
|
|
|
|
|
|
|
'Plugin::SocialMeta' => { |
90
|
|
|
|
|
|
|
meta_provider => 'all', |
91
|
|
|
|
|
|
|
card_type => 'featured_image', |
92
|
|
|
|
|
|
|
site => 'Lnation.org', |
93
|
|
|
|
|
|
|
site_name => 'Lnation', |
94
|
|
|
|
|
|
|
title => 'Social Meta Tag Generator', |
95
|
|
|
|
|
|
|
description => 'Demo UI for HTML::SocialMeta', |
96
|
|
|
|
|
|
|
image => 'https://lnation.org/static/images/social.png', |
97
|
|
|
|
|
|
|
fb_app_id => 'lnationorgnofb', |
98
|
|
|
|
|
|
|
url => 'https://lnation.org/socialmeta/demo' |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# Start the application |
103
|
|
|
|
|
|
|
__PACKAGE__->setup(); |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
.... Controller ... |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
package MyApp::Controller::Foo; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
use Moose; |
110
|
|
|
|
|
|
|
use namespace::autoclean; |
111
|
|
|
|
|
|
|
BEGIN { |
112
|
|
|
|
|
|
|
extends 'Catalyst::Controller'; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub foo :Chained('/') :PathPart('foo') :Args(0) { |
116
|
|
|
|
|
|
|
my ($self, $c) = @_; |
117
|
|
|
|
|
|
|
... # uses default social meta tags from config |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub base :Chained('/') :PathPart('') :CaptureArgs(0) { |
121
|
|
|
|
|
|
|
my ($self, $c) = @_; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
$c->socialmeta( |
124
|
|
|
|
|
|
|
title => 'Changed Title', |
125
|
|
|
|
|
|
|
description => 'Demo UI for Changed::Title', |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub bar :Chained('base') :PathPart('bar') :Args(0) { |
130
|
|
|
|
|
|
|
my ($self, $c) = @_; |
131
|
|
|
|
|
|
|
... # social meta tags from the config + the keys set in the base action |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
` ... wrapper.tt ... |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
<html> |
137
|
|
|
|
|
|
|
<head> |
138
|
|
|
|
|
|
|
[% socialmeta %] |
139
|
|
|
|
|
|
|
</head> |
140
|
|
|
|
|
|
|
<body> |
141
|
|
|
|
|
|
|
... |
142
|
|
|
|
|
|
|
</body> |
143
|
|
|
|
|
|
|
</html> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 socialmeta |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Set the social meta tags for the current action, you can pass the following keys, see L<HTML::SocialMeta> for more information. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item meta_provider |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
The meta provider you would like to generate the social meta tags for, this defaults to 'all'. twitter and opengraph are the other valid options. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item card_type |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The type of social meta card see L<HTML::SocialMeta> documention for options. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item card |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
OPTIONAL - if you always want the same card type you can set it |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item site |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
The Twitter @username the card should be attributed to. Required for Twitter Card analytics. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item site_name |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This is Used by Facebook, you can just set it as your organisations name. |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item title |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
The title of your content as it should appear in the card |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item description |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
A description of the content in a maximum of 200 characters |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item image |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
A URL to a unique image representing the content of the page |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item image_alt |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
OPTIONAL - A text description of the image, for use by vision-impaired users |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item url |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Required for OpenGraph. Allows you to specify an alternative url link you want the reader to be redirected |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item player |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
HTTPS URL to iframe player. This must be a HTTPS URL which does not generate active mixed content warnings in a web browser |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item player_width |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Width of IFRAME specified in twitter:player in pixels |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=item player_height |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Height of IFRAME specified in twitter:player in pixels |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item operating_system |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
IOS or Android |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item app_country |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
UK/US ect |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item app_name |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
The applications name |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item app_id |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
String value, and should be the numeric representation of your app ID in the App Store (.i.e. 307234931) |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item app_url |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Application store url - direct link to App store page |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item fb_app_id |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
This field is required to use social meta with facebook, you must register your website/app/company with facebook. |
228
|
|
|
|
|
|
|
They will then provide you with a unique app_id. |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=back |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=cut |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 AUTHOR |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
LNATION, C<< <email at lnation.org> >> |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=head1 BUGS |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-catalyst-plugin-socialmeta at rt.cpan.org>, or through |
241
|
|
|
|
|
|
|
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Catalyst-Plugin-SocialMeta>. I will be notified, and then you'll |
242
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head1 SUPPORT |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
perldoc Catalyst::Plugin::SocialMeta |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
You can also look for information at: |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=over 4 |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Catalyst-Plugin-SocialMeta> |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item * CPAN Ratings |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
L<https://cpanratings.perl.org/d/Catalyst-Plugin-SocialMeta> |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=item * Search CPAN |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
L<https://metacpan.org/release/Catalyst-Plugin-SocialMeta> |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=back |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
This software is Copyright (c) 2022 by LNATION. |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
This is free software, licensed under: |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
1; # End of Catalyst::Plugin::SocialMeta |