2 package IkiWiki::Plugin::googlecalendar;
10 hook(type => "preprocess", id => "googlecalendar",
11 call => \&preprocess);
12 hook(type => "format", id => "googlecalendar",
16 sub preprocess (@) { #{{{
19 # Parse the html, looking for the url to embed for the calendar.
21 my ($url)=$params{html}=~m#iframe\s+src="http://www\.google\.com/calendar/embed\?([^"<>]+)"#;
22 if (! defined $url || ! length $url) {
23 return "[[googlecalendar failed to find url in html]]";
25 my ($height)=$params{html}=~m#height="(\d+)"#;
26 my ($width)=$params{html}=~m#width="(\d+)"#;
28 return "<div class=\"googlecalendar\" src=\"$url\" height=\"$height\" width=\"$width\"></div>";
34 $params{content}=~s/<div class=\"googlecalendar" src="([^"]+)" height="([^"]+)" width="([^"]+)"><\/div>/gencal($1,$2,$3)/eg;
36 return $params{content};
39 sub gencal ($$$) { #{{{
43 return qq{<iframe src="http://www.google.com/calendar/embed?$url" style=" border-width:0 " width="$width" frameborder="0" height="$height"></iframe>};