Calendar Plugin
The CalendarPlugin handles the macro
%CALENDAR% that inserts a
monthly calendar in the page. Multiple topics can be specified as the source
of the events, and these can be in any web. The calendar marks dates
corresponding to the events. Events can be listed literally in the topics,
or can be taken from the results of macro expansions (such as %SEARCH).
NOTE since release 2.000, the plugin now respects access controls on
topics containing events. You must have VIEW permission on these topics to
be able to see the events they contain.
Also since 2.000, preferences settings
in this topic are no longer read.
Please define preferences as non-plugin preference settings instead.
Syntax Rules
You type |
you get |
%CALENDAR% |
a monthly calendar for the current month/year, with events taken from the current topic |
%CALENDAR{<attributes>}% |
is the full syntax |
Attributes recognized
Attribute |
Meaning |
Default |
year="yyyy" |
The year |
Current year |
year="+yy" or "-yy" |
Relative year |
Current year |
month="mm" |
The month |
Current month |
month="+mm" or "-mm" |
relative month |
Current month |
gmtoffset="+/-hh" |
Timezone expressed as number of hours offset from GMT |
Server timezone |
topic="TopicName" |
Topic containing events |
The topic containing the tag |
topic="Web.TopicName1, Web.TopicName2" |
Topics containing events |
The topics containing the events. You must have VIEW access to these topics, or the events therein will be ignored. |
web="Webname" |
Web containing the event topic |
The current web |
lang="language" |
Language: First few characters of "English", "Français", "Deutsch", "Español", "Português", "Nederlands", "Italiano", "Norsk", "Svenska", "Dansk", "suomi", "Magyar", "polski", "Romaneste" |
"English" |
daynames="Mon¦Tue¦..." |
Custom day names |
"Monday¦Tuesday¦Wednesday¦Thursday¦ Friday¦Saturday¦Sunday" |
header="..." |
Text at the top of the calendar; use $m for current month, $y for year |
Current month and year |
weekstartsonmonday="1" or "0" |
Flag to start week on Monday |
"0" (Sunday) |
showdatenumbers="0" |
Show day numbers 1...31 in date cells. Note that showdatenumbers=1 means that HTML::CalendarMonthSimple will add the date numbers to the cells. If showdatenumbers=0 , then the plugin adds the date numbers. The result of this is that a calendar will always show the date numbers. |
"0" (except with aslist="1", see below) |
showweekdayheaders="1" |
Show the weekday headers |
"0" |
weekdayheadersbig="0" |
If enabled, show weekday headers in bold cell headings |
"1" |
cellalignment="left" |
Horizontal cell alignment of day cells: "left", "center", "right", "justify", "char" |
"center" |
vcellalignment="middle" |
Vertical cell alignment of day cells: "top", "middle", "bottom", "baseline" |
"top" |
cellheight="n" |
Height in pixels of each cell in the calendar |
Minimum height needed |
format="..." |
How to highlight a date. NOTE make sure you use $old to denote the date output, otherwise you may only see one event per day. |
See Event Formatting below |
width="n" or "n%" |
Width of calendar table in pixels or percent |
Minimum width needed |
border="n" |
Border width of calendar table |
"1" |
nowrap="1" or "0" |
Prevent cell content from wrapping |
"0" |
bgcolor="#nnnn" |
Default background color of all cells unless redefined by other color settings below (use an HTML color-code like "#000000" as defined in StandardColors) |
white |
contentcolor="#nnnn" |
Default content color of all cells unless redefined |
black |
headercolor="#nnnn" |
Background color of the Month+Year header |
The web bgcolor |
headercontentcolor="#nnnn" |
Content color of the Month+Year header |
contentcolor setting |
weekdayheadercolor="#nnnn" |
Background color of weekdays' headers |
bgcolor setting |
weekdayheadercontentcolor= "#nnnn" |
Content color of weekdays' headers |
contentcolor setting |
weekendheadercolor="#nnnn" |
Background color of weekends' headers |
bgcolor setting |
weekendheadercontentcolor= "#nnnn" |
Content color of weekends' headers |
contentcolor setting |
weekdaycolor="#nnnn" |
Background color of weekday cells |
bgcolor setting |
weekdaycontentcolor="#nnnn" |
Content color of weekday cells |
contentcolor setting |
weekendcolor="#nnnn" |
Background of weekend cells |
light gray |
weekendcontentcolor="#nnnn" |
Content color of weekend cells |
contentcolor setting |
todaycolor="#nnnn" |
Background of today's cell |
The web bgcolor |
todaycontentcolor="#nnnn" |
Content color of today's cell |
contentcolor setting |
and other attributes of HTML::CalendarMonthSimple |
aslist |
Controls whether events displayed in calendar style (aslist=0 ) or list style (aslist=1 ). Note that specifying aslist=1 forces showdatenumbers=1 and defaults to show only one day's events (see day and days ). This is done to ensure that the date number is formatted according to datenumberformat and that only the days that have an event are listed. |
0 |
day |
Specifies the first day to show. Only valid if aslist=1 . |
1 |
days |
Specifies how many days of calendar data to list. Only valid if aslist=1 . |
1 |
months |
Specifies how many months of calendars to display. Only valid if aslist=0 . |
1 |
datenumberformat |
Specifies formatting for the date number in each cell. The formatting codes accepted are the same as those for the %GMTIME% variable. |
'$day' (if aslist=0 ) ' * $day $mon $year' (if aslist=1 ) |
todaydatenumberformat |
Specifies formatting for the date number for the current day (today) in the calendar. The formatting codes accepted are the same as those for the %GMTIME% variable. |
datenumberformat |
multidayformat |
Specifies formatting of the description for multi-day events. See Multi-Day Event Formatting for details. |
$description |
tableclass |
css class given to the outer table |
calendar $month $year |
cellclass |
css class given to each day's element |
day $day $month $year |
weekdaycellclass |
css class given to weekdays in the showweekdayheaders |
weekday |
weekendcellclass |
css class given to weekendin the showweekdayheaders |
weekend |
todaycellclass |
css class given to today's element (inaddition to cellclass ) |
today |
headerclass |
css class given to the header |
calendarHeader |
eventbgcolor |
Background color Event, when have a event in calendar |
for default is undef, you have to put some color |
Event Syntax
Events are defined by bullets with the following syntax:
Event type |
Syntax |
Example |
Single: |
* dd MMM yyyy - description |
09 Dec 2002 - Expo |
Interval: |
* dd MMM yyyy - dd MMM yyyy - description |
02 Feb 2002 - 04 Feb 2002 - Vacation |
Yearly: |
* dd MMM - description |
05 Jun - Every 5th of June |
* w DDD MMM - description |
2 Tue Mar - Every 2nd Tuesday of March |
* L DDD MMM - description |
L Mon May - The last Monday of May |
* A dd MMM yyyy - description |
A 20 Jul 1969 - First moon landing This style will mark anniversaries of an event that occurred on the given date. The description will have " (x)" appended to it, where "x" indicates how many years since the occurence of the first date. The first date is not annotated. |
Monthly: |
* w DDD - description |
1 Fri - Every 1st Friday of the month |
* L DDD - description |
L Mon - The last Monday of each month |
* dd - description |
14 - The 14th of every month |
Weekly: |
* E DDD - description |
E Wed - Every Wednesday |
* E DDD dd MMM yyyy - description |
E Wed 27 Jan 2005 - Every Wednesday Starting 27 Jan 2005 |
* E DDD dd MMM yyyy - dd MMM yyyy - description |
E Wed 1 Jan 2005 - 27 Jan 2005 - Every Wednesday from 1 Jan 2005 through 27 Jan 2005 (inclusive) |
Periodic: |
* En dd MMM yyyy - description |
E3 02 Dec 2002 - Every three days starting 02 Dec 2002 |
* En dd MMM yyyy - dd MMM yyyy - description |
E3 12 Apr 2005 - 31 Dec 2005 - Every three days from 12 Apr 2005 through 31 Dec 2005 (inclusive) |
Exception: |
Insert the following between the above syntax and the description: X { dd MMM yyyy, dd MMM yyyy - dd MMM yyyy } |
1 Fri X { 01 Dec 2002, 06 Dec 2002 - 14 Dec 2002 } - Every first Friday except on the 01 Dec 2002 and between 06 Dec 2002 and 14 Dec 2002 |
For a table-style calendar, each day which has one or more events will have a
list of the descriptions of those events. Each event description will be set
in a small font. In other words,
format
is:
$old<br /><small>$description</small>
For a list-style calendar, if an event falls in the selected time period, then
it is displayed (by default) as a bullet item with the date as dd Mmm yyyy In
other words,
datenumberformat
is:
* $day $mon $year
and
format
is:
$old - $description
This displays the events in a form very similar to that in which they are specified (although specific to a particular date).
The multidayformat option allows the description of each day of a
multiday event to be displayed differently. This could be used to
visually or textually annotate the description to indicate continuance
from or to other days.
The option consists of a comma separated list of formats for each
type of day in a multiday event:
first, middle, last, middle-unseen, last-unseen
Where:
- first is the format used when the first day of the event is displayed
- middle is the format used when the day being displayed is not the first or last day
- last is the format used when the last day of the event is displayed
- middle-unseen is the format used when the day being displayed is not the first or last day of the event, but the preceding days of the event have not been displayed. For example, if an event runs from 29 Apr to 2 May and a May calendar is being displayed, then this format would be used for 1 May.
- last-unseen is the format used when the day being displayed is the last day of the event, but the preceding days of the event have not been displayed. For example, if an event runs from 29 Apr to 1 May and a May calendar is being displayed, then this format would be used for 1 May. Note that in the previous example (event from 29 Apr to 2 May), this format would not be used for a May calendar because the event was "seen" on 1 May; so, the last format would be used for 2 May.
Within each format, date information for the current day can be
substituted using the same format codes as accepted by
%GMTIME%
. An extension to these codes allows the date of the
first and/or last day of the event to also be rendered.
-
$first(format)
will render the first date of the event according to format, where format is, again, a string of codes acceptable to %GMTIME%
.
-
$last(format)
will render the last date of the event in the way just described for $first()
Missing formats will be filled in as follows:
- middle will be set to first
- last will be set to middle
- middle-unseen will be set to middle
- last-unseen will be set to last
Missing formats are different from empty formats. For example,
multidayformat="$description (until $last($day $month)),,"
specifies an empty format for
middle and
last. The result of this
is that only the first day will be shown. Note that since an
unspecified
middle-unseen is set from the (empty)
middle format,
an event that begins prior to the calendar being displayed but ending
in the current calendar will not be displayed. In contrast,
multidayformat="$description" will simply display the description for
each day of the event; all days (within the scope of the calendar)
will be displayed.
The default format is to simply display the description of the event.
Other sources of calendars
You can also use the
Foswiki:Extensions.CalDAVPlugin to recover calendars from
a CalDAV server.
Examples
You type: | You get: | If correctly installed: |
A list of Events is just a bullet list like this:
- 2 Feb - Andrea's birthday
- A 7 Mar 1966 - Nicoletta's birthday
- 29 May 1996 - Maria Teresa is born!
- 29 Sep 1998 - Davide is born!
%CALENDAR{month="2" year="2002" bgcolor="cyan"}%
%CALENDAR{month="3" year="2002" showweekdayheaders="1"}%
|
February 2002 |
|
|
|
|
|
01 |
02 Andrea's birthday |
03 |
04 |
05 |
06 |
07 |
08 |
09 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
|
|
|
March 2002 |
Sunday |
Monday |
Tuesday |
Wednesday |
Thursday |
Friday |
Saturday |
|
|
|
|
|
01 |
02 |
03 |
04 |
05 |
06 |
07 Nicoletta's birthday (36) |
08 |
09 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
01 |
02 Andrea's birthday |
03 |
04 |
05 |
06 |
07 |
08 |
09 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
|
|
|
Sunday |
Monday |
Tuesday |
Wednesday |
Thursday |
Friday |
Saturday |
|
|
|
|
|
01 |
02 |
03 |
04 |
05 |
06 |
07 Nicoletta's birthday (36) |
08 |
09 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
|
|
|
|
|
|
|
|
Settings
Any of the recognized
CALENDAR{}
macro attributes can be defaulted using preferences. These
preferences all start with
CALENDARPLUGIN_
and end with the upper case name
of the attribute. For example, the following affect only Calendars on this topic:
-
- Set CALENDARPLUGIN_FORMAT = $old
$description
- Set CALENDARPLUGIN_CELLALIGNMENT = center
- Set CALENDARPLUGIN_GMTOFFSET = +10
- Set CALENDARPLUGIN_WEEKSTARTSONMONDAY = 0
Preferences can be set at the site, web, topic or user level. See
PreferenceSettings for more information.
Note: this is different from TWiki
CalendarPlugin for significant performance reasons, and because in foswiki, its prefferable not to modify topics in the System web.
Installation Instructions
You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server.
Open configure, and open the "Extensions" section. "Extensions Operation and Maintenance" Tab -> "Install, Update or Remove extensions" Tab. Click the "Search for Extensions" button.
Enter part of the extension name or description and press search. Select the desired extension(s) and click install. If an extension is already installed, it will
not show up in the
search results.
You can also install from the shell by running the extension installer as the web server user: (Be sure to run as the webserver user, not as root!)
cd /path/to/foswiki
perl tools/extension_installer <NameOfExtension> install
If you have any problems, or if the extension isn't available in
configure
, then you can still install manually from the command-line. See
https://foswiki.org/Support/ManuallyInstallingExtensions for more help.
You should see two calendars near the Event list above and a current month calendar below (using css style section inline):
01 |
02 |
03 |
04 |
05 |
06 |
07 |
08 |
09 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
|
|
|
|
|
Info
Change History: |
|
2.020 (18 Jul 2017): |
Foswiki:Tasks.Item14440: Restore expansion of macros for Calendar event topics. |
2.010 (1 Sep 2015): |
Foswiki:Tasks.Item2038: Preserve header colors across multiple months. Foswiki:Tasks.Item10135: Don't omit events outside of STARTINCLUDE/STOPINCLUDE blocks Foswiki:Tasks.Item11202: Modernize CalendarPlugin (phase 1) Update copyright, Eliminate Subversion macros, Remove high characters from plugin topic. Foswiki:Main.GeorgeClark |
2.001 (26 Oct 2011): |
Foswiki:Tasks.Item11202: created unit tests! rewrote the parse code to make it testable - Foswiki:Main.SvenDowideit |
2.000 (30 Jun 2010): |
Foswiki:Tasks.Item1841: Foswiki:Tasks.Item8421: Foswiki:Tasks.Item1546: added support for macro expansions to provide the event lists. This allows other plugins to generate data sources e.g. by including calendars from e.g. CalDAV. Restructured for maintenance and performance. Foswiki:Tasks.Item9231: Added topic permission checking. Crawford Currie http://c-dot.co.uk |
12 Aug 2009: |
Foswiki:Main.MarcelloBontempoSalgueiro: add eventbgcolor attribute for background color when day have a event |
09 March 2009: |
Foswiki:Main.SvenDowideit: add day attribute for aslist rendering so users can select a start day |
28 Feb 2009: |
Foswiki:Main.SvenDowideit: add css classes and parameters so that we're not so ugly anymore |
10 Feb 2009: |
Foswiki:Main.SvenDowideit: port to Foswiki |
1.020: |
TWiki:Main.DavidBright: Bug fix from TWiki:Main.MarcLangheinrich for multiday events that were not properly displayed because the first day occurred in the current month, but before the first day included in the list. |
1.019: |
TWiki:Main.DavidBright: Added support for monthly repeaters specified as "L Fri" (last Friday in all months). |
1.018: |
TWiki:Main.DavidBright: Added capability to display multiple months in one call, display events in a list, and provided for more extensive formatting of date and description of events. |
1.017: |
TWiki:Main.DanielRohde: Added start and end date support for periodic repeaters; Added initlang patch by TWiki:Main.JensKloecker; Changed 'my' to 'local' so exceptions working again; Removed fetchxmap debug message; Fixed illegal date bug; Allowed month abbreviations in month attribute |
1.016: |
TWiki:Main/DavidBright: Added support for anniversary events; changed "our" to "my" in module to support perl versions prior to 5.6.0 |
1.015: |
TWiki:Main.PatriceFournier: Added back support for preview showing unsaved events; Two loop fixes from TWiki:Main.DanielRohde |
1.014: |
TWiki:Main.NathanKerr: Added start and end date support for weekly repeaters |
1.013: |
TWiki:Main.MartinCleaver: Added multiple topic=web.topic parameters |
1.012: |
TWiki:Main/PeterThoeny: Added missing doc of gmtoffset parameter (was deleted in 1.011) |
1.011: |
TWiki:Main/PeterThoeny: Fixed deep recursion bug; preview shows now unsaved events; performance and resource improvements; documented most of HTML::CalendarMonthSimple attributes; TWiki:Main/PaulineCheung: Fixed uninitialized value in join |
1.010: |
TWiki:Main/DanBoitnott: Fixed variable conflict in timezone code |
1.009: |
TWiki:Main/DanBoitnott: Added ability to have event topics in other webs |
1.008: |
TWiki:Main/AnthonPang: Added daynames attribute; TWiki:Main/JensKloecker: Added lang attribute; TWiki:Main/DanBoitnott: Added yearly, monthly, weekly, and periodic events and exceptions |
1.006: |
TWiki:Main/DanBoitnott: Added monthly date support |
1.005: |
TWiki:Main/AkimDemaille: handle date intervals (thanks!) |
1.004: |
uses only HTML::CalendarMonthSimple, ISO dates, all possible settings, fixed month bug |
1.003: |
introducing HTML::CalendarMonthSimple |
1.002: |
TWiki:Main/ChristianSchultze: highlight today, relative month/year and debugging (thanks!) |
1.001: |
delayed load of used packages |
1.000: |
first release using only HTML::CalendarMonth |
Dependencies: |
Name | Version | Description |
---|
Date::Calc | >=1.000 | Required | HTML::CalendarMonthSimple | >=1.23 | Required | |