| MojoMojo documentation | Contained in the MojoMojo distribution. |
MojoMojo::Formatter::GoogleCalendar - Embed Google Calendar
Embed Goodle Calendar in wiki page {{gcal <url> <width>,<height> <alignment>}}.
Format order can be 1-99. The Google Calendar formatter runs on 20.
Calls the formatter. Takes a ref to the content as well as the context object.
Jurnell Cockhren <jurnell.cockhren@vanderbilt.edu>
This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself.
| MojoMojo documentation | Contained in the MojoMojo distribution. |
package MojoMojo::Formatter::GoogleCalendar; #use strict; use parent 'MojoMojo::Formatter'; #my $dependencies_installed = !$@; #sub module_loaded { $dependencies_installed } our $VERSION = '0.1';
sub format_content_order { 20 }
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 = "<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>"; } $$content .= $line . "\n"; } return $content; }
1;