#!/usr/bin/perl # # output Paul's "remind" calendar for current month (or specified month) # use CGI; use Date::Manip; @monthlist = qw(January February March April May June July August September October November December); $today = ParseDate("today"); $this_year = UnixDate( $today, "%Y" ); @yearlist = ( $this_year - 1 ) .. ( $this_year + 3 ); $remind_file = '/home/pas/.reminders'; $q = new CGI; $myself = $q->url; # # if month/year parameters are supplied, and and produce # a date parseable by ParseDate, # then use them, otherwise use today # $disp_date = ParseDate( $q->param('month') . ' ' . $q->param('year') ) || $today; $disp_month = UnixDate( $disp_date, "%B" ); $disp_year = UnixDate( $disp_date, "%Y" ); $rem_cmd = '/usr/bin/remind -p ' . $remind_file . ' ' . $disp_month . ' ' . $disp_year; # # calculate previous and next month dates, and the respective URLs # $forw_delta = ParseDateDelta("+1m"); $back_delta = ParseDateDelta("-1m"); $forw_date = DateCalc( $disp_date, $forw_delta ); $back_date = DateCalc( $disp_date, $back_delta ); $backurl = quotemeta $myself . '?year=' . UnixDate( $back_date, "%Y" ) . '&month=' . UnixDate( $back_date, "%B" ); $forwurl = quotemeta $myself . '?year=' . UnixDate( $forw_date, "%Y" ) . '&month=' . UnixDate( $forw_date, "%B" ); # # ... which are used as parameters to the rem2html script # $html_cmd = '/usr/bin/perl /usr/share/doc/remind-03.01.02/www/rem2html --backurl ' . $backurl . ' --forwurl ' . $forwurl . ' --tableonly'; # # we're ready to go, produce the page # print $q->header(), $q->start_html( -title => "Remind", -style => { -src => 'http://okoboji.unh.edu/remind.css' }, ), $q->h1("Reminders"), $q->hr, $q->start_form, "Month: ", $q->popup_menu( -name => 'month', -values => \@monthlist, -default => $disp_month ), "Year: ", $q->popup_menu( -name => 'year', -values => \@yearlist, -default => $disp_year ), $q->submit( -value => 'Go' ), $q->end_form, $q->hr; system("$rem_cmd | $html_cmd"); print $q->hr, $q->end_html;