]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/googlecalendar.pm
releasing version 2.72
[ikiwiki.git] / IkiWiki / Plugin / googlecalendar.pm
index dc0df0ad3ff6d523571366b651a8f171e3799698..24c2e1527599f508d33190c0fc6a2ba0680f8ae1 100644 (file)
@@ -3,43 +3,55 @@ package IkiWiki::Plugin::googlecalendar;
 
 use warnings;
 use strict;
-use IkiWiki;
+use IkiWiki 2.00;
 
-sub import { #{{{
+print STDERR "warning: the googlecalendar plugin is deprecated and will be removed in ikiwiki 3.0 (use the embed plugin instead)\n";
+
+sub import {
+       hook(type => "getsetup", id => "googlecalendar",
+               call => \&getsetup);
        hook(type => "preprocess", id => "googlecalendar",
                call => \&preprocess);
        hook(type => "format", id => "googlecalendar",
                call => \&format);
-} # }}}
+}
+
+sub getsetup () {
+       return
+               plugin => {
+                       safe => 1,
+                       rebuild => undef,
+               },
+}
 
-sub preprocess (@) { #{{{
+sub preprocess (@) {
        my %params=@_;
 
        # Parse the html, looking for the url to embed for the calendar.
        # Avoid XSS attacks..
        my ($url)=$params{html}=~m#iframe\s+src="http://www\.google\.com/calendar/embed\?([^"<>]+)"#;
        if (! defined $url || ! length $url) {
-               return "[[googlecalendar failed to find url in html]]";
+               error gettext("failed to find url in html")
        }
        my ($height)=$params{html}=~m#height="(\d+)"#;
        my ($width)=$params{html}=~m#width="(\d+)"#;
 
        return "<div class=\"googlecalendar\" src=\"$url\" height=\"$height\" width=\"$width\"></div>";
-} # }}}
+}
 
-sub format (@) { #{{{
+sub format (@) {
         my %params=@_;
 
        $params{content}=~s/<div class=\"googlecalendar" src="([^"]+)" height="([^"]+)" width="([^"]+)"><\/div>/gencal($1,$2,$3)/eg;
 
         return $params{content};
-} # }}}
+}
 
-sub gencal ($$$) { #{{{
+sub gencal ($$$) {
        my $url=shift;
        my $height=shift;
        my $width=shift;
        return qq{<iframe src="http://www.google.com/calendar/embed?$url" style=" border-width:0 " width="$width" frameborder="0" height="$height"></iframe>};
-} #}}}
+}
 
 1