utilities.tcl
file
from http://photo.net/wtr/thebook/utilities.txt. This package relies upon the presence
of ad_proc
to give us Common Lisp-style keyword args.
When formatting hyperlinks from day numbers, Julian dates are used. A Julian
date is the number of days since 4712 B.C. The benefit of using Julian dates
is that they make it very easy to do calendar date calculations. To make it
easy to convert back to ANSI dates, the helper procedure
calendar_convert_julian_to_ansi
is provided. To obtain a
Julian date from Oracle, use to_char
with a the 'J' format
option. For example, to obtain today's Julian date:
select to_char(sysdate, 'J') from dual
All of the color parameters are standard HTML colors. You can specify either recognized color names, or you can use the more specific hex color values. The names "white" and "black" are used in the code as defaults. However, you could use "#ffffff" or "#000000", respectively, if you prefer.
calendar_basic_month
This is the basis of all of the other calendar types. Use this if you want to produce a large calendar with daily details.
calendar_small_month
Creates small, detail-free calendars. It might be useful in date-selection situations, or for general overview calendars. This is used as the basis for all of the other small-calendar procedures.
calendar_prev_current_next
Creates a three-wide table of small calendars. The left calendar is the month prior to the passed-in date, the middle calendar is the month of the supplied date, and the right calendar is the month following the passed in date.
calendar_small_year
Forms a twelve-calendar display of twelve months, beginning the first of the passed-in month.
calendar_small_calendar_year
Forms a twelve-calendar display of the calendar year of the passed in month.
calendar_details
This is anns_set
that holds the daily details for the calendar. Each key is the Julian date of the day, and the values are strings representing the details.You can add multiple values for each Julian date key. When the calendar is rendered, it will fetch the values for all entries matching the appropriate Julian date.
Default: no data
date
A truncated ANSI format ('YYYY-MM-DD'), used to represent the desired reference date for each procedure. It's actual use may vary by procedure.Default: current database date (fetched via sysdate)
days_of_week
A list specifying the day-of-week headings in the calendar. This needs to always start on Sunday.Defaults:
calendar_basic_month
: "Sunday Monday Tuesday Wednesay Thursday Friday Saturday"- All small calendars: "S M T W T F S"
large_calendar_p
Specifies if this is a large (with daily details) or a small (no daily details) calendar.Defaults:
calendar_basic_month
: 1- All small calendars: 0
master_bgcolor
The background color of the entire calendar.Default: "black"
header_bgcolor
The background color of the master header (the month section of the calendar.)Default: "black"
header_text_color
The text color for the master header (the text used to display the month.)Default: "white"
header_text_size
The size of the month/year header, as passed to the "size" parameter of an HTML font tag.Defaults:
calendar_basic_month
: "+2"- All small calendars: "+1"
day_number_template
This template allows formatting or linking from the day number displayed on the calendar. Using the Tclsubst
command, two variables are substituted in the template. The first is the Julian date of the appropriate day. The second is the day of the month.For example, a
day_number_template
to show a relatively plain, unlinked day number might look like:Here is an example from the ACS /bboard system:
<!--$julian_date--><font size=1>$day_number</font>
<a href=\"threads-one-day.tcl?topic=[ns_urlencode $topic]&julian_date=\$julian_date\"><font size=-1>\$day_number</font></a>Default: "<!--%d--><font size=1>%d</font>"
day_header_size
The font size of the day header (the day of the week.)Default:
calendar_basic_month
: 2- All small calendars: 1
day_header_bgcolor
The background color of the day header row.Default: "#666666" (this is a dark gray)
calendar_width
The table width of calendar's master table. Alternatives can be specified either as a percentage of the page's width (e.g., -calendar_width "50%") or in absolute width (e.g., -calendar_width 100)Default:
calendar_basic_month
: "100%"- All small calendars: 0
day_bgcolor
The background color of each day cell.Default: "#DDDDDD" (this is a light gray)
day_text_color
The color of the days' details text.Default: "white"
empty_bgcolor
The background color to give empty cells (those before the first and after the last days of the month.)Default: "white"
next_month_template
Use this to specify the hyperlink format to do a next-month link at the bottom of a calendar. This will be processed byformat
, which will be inserting a string.For example, to link to a page called
month-show.tcl
which expects the variabledate
, you could use the following:This will insert a date in ANSI format (first day of next month, e.g., 1999-07-01 if you call it during display of a calendar for June 1999).
<a href="month-show.tcl?date=$ansi_date">Next month</a>Default: ""
prev_month_template
Seenext_month_template
.$ansi_date
will be last day of previous month, e.g., 1999-05-31 if you call it during display of a calendar for June 1999Default: ""
width
Used only bycalendar_small_year
andcalendar_small_calendar_year
Specifies the number of calendars-wide the displays are made.
Default: 2
month-show.tcl
.
Assuming the current month is June 1999, June 10, 1999 will show details.
June 10, 1999, is Julian date 2451340.
set calendar_details [ns_set create calendar_details]
set day_details "<font size=-1><b>Tasks</b><ul><li>shower<li>shave</ul><b>Appointments</b><br>- See the Prez</font>"
ns_set put $calendar_details "2451340" $day_details
set next_month_template "(<a href=\"month-show.tcl?date=\$calendar_details\">next</a>)"
set prev_month_template "(<a href=\"month-show.tcl?date=\$calendar_details\">prev</a>)"
ns_write "[calendar_basic_month -calendar_details $calendar_details -day_number_template $day_number_template -next_month_template $next_month_template -prev_month_template $prev_month_template]"
ns_write "[calendar_small_month -day_bgcolor "#00FFFF"]"
ns_write "[calendar_prev_current_next -days_of_week "D L M M J V S"]"
ns_write "[calendar_small_year]"
ns_write "[calendar_small_year -date "2000-04-01" -width 4 ]"