diff --git a/WHATSNEW.30 b/WHATSNEW.30 index 4671fcef..95d39038 100644 --- a/WHATSNEW.30 +++ b/WHATSNEW.30 @@ -2,16 +2,22 @@ CHANGES TO REMIND * Version 3.0 Patch 17 ++ MINOR ENHANCEMENTS + +- Added www/rem2html, a Perl script which converts the output of + `remind -p ...' to an HTML table. The script was contributed by + Don Schwarz + + BUG FIXES - Added romanian.h to the manifest. Sorry. -- CalcMinsFromUTC was failing if time_t was unsigned. I really _should_ - use difftime(), but not all systems have it. Also, defs.rem was rearranged +- CalcMinsFromUTC was failing if time_t was unsigned. I now use + difftime(), but not all systems have it. Also, defs.rem was rearranged so PostScript stuff works better, and new target "emxomf" was added to - makefile.ost which uses OMF linking and a dynamically-linked C library. - All three of these fixes are courtesy of Christopher J. Madsen - . Thanks, Christopher. + makefile.os2 which uses OMF linking and a dynamically-linked C + library. All three of these fixes are courtesy of Christopher + J. Madsen . Thanks, Christopher. * Version 3.0 Patch 16 diff --git a/main.c b/main.c index b320b747..0abfc9fb 100644 --- a/main.c +++ b/main.c @@ -11,7 +11,7 @@ /***************************************************************/ #include "config.h" -static char const RCSID[] = "$Id: main.c,v 1.6 1997-03-31 22:13:09 dfs Exp $"; +static char const RCSID[] = "$Id: main.c,v 1.7 1997-07-06 14:34:37 dfs Exp $"; #ifdef HAVE_STDLIB_H #include @@ -1260,11 +1260,18 @@ int jul, tim, *mins, *isdst; temp = localtime(&loc_t); /* Compute difference between local time and UTC in seconds. Be careful, since time_t might be unsigned. */ - tdiff = (loc_t < utc_t) ? -1*((int)(utc_t-loc_t)) : (loc_t-utc_t); #ifdef HAVE_MKTIME - /* Should use difftime */ + /* If we have mktime(), then we have difftime(), so use it! */ + tdiff = (int) difftime(loc_t, utc_t); if (mins) *mins = (int)(((temp->tm_isdst) ? 60 : 0) + tdiff / 60 ); #else + /* If we don't have mktime(), we probably don't have difftime(), + so use this rather non-portable code. */ + if (loc_t < utc_t) { + tdiff = - (int) (utc_t - loc_t); + } else { + tdiff = (int) (loc_t - utc_t); + } if (mins) *mins = (int)(tdiff / 60); #endif if (isdst) *isdst = temp->tm_isdst; diff --git a/www/README.rem2html b/www/README.rem2html new file mode 100644 index 00000000..24a76b43 --- /dev/null +++ b/www/README.rem2html @@ -0,0 +1,15 @@ +REM2HTML +$Id: README.rem2html,v 1.1 1997-07-06 14:34:41 dfs Exp $ + +Rem2HTML is a Perl script which transforms the output of +`remind -p ...' to an HTML table. Type `perl rem2html --help' for +usage information. + +Typical usage: remind -p ~/.reminders | rem2html > file.html + +Rem2HTML was contributed by Don Schwarz . It +produces HTML compatible with most modern browsers, but *not* with +browsers which don't support tables (like Lynx, as of this writing.) + +-- +David F. Skoll diff --git a/www/calendar.html-DIST b/www/calendar.html-DIST index fa0311b4..003281df 100644 --- a/www/calendar.html-DIST +++ b/www/calendar.html-DIST @@ -1,6 +1,6 @@ - + David Skoll's Calendar Server @@ -25,3 +25,4 @@ PostScript Calendar with Jewish Holidays (Approximately 35 kB)

Get the Remind software that provides this service.

+ diff --git a/www/rem2html b/www/rem2html new file mode 100755 index 00000000..3cfdc9f2 --- /dev/null +++ b/www/rem2html @@ -0,0 +1,298 @@ +#!/bin/perl + +# rem2html +# +# $Id: rem2html,v 1.1 1997-07-06 14:34:41 dfs Exp $ +# +# A script to convert from the output of "remind -p" to Hyper-Text Markup +# Language (HTML), the text format used in WWW documents. By default, it +# outputs a stand-alone file which can be fed directly into a web browser. +# The output uses nested blocks, so it will only work in a browser +# which supports tables (Netscape, MSIE, etc, NOT Lynx). +# +# This script works well on my computer (Linux 2.0.27) under Perl 5.003 and +# 5.004. It should work fine on other unices but I have no idea whether +# it will run under VMS, OS/2, Windows, etc. +# +# This file is Copyright (C) 1997 by Don Schwarz . + +use Getopt::Long; + +@months = (January,February,March,April,May,June,July,August,September,October,November,December); + +$rem2html_version = "1.0"; + +&parse_options(); + +if ($Options{'help'}) { + &show_usage(); +} elsif ($Options{'version'}) { + print "Rem2HTML Version $rem2html_version.\n"; +} else { + &parse_input(); + + &output_header(); + &output_data(); + &output_footer(); +} + +exit(0); + +sub show_usage { + print STDERR < +--forwurl url Same as --backurl, but with the next month's small calendar +--tableonly Output the results as a
block only, no , etc. +--border,-b size Set the border thickness of the table +--cellspace,-t size Set the line thickness of the table +--bgcolor,-g color Set the background color for the day entries + +EndOfUsage + +} + +sub parse_options { + %Options = (); + + GetOptions (\%Options, "help|h", + "version", + "border|b=i", + "cellspace|t=i", + "backurl|bu:s", "forwurl|fu:s", + "tableonly|to", + "prologue|p=s", + "bgcolor|g=s", + "fs=s", "fh=s", "ft=s", "fe=s", "fd=s", + "sh=i", "st=i", "se=i", "sd=i", + ); + + $Options{'border'} = "BORDER=" . ($Options{'border'} || 1); + $Options{'cellspace'} &&= "CELLSPACING=$Options{'cellspace'}"; + $Options{'bgcolor'} &&= "BGCOLOR=$Options{'bgcolor'}"; +} + +sub parse_input { + local $where = 0; + local $msg; + @days = (); + + while (<>) { + chomp($_); + if (/rem2(html|ps) begin/) { + } elsif (!$where) { + next; + } elsif ($where == 1) { + local ($month, $year); + ($month, $year, $month_length, $firstday, $mfirst) = split(" "); + $caption = "$month, $year"; + for $i ( 1 .. $month_length) { push(@days, ""); } + } elsif ($where == 2) { + @prevsc = split(" "); + } elsif ($where == 3) { + @nextsc = split(" "); + } else { + last if /rem2(html|ps) end/; + next unless m%^(\d*)/*(\d*)/*(\d*) ([^ ]*)?\s*(.*)$%; + $msg = $5; + $msg = "$4 $msg" if $4; + $days[$3] .= "

$msg

"; + } + $where++; + } + + die "Rem2HTML: Could not find any calendar data.\n", unless $where; +} + +sub output_header { + local ($title, $dayheader); + + if (!$Options{'tableonly'}) { + print < + Reminders for $caption + +EndOfHTML + } + + print <) and Remind (written by David F. Skoll). --> +EndOfHTML + + if ($Options{'prologue'}) { + open(PROLOGUE, "< $Options{'prologue'}"); + print while ( ); + close(PROLOGUE); + } + + $caption = &format_font($caption, $Options{'ft'}, $Options{'st'} || "+1"); + + print < + + +EndOfHTML + + $mfirst || &print_day_header("Sunday"); + + foreach $dayheader (Monday,Tuesday,Wednesday,Thursday,Friday,Saturday) { + &print_day_header($dayheader); + } + + $mfirst && &print_day_header("Sunday"); + print " \n"; +} + +sub output_footer { + print "
$caption
\n"; + + unless ($Options{'tableonly'}) { + print < + +EndOfHTML + } +} + +sub output_data { + local ($endday, $prevday, $nextday, $week, $weekday); + local ($element, $day, $msg, $fday); + $firstday -= $mfirst; + if ($firstday < 0) { $firstday += 7; } + $endday = $firstday + $month_length; + $endweek = $endday + (6 - ($endday % 7)); + $endday %= 7; + + if ( $firstday > 1 ) { + $prevday = 0; + $nextday = 1; + } elsif ($endday ? ($endday < 5) : !$firstday) { + $prevday = $endweek - 1; + $nextday = $endweek; + } else { + $prevday = 0; + $nextday = $endweek; + } + + for $week ( 0..5 ) { + print " \n"; + for $weekday ( 0..6 ) { + $element = ($week * 7) + ($weekday * 1); + $day = $element - $firstday + 1; + $msg = $days[$day]; + $msg = $msg ? &format_font($msg, $Options{'fe'}, $Options{'se'}) + : "



"; + + $fday = &format_font($day, $Options{'fd'}, $Options{'sd'} || -1); + if ($day > 0 && $day <= $month_length) { + + print < +

$fday

+ $msg + +EndOfHTML + + } elsif ($element == $prevday) { + &small_calendar(@prevsc, 1, $Options{'backurl'}); + } elsif ($element == $nextday) { + &small_calendar(@nextsc, 2, $Options{'forwurl'}); + } else { + print "
"; + } + } + print " \n"; + last if $day >= $month_length && $element >= $nextday; + } +} + +sub small_calendar { + local ($scname, $scn, $which, $url) = @_; + local ($scstart, $l, $week, $weekday, $tday); + + $scname = "$scname", if $url; + $scname = &format_font($scname, $Options{'fs'}, -2); + + if ($which == 1) { + $scstart = $firstday - ($scn % 7); + if ($scstart < 0) { $scstart += 7; } + } else { + $scstart = $firstday + ($month_length % 7); + if ($scstart > 6) { $scstart -= 7; } + } + + print < + + + +EndOfHTML + + $mfirst || &print_day_header("S", 1); + + foreach $l (M,T,W,T,F,S) { + &print_day_header($l, 1); + } + + $mfirst && &print_day_header("S", 1); + print "\n"; + + for $week ( 0..5 ) { + print " \n"; + for $weekday ( 0..6 ) { + $tday = ($week * 7) + ($weekday * 1) - $scstart + 1; + $tday = "", if $tday <= 0 || $tday > $scn; + print " \n"; + } + print " \n"; + last if $tday >= $scn; + } + + print < + +EndOfHTML + +} + +sub format_font { + local ($text, $font, $size) = @_; + + if (!$text) { + return ""; + } elsif ($font && $size) { + return "$text"; + } elsif ($font) { + return "$text"; + } elsif ($size) { + return "$text"; + } else { + return $text; + } +} + +sub print_day_header { + local ($dheader, $small) = @_; + + if ($small) { + $dheader = &format_font($dheader, $Options{'fs'}, -2); + } else { + $dheader = &format_font($dheader, $Options{'fh'}, $Options{'sh'}); + } + + print " \n"; +}
$scname
$tday
$dheader