#!/usr/bin/perl -w # # web.calendar2 # # Generate a calendar. # # Generate a simple calendar. Get the information # from a calendar file. # # This generates a single web page with the calendar # between the given dates specified. # # Usage: # web.calendar2 [flags] >calendar.html # Flags: # --data datafile # This is the name of the calendar data file. It contains # which are of the form: # # Comment line # Year=1999 Introduces a new year # Month=10 Introduces a new month # 1=event Some event on the specified day. # TBA=event Some event at an unknown date within the month. # The event calendar must be in order. If not specified, the # event calendar's filename is assumed to be "calendar.data". # The events may contain HTML, but keep it simple. # --start 1998/10 # This specifies the starting month. This must be in the # format shown. If unspecified, it starts as early as possible. # --end 1999/05 # This specifies the ending month. If unspecified, the calendar # goes as long as possible. # --bg color # This specifies the background color. This can be anything # that HTML allows. This defaults to no specific color. # --title "some title" # This specifies the title of the calendar. # --banner "some message" # This is the header text of the calendar. # # This program is in the public domain. Do what you want with it. # Don't ask too many questions. # # The official source is in on my home computer. A copy which # should be up to date is at: # http://cornvalley.peak.org/web.calendar/ # # Dave Regan # regan@ao.com # 7 Feb 1999 # use strict; use Getopt::Long; use vars qw(%Activities $EndMonth $EndYear @MonTabShort %Params $StartMonth $StartYear $Version); $StartYear = 1000; $StartMonth = 1; $EndYear = 9999; $EndMonth = 12; $Version = 'web.calendar2 v0.11 regan@ao.com'; %Params = ( "data" => "calendar.data", "start" => "0000/01", "end" => "9999/12", "bg" => "", "title" => "Calendar", "banner" => "Calendar", ); @MonTabShort = ( "", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); ### ### Main program ### my($cal, $day, $disp, $key, $lastmon, $mon, $thismon, $year); # Crack the parameters GetOptions(\%Params, "data=s", "start=s", "end=s", "bg=s", "title=s", "banner=s"); # Split the years and month ($StartYear, $StartMonth) = split(/[\D]/, $Params{'start'}); ($EndYear, $EndMonth) = split(/[\D]/, $Params{'end'}); # chdir($ENV{'HOME'}); ReadCalendar($Params{'data'}); $Params{'bg'} = qq|bgcolor="$Params{'bg'}"| if ($Params{'bg'} ne ""); print << " EOF";
| $MonTabShort[$mon] $disp | $Activities{$year, $mon, $day} | \n"; if ($mon != $lastmon) { $cal = `cal $mon $year`; $lastmon = $mon; # Put out a new table for the month print "$cal | ";
}
}
print "