Copyright © 2011 , Kurt Nørmark |
(laml-style "simple-xhtml1.0-transitional-validating") (lib-load "xhtml1.0-convenience.scm")
(load (string-append laml-dir "tools/calendar/xml-in-laml/calendar.scm"))
The main function of the tool is calendar. The function week-calendar is also a top-level function. Besides these two functions, it is important to understand the input format of appointments in the calendar. Also, there are a number of constants, which affect the appearance of the calendar.
This tools requires input in terms of calendar events, which are assumed to be hold the the Scheme variabel calendar-events. In other words, you must define this variable to a value which represents a list of calendar event. Below, in section 1, we explain the calendar event format.
Besides the general LAML stuff (laml.scm) and the XHTML mirror libraries (mentioned above) this tools requires the libraries color.scm, time.scm and file-read.scm (all from directory lib in the LAML distribution). The required libraries are not loaded by the tool itself. Notice however, that the loading example given above also includes loading of color, time and file-read (because they are loaded by simple-xhtml1.0-transitional-validating).
The font size of the calendar entries is controlled by CSS. You can either link to a CSS file, or embed a CSS clause in the head of your HTML element. The following CSS clauses is an example:
(style 'type "text/css" "TABLE.calendar-table TD { font-size: 7pt; }")
A clause like this should be a constituent of the HTML head element.
Please take look at the calendar examples.
At www.cs.aau.dk we support a LAML web calendar service which will generate a calendar for you based on web input. You are welcome to try it out.
calendar | (calendar year from-month number-of-months [show-today? number-of-divisions]) | Return a HTML calendar for year, from-months, and running through number-of-months. |
calendar-background-color | calendar-background-color | The background color of the calendar. |
calendar-division-of-day | calendar-division-of-day | A list of second count intervals that divide a day and night (24 hours = 86400 seconds) into disjoint intervals. |
event-brief-text | (event-brief-text e) | Return the brief textual description of a calendar appointment. |
event-color | (event-color e) | Return the color of a calendar appointment. |
event-end-time | (event-end-time e) | Return the end time of a calendar appointment. |
event-long-text | (event-long-text e) | Return the long textual description of a calendar appointment. |
event-start-time | (event-start-time e) | Return the start time of a calendar appointment. |
event-url | (event-url e) | Return the url of a calendar appointment. |
month-width | month-width | The width of a month. |
week-calendar | (week-calendar t0 [number-of-divisions week-cal-column-width]) | Make a week calendar for the week that contains the time t0 (a second count). |
week-separator-of-calendar | week-separator-of-calendar | Week separators: Whether thin og thick (symbols). |
1 About the format of calendar input. | |||
The calendar input must be present in a variable named calendar-events. calendar-events must be defined externally to the calendar tool. calendar-events is a list of appointments. A single appointment is, in turn, a list. Thus calendar-events is a list of lists. The detailed format of an appointment is the following: (start-time end-time brief-description long-description color url)Start-time and end-time are integers (a number of seconds since january 1, 1970). The function time-encoding from the time library is useful for construction of these numbers. Brief-description is a string, the contents of which goes into the calendar. Long-description is a longer description of the event. The long description is supposed to contain the brief description as well. The long description is currently used as a popup title text of a calendar event presentation. In addition, the long description is shown instead of the brief description in a week calendar. Color is a RGB color. The color can be given in all formats accepted by the function rgb-color-encoding from the LAML color library. You can also use the color constants of the LAML color library. Finally, url is an URL, to which we link from the calendar entry. If it is the empty string, no link will be made. | |||
2 Event selection functions. | |||
The event selector functions define accessors into a calendar appointment. | |||
event-start-time | |||
Form | (event-start-time e) | ||
Description | Return the start time of a calendar appointment. A second count integer. | ||
See also | Scheme source file | event-start-time | |
event-end-time | |||
Form | (event-end-time e) | ||
Description | Return the end time of a calendar appointment. A second count integer. | ||
See also | Scheme source file | event-end-time | |
event-brief-text | |||
Form | (event-brief-text e) | ||
Description | Return the brief textual description of a calendar appointment. | ||
See also | Scheme source file | event-brief-text | |
event-long-text | |||
Form | (event-long-text e) | ||
Description | Return the long textual description of a calendar appointment. | ||
See also | Scheme source file | event-long-text | |
event-color | |||
Form | (event-color e) | ||
Description | Return the color of a calendar appointment. | ||
See also | Scheme source file | event-color | |
event-url | |||
Form | (event-url e) | ||
Description | Return the url of a calendar appointment. | ||
See also | Scheme source file | event-url | |
3 Calendar parameters. | |||
In this section we find a number of variables which control the calendar appearance. | |||
week-separator-of-calendar | |||
Form | week-separator-of-calendar | ||
Description | Week separators: Whether thin og thick (symbols). | ||
See also | Scheme source file | week-separator-of-calendar | |
month-width | |||
Form | month-width | ||
Description | The width of a month. Default value is 150. | ||
See also | Scheme source file | month-width | |
calendar-division-of-day | |||
Form | calendar-division-of-day | ||
Description | A list of second count intervals that divide a day and night (24 hours = 86400 seconds) into disjoint intervals. The list must at least contain one interval. There is no fixed upper limit of the number of intervals. Minimum second count is 0 and highest possible second count is seconds-in-a-day. It is allowed that the start second count of one interval is equal to the end of the second count of the previous interval. The intervals are not required to span all seconds of the 24 hours. The value of this variable is used to determine the meaning of the columns in a LAML calendar. The default value divides at noon. Example of a legal value (the default value, in fact): '((0 43200) (43200 86399)) | ||
See also | Scheme source file | calendar-division-of-day | |
calendar-background-color | |||
Form | calendar-background-color | ||
Description | The background color of the calendar. A color can be constructed by use of the function make-color from the LAML color library. The default background color is white. | ||
See also | Scheme source file | calendar-background-color | |
4 The main calendar function. | |||
In this section we find the most important function at all, the calendar function which generates a calendar. | |||
calendar | |||
Form | (calendar year from-month number-of-months [show-today? number-of-divisions]) | ||
Description | Return a HTML calendar for year, from-months, and running through number-of-months. This is the main function of the tool. Thus, the LAML calendar tool IS this function. As an example, (calendar 1999 2 3) will produce a calendar of February, March, and April in 1999. If the optional parameter show-today is #t, the current date is shown in red. | ||
Precondition | The variable calendar-events must be defined prior to the call of this function. number-of-divisions = (length calendar-division-of-day). | ||
Parameters | year | The year of the calendar. An integer. Example 2005. | |
from-month | The first month of the calendar. An integer from 1 to 12. | ||
number-of-months | The number of months in this calendar. A non-negative integer. | ||
show-today? | If true, mark the calendar generation day of with a red color. Defaults to #f. | ||
number-of-divisions | The number of columns (besides the fixed weekday and day columns) in this calendar. Defaults to 2. | ||
See also | Scheme source file | calendar | |
calendar events | SECTION1 | ||
week-calendar | |||
Form | (week-calendar t0 [number-of-divisions week-cal-column-width]) | ||
Description | Make a week calendar for the week that contains the time t0 (a second count). The week calendar has number-of-divisions columns (besides the fixed weekday and day columns), relative to the value of the variable calendar-division-of-day. | ||
Parameters | t0 | A time (a second-count) contained in the desired week. | |
number-of-divisions | The number of columns (besides the fixed weekday and day columns) of this week calendar. Defaults to 2. | ||
week-cal-column-width | The pixel width of columns in the week calendar. Defaults to 200. | ||
See also | Scheme source file | week-calendar | |