NAME

HTML::Calendar::Simple - A simple html calendar

SYNOPSIS

use HTML::Calendar::Simple;

my $cal = HTML::Calendar::Simple->new; # This month, this year
   $cal = HTML::Calendar::Simple->new({ 'month' => $month }); # This year
   $cal = HTML::Calendar::Simple->new({ 'month' => $month, 
                                        'year'  => $year});

print $cal; # stringifies to something like the output of cal
print $cal->html;

$cal->daily_info({ 'day'      => $day,
                   'day_link' => $location,
                   $type1     => $info1,
                   $type2     => $info2,
                   'link'     => [$link, $tag],
});

DESCRIPTION

This is a simple module which will make an HTML representation of a given month. You can add links to individual days, or in fact, any sort of information you want.

Yes, the inspiration for this came out of me looking at HTML::CalendarMonthSimple, and thinking 'Hmmm. A bit too complicated for what I want. I know, I will write a simplified version.' So I did.

new

my $cal = HTML::Calendar::Simple->new;
my $cal = HTML::Calendar::Simple->new({ 'month' => $month });
my $cal = HTML::Calendar::Simple->new({ 'month' => $month, 
                                        'year'  => $year });

This will make a new HTML::Calendar::Simple object.

daily_info

$cal->daily_info({ 'day'      => $day,
                   'day_link' => $location, # puts an href on the day
                   $type1     => $info1,
                   $type2     => $info2,
                   'link'     => [$link, $tag],
});

This will record that fact that $info of $type happen(s|ed) on $day.

Now, if there is no method defined to cope with $type, then the information pased as $info will just be text printed in the cell of $day. So, if you want something special to happen to (say) a type of 'meeting', you would have to define a method called _meeting.

For example:

$cal->daily_info({ 'day'     => 12, 
                   'meeting' => 'Meet swm');

and somewhere else in this module...

sub _meeting {
  my $self = shift;
  return $self->_cgi->h1( shift );
}

So any day that had a meeting key in its hash would be displayed as an <h1>$info</h1>

Note: If you call daily_info again with the same day with the same type BUT with different info, then the old info will get clobbered.

There is already one method in here, and that is _link. So, you can do:

$cal->daily_info({ 'day'  => $day,
                   'link' => [$link, $tag],
});

Note that the key 'link' takes an array ref.

Also, if you don't pass valid uris as values of the keys 'link' and 'day_link', well, that is your out if they don't work!

html

my $html = $cal->html;

This will return an html string of the calendar month in question.

BUGS

None known

TODO

Oh....lots of things.

o Allow for the setting of borders etc like HTML::CalendarMonthSimple.
o Format the output better if there is info in a daily cell.
o Perhaps overload '.' so you could add two calendars. Not sure.
o Check the links passed in are of format http://www.stray-toaster.co.uk
  or something.
o Get rid of the days and months hashes and replace with something better.
o And if all that happens, it may as well be HTML::CalendarMonthSimple!!

SHOWING YOUR APPRECIATION

There was a thread on london.pm mailing list about working in a vacumn - that it was a bit depressing to keep writing modules but never get any feedback. So, if you use and like this module then please send me an email and make my day.

All it takes is a few little bytes.

(Leon wrote that, not me!)

AUTHOR

Stray Toaster <coder@stray-toaster.co.uk>

With Thanks

To swm <swm@swmcc.com> for some roadtesting!

COPYRIGHT

Copyright (C) 2002, mwk

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.