package MojoMojo::Formatter::GoogleCalendar; #use strict; use parent 'MojoMojo::Formatter'; #my $dependencies_installed = !$@; #sub module_loaded { $dependencies_installed } our $VERSION = '0.1'; =head1 NAME MojoMojo::Formatter::GoogleCalendar - Embed Google Calendar =head1 DESCRIPTION Embed Goodle Calendar in wiki page {{gcal , }}. =head1 METHODS =head2 format_content_order Format order can be 1-99. The Google Calendar formatter runs on 20. =cut sub format_content_order { 20 } =head2 format_content Calls the formatter. Takes a ref to the content as well as the context object. =cut sub format_content { my ( $class, $content, $c ) = @_; my ( $width, $height, $align ); my $default_width = 600; my $default_height = 400; my $default_alignment = 'center'; my %alignment_style = ( 'center' => 'margin:auto;width:70%', 'right' => 'float:right;width:70%', 'left' => 'float:left;width:70%' ); my @lines = split /\n/, $$content; my $re = $class->gen_re(qr/gcal\s+(.*?)\s+(\d+),(\d+)\s+(\w+)/); $$content = ""; foreach my $line (@lines) { if ( $line =~ m/$re/ ) { !defined($2) ? $height = $default_height : $height = $2; !defined($3) ? $width = $default_width : $width = $3; !defined($4) ? $align = $alignment_style{$default_alignment} : $align = $alignment_style{$4}; $line = "
"; } $$content .= $line . "\n"; } return $content; } =head1 SEE ALSO L, L, L =head1 AUTHORS Jurnell Cockhren =head1 LICENSE This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself. =cut 1;