Jim Brandt (TPF Conference Chair) and I were talking about the Perl Community Calendar. Eventually we want to use the Google Calendar as a central data store to which anyone can add and update events, and then create various feeds from it (Jim or I can both add people to the calendar's editors if you want to add events. The trick is getting the data back out and figuring out what to include in which feed (for instance, maybe Lisbon.pm wants just the events in Portugal, but also the major events such as YAPC).
It's only a lack of free time that prevents me from getting right on this. If someone else wants to solve this, I could find some free subscriptions to TPR, even though the solution should work for any Google Calendar.
Here's the quick script I wrote just to see if I could get the data programmatically and what It would look like. I haven't investigated too deeply, but you see that Net::Google::Calendar's body method returns the data in a big string rather than in the separated form in which someone enters the separate parts.
This code is free for you to use anyway that you like, even if not for this problem:
#!/usr/bin/perl
use strict;
use Data::Dumper;
use Template;
use Net::Google::Calendar;
my $url = "http://www.google.com/calendar/feeds/ngctmrd1cac35061mrjt3hpgng%40group.calenda r.google.com/public/basic";
my $cal = Net::Google::Calendar->new( url => $url );
my @entries = ();
foreach my $event ( $cal->get_events )
{
my $hash = {};
$hash->{title} = $event->title;
my $body = $event->content->body;
print $body, "\n\n\n";
$body =~ s/ //g;
$hash->{description} = do { $body =~ s/(?:<br>\s*)*Event Description:\s+(.*)\s*//; $1 };
$hash->{status} = do { $body =~ s/(?:<br>\s*)*Event Status:\s+(.*)\s*//; $1 };
$hash->{where} = do { $body =~ s/(?:<br>\s*)*Where:\s+(.*)\s*//; $1 };
$hash->{when} = do { $body =~ s/When:\s+(.*)\s*//; $1 };
$hash->{when} =~ s/<br>Replaces.*//;
push @entries, $hash;
}
my $tt = Template->new();
my $template = <<"TT";
<?xml version="1.0" encoding="ISO-8859-1"?>
<rdf:RDF
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<channel rdf:about="http://use.perl.org/">
<title>The Perl Review: Community Events Calendar</title>
<link>http://www.theperlreview.com/community_calendar</link>
</channel>
[% FOREACH event IN entries %]
<item>
<title>[% event.title %]</title>
<link></link>
<description>[% event.description %]</description>
</item>
[% END %]
</rdf:RDF>
TT
$tt->process( \$template, { entries => \@entries } );
Confusion with $event-content-body (Score:1)
Once I got home and was able to test it out, my experience disagreed with those assumptions. In fact, I couldn't get much more than id(), title(), and content()->body() to work. The output of content()->body() though is much different then is implied above.
As I pointed out in a reply to you o
Re: (Score:2)
Ahhhh, I get it now (Score:1)
group.calendar.google.com/public/basic
vs
group.calendar.google.com/public/full
I focused on full which required me to figure out why Net::Google::Calendar is broken since not all the meta data is stuffed into body() in that view.
In any case, I hope the code I provided is useful.