2 package IkiWiki::Plugin::googlecalendar;
9 hook(type => "preprocess", id => "googlecalendar",
10 call => \&preprocess);
11 hook(type => "format", id => "googlecalendar",
15 sub preprocess (@) { #{{{
18 # Parse the html, looking for the url to embed for the calendar.
20 my ($url)=$params{html}=~m#iframe\s+src="http://www\.google\.com/calendar/embed\?([^"<>]+)"#;
21 if (! defined $url || ! length $url) {
22 error gettext("failed to find url in html")
24 my ($height)=$params{html}=~m#height="(\d+)"#;
25 my ($width)=$params{html}=~m#width="(\d+)"#;
27 return "<div class=\"googlecalendar\" src=\"$url\" height=\"$height\" width=\"$width\"></div>";
33 $params{content}=~s/<div class=\"googlecalendar" src="([^"]+)" height="([^"]+)" width="([^"]+)"><\/div>/gencal($1,$2,$3)/eg;
35 return $params{content};
38 sub gencal ($$$) { #{{{
42 return qq{<iframe src="http://www.google.com/calendar/embed?$url" style=" border-width:0 " width="$width" frameborder="0" height="$height"></iframe>};