#!/usr/bin/perl
# rem2html
#
# 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.
#
# [Note from David: The REMIND license prohibits you from using REMIND
# under Windows.]
#
# Rem2html puts "normal" CAL or MSG-type reminders in a pair,
# and escapes any special HTML characters.
#
# If you want to put actual HTML code in the calendar (hyper-links, for
# example), use the "SPECIAL HTML" type. For example:
#
# REM Wed SPECIAL HTML Meeting at \
# Linux HQ
#
# This file is Copyright (C) 1997-8 by Don Schwarz
# and David F. Skoll
#
# v1.2-beta, Hal Burgiss 03/03/05
#
# Changelog:
#
# - Fixed some mark-up mishaps for calendars with multiple months.
# - Added provision for a default CSS stylesheet (remind.css), and various
# related mark-up additions.
# - Added a 'nomini' option for eliminating the 'small calendar' thumbnails.
# - Added a 'title' option for HTML page title.
# - Added a 'print' option for nicer print look.
# - Added a 'months' option to control the size of the calendar.
# - Added a 'dtd' option to allow control of the document DTD.
# - Added some minor mark-up changes/improvements, eg xhtml compliant.
# - Added capability to grok remind data from within rem2html, looking for
# cgi type output, with -x option.
#
# A work in progress at this point.
#
#
########################################################################
use Getopt::Long;
@months = (January,February,March,April,May,June,July,August,September,October,November,December);
$def_width = '14%';
$DefaultImageDir = "%IMAGEBASE%";
$DefaultImageDir = "/images";
if ($DefaultImageDir =~ m@/$@) {
chop $DefaultImageDir;
}
$rem2html_version = "1.2-beta";
&parse_options();
# Backgound color -- unfortunately, most Web browsers (as of 14 October 1999)
# do not correctly handle transparency in PNG images, so I had to make the
# moon image background white.
$Options{'bgcolor'} ||= "bgcolor=\"#FFFFFF\"";
# if (-t STDIN) {
# print STDERR "(Rem2HTML: Input should not come from a terminal.)\n";
# $Options{'help'} = 1;
# }
if ($Options{'help'}) {
&show_usage();
} elsif ($Options{'version'}) {
print "Rem2HTML Version $rem2html_version.\n";
} else {
$successes = 0;
$today = &today();
$num = ($Options{'months'}) ? $Options{'months'} : 3;
# get the data from remind here.
$Options{'x'} && open STDIN, "$Options{'x'} |" || die "Unable to open todo file
";
if (-t STDIN) {
print STDERR "(Rem2HTML: Input should not come from a terminal.)\n";
&show_usage();
} else {
while(1) {
last if (!parse_input());
$successes++;
&output_header();
&output_data();
&output_footer();
}
print STDERR "Rem2HTML: Couldn't find any calendar data.\n" if (!$successes);
unless ($Options{'tableonly'}) {
print <