line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MojoMojo::Formatter::GoogleCalendar; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#use strict; |
4
|
26
|
|
|
26
|
|
17296
|
use parent 'MojoMojo::Formatter'; |
|
26
|
|
|
|
|
71
|
|
|
26
|
|
|
|
|
178
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#my $dependencies_installed = !$@; |
7
|
|
|
|
|
|
|
#sub module_loaded { $dependencies_installed } |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
MojoMojo::Formatter::GoogleCalendar - Embed Google Calendar |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Embed Goodle Calendar in wiki page {{gcal <url> <width>,<height> <alignment>}}. |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 METHODS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 format_content_order |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Format order can be 1-99. The Google Calendar formatter runs on 20. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
620
|
|
|
620
|
1
|
1460
|
sub format_content_order { 20 } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 format_content |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Calls the formatter. Takes a ref to the content as well as the |
32
|
|
|
|
|
|
|
context object. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub format_content { |
37
|
124
|
|
|
124
|
1
|
1125
|
my ( $class, $content, $c ) = @_; |
38
|
124
|
|
|
|
|
318
|
my ( $width, $height, $align ); |
39
|
124
|
|
|
|
|
276
|
my $default_width = 600; |
40
|
124
|
|
|
|
|
246
|
my $default_height = 400; |
41
|
124
|
|
|
|
|
307
|
my $default_alignment = 'center'; |
42
|
124
|
|
|
|
|
729
|
my %alignment_style = ( |
43
|
|
|
|
|
|
|
'center' => 'margin:auto;width:70%', |
44
|
|
|
|
|
|
|
'right' => 'float:right;width:70%', |
45
|
|
|
|
|
|
|
'left' => 'float:left;width:70%' |
46
|
|
|
|
|
|
|
); |
47
|
124
|
|
|
|
|
665
|
my @lines = split /\n/, $$content; |
48
|
124
|
|
|
|
|
847
|
my $re = $class->gen_re(qr/gcal\s+(.*?)\s+(\d+),(\d+)\s+(\w+)/); |
49
|
124
|
|
|
|
|
471
|
$$content = ""; |
50
|
|
|
|
|
|
|
|
51
|
124
|
|
|
|
|
374
|
foreach my $line (@lines) { |
52
|
730
|
50
|
|
|
|
2425
|
if ( $line =~ m/$re/ ) { |
53
|
0
|
0
|
|
|
|
0
|
!defined($2) ? $height = $default_height : $height = $2; |
54
|
0
|
0
|
|
|
|
0
|
!defined($3) ? $width = $default_width : $width = $3; |
55
|
|
|
|
|
|
|
!defined($4) |
56
|
|
|
|
|
|
|
? $align = $alignment_style{$default_alignment} |
57
|
0
|
0
|
|
|
|
0
|
: $align = $alignment_style{$4}; |
58
|
0
|
|
|
|
|
0
|
$line = |
59
|
|
|
|
|
|
|
"<div style='$align;border:1'><iframe src='$1' height='$height' width='$width' style='border-width:0; margin-left:auto; margin-right:auto' frameborder='0' scrolling='no'></iframe></div>"; |
60
|
|
|
|
|
|
|
} |
61
|
730
|
|
|
|
|
1655
|
$$content .= $line . "\n"; |
62
|
|
|
|
|
|
|
} |
63
|
124
|
|
|
|
|
559
|
return $content; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SEE ALSO |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
L<MojoMojo>, L<Module::Pluggable::Ordered>, L<URI::Fetch> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHORS |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Jurnell Cockhren <jurnell.cockhren@vanderbilt.edu> |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 LICENSE |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify |
78
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |