example

CalendarPlugin

This plugin is originally build on CalendarPlugin v1.020 .

The CalendarPlugin2 handles the tag %CALENDAR2% 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.

If you dont want to use tag %CALENDAR2%, you can modify it in <nop>CalendarPlugin.pm at line 267,268 and also in <nop>CalSync.pm 121,122.

NB. This Plugin does not, and has never, observed topic permissions.

Syntax Rules

You type you get
%CALENDAR2% a monthly calendar for the current month/year, with events taken from the current topic
%CALENDAR2{<attributes>}% is the full syntax

Attributes recognized

Attribute Meaning Default
oldcalendar="1" or "0" if 1 calendar looks like CalendarPlugin v1.020 "0"
id="any" identify particular iCal Calendar if there is more than one Calendar in the same topic ""
timezone="+/-hh" or a time zone abbreviation (e.g. "UTC", "CET" ...) specify timezone, ! NOT WORKING PROPERLY ! "0"
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
topic="TopicName" Topic containing events The topic containing the tag
topic="Web.TopicName1, Web.TopicName2" Topics containing events The topics containing the tags
web="Webname" Web containing the event topic The current web
lang="language" Language: First few characters of "English", "Frani"?1/2ais", "Deutsch", "Espai"?1/2ol", "Portugui"?1/2s", "Nederlands", "Italiano", "Norsk", "Svenska", "Dansk", "suomi", "Magyar", "Polski "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 - only in oldcalendar
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) - only in oldcalendar
showweekdayheaders="1" Show the weekday headers "0" - only in oldcalendar
weekdayheadersbig="0" If enabled, show weekday headers in bold cell headings "1" - only in oldcalendar
cellalignment="left" Horizontal cell alignment of day cells: "left", "center", "right", "justify", "char" "center" - only in oldcalendar
vcellalignment="middle" Vertical cell alignment of day cells: "top", "middle", "bottom", "baseline" "top" - only in oldcalendar
cellheight="n" Height in pixels of each cell in the calendar Minimum height needed - only in oldcalendar
format="..." How to highlight a date See Event Formatting below - only in oldcalendar
width="n" or "n%" Width of calendar table in pixels or percent Minimum width needed
border="n" Border width of calendar table "1" - only in oldcalendar
nowrap="1" or "0" Prevent cell content from wrapping "0" - only in oldcalendar
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 - only in oldcalendar
contentcolor="#nnnn" Default content color of all cells unless redefined black - only in oldcalendar
headercolor="#nnnn" Background color of the Month+Year header The web bgcolor - only in oldcalendar
headercontentcolor="#nnnn" Content color of the Month+Year header contentcolor setting - only in oldcalendar
weekdayheadercolor="#nnnn" Background color of weekdays' headers bgcolor setting - only in oldcalendar
weekdayheadercontentcolor=
"#nnnn"
Content color of weekdays' headers contentcolor setting - only in oldcalendar
weekendheadercolor="#nnnn" Background color of weekends' headers bgcolor setting - only in oldcalendar
weekendheadercontentcolor=
"#nnnn"
Content color of weekends' headers contentcolor setting - only in oldcalendar
weekdaycolor="#nnnn" Background color of weekday cells bgcolor setting - only in oldcalendar
weekdaycontentcolor="#nnnn" Content color of weekday cells contentcolor setting - only in oldcalendar
weekendcolor="#nnnn" Background of weekend cells light gray - only in oldcalendar
weekendcontentcolor="#nnnn" Content color of weekend cells contentcolor setting - only in oldcalendar
todaycolor="#nnnn" Background of today's cell The web bgcolor - only in oldcalendar
todaycontentcolor="#nnnn" Content color of today's cell contentcolor setting - only in oldcalendar
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. 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 - only in oldcalendar
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) - only in oldcalendar
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 - only in oldcalendar
multidayformat Specifies formatting of the description for multi-day events. See Multi-Day Event Formatting for details. $description - only in oldcalendar

Event Syntax

Events are defined by bullets with the following syntax:

Event type Syntax Example
Single: * dd MMM yyyy - description 09 Dec 2002 - Expo
Single incuding time: * dd MMM yyyy hh:mm(:ss) - hh:mm(:ss) - description 09 Dec 2002 14:00(:00)-15:00(:00) - Expo (Same day)
* dd MMM yyyy hh:mm(:ss) - description 09 Dec 2002 14:00(:00) - Expo (from 14 to the end of the day)
Interval: * dd MMM yyyy - dd MMM yyyy - description 02 Feb 2002 - 04 Feb 2002 - Vacation
Interval including time: * dd MMM yyyy hh:mm(:ss) - dd MMM yyyy hh:mm(:ss) - description 02 Feb 2002 14:00(:00) - 04 Feb 2002 14:00(:00) - 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
Monthly including time: * w DDD hh:mm(:ss) - hh:mm(:ss) - description 1 Fri 14:00(:00) - 15:00(:00) - Every 1st Friday of the month from 14:00 to 15:00
* L DDD hh:mm(:ss) - hh:mm(:ss) - description L Mon 14:00(:00) - 15:00(:00) - The last Monday of each month from 14:00 to 15:00
* dd hh:mm(:ss) - hh:mm(:ss) - description 14 14:00(:00) - 15:00(:00) - The 14th of every month from 14:00 to 15:00
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)
Weekly including time: * E DDD hh:mm(:ss) - hh:mm(:ss) - description E Wed 14:00 - 15:00 - Every Wednesday 14:00 - 15:00
* E DDD hh:mm(:ss) - hh:mm(:ss) dd MMM yyyy - description E Wed 14:00 - 15:00 1 Jan 2005- Every Wednesday 14:00 - 15:00 Starting 27 Jan 2005
* E DDD hh:mm(:ss) - hh:mm(:ss) dd MMM yyyy - dd MMM yyyy - description E Wed 14:00 - 15:00 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

Export to iCal

Every %CALENDAR2% tag creates also iCalendar export of Events, it is available through direct link placed under Calendar. If you want to have your organiser synchronized, you can use this link. ICal files are by default saved in pub directory.

Event formatting

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).

Multi-Day Event Formatting only with attribute oldcalendar="1"

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.

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!

%CALENDAR2{ oldcalendar="1" month="2" year="2002" bgcolor="cyan"}% %CALENDAR2{month="3" year="2002" showweekdayheaders="1" ID="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

Example

%CALENDAR2{oldcalendar="1" month="2" year="2002" bgcolor="cyan" ID="1"}% %CALENDAR2{month="3" year="2002" showweekdayheaders="1" ID="1"}%

Plugin Settings

Plugin settings are stored as preferences variables. To reference a plugin setting write %<plugin>_<setting>%, i.e. %INTERWIKIPLUGIN_SHORTDESCRIPTION%

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = Show a monthly calendar with highlighted events

  • Debug plugin: (See output in data/debug.txt)
    • Set DEBUG = 0

  • How the cell content is formatted
      * #Set FORMAT = $old<br /><small>$description</small>
  • Note: You can add settings of any of the recognized attributes (in upper case like SHOWWEEKDAYHEADERS). Examples are shown below:
    • #Set CELLALIGNMENT = center
    • #Set VCELLALIGNMENT = center
    • #Set WIDTH = 100%
    • #Set GMTOFFSET = +10
    • #Set SHOWWEEKDAYHEADERS = 0
    • #Set WEEKSTARTSONMONDAY = 0

Plugin Installation Instructions

Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.

  • Download the ZIP file from the Plugin web (see below)
  • The Plugin uses the HTML::CalendarMonthSimple2 and HTML::CalendarMonthSimple and Date::Calc , Date::ICal , Data:: ICal CPAN packages (see http://www.cpan.org)
    • Install Date::Calc
    • Install Date::ICal
    • Install Data:: ICal
    • Install HTML::CalendarMonthSimple2 and HTML::CalendarMonthSimple
    • To avoid an annoying log message, change line 272 of CalendarMonthSimple.pm v1.25 by adding the section marked in RED :
      if ($self->year = = $todayyear && $self->month = = $todaymonth %RED% && defined $thisday %ENDCOLOR% && $thisday = = $todaydate)
      • For earlier or later versions where the line number may be different, search for todayyear. It currently (v1.22-v1.25) only appears twice: once to declare and set it, once to use it. On the line that uses it, add the && defined $thisday as shown above. -- TWiki:Main.AngusRogerson - 16 Aug 2004
  • Unzip CalendarPlugin.zip in your twiki installation directory. Content:
File: Description:
data/TWiki/CalendarPlugin.txt Plugin topic
data/TWiki/CalendarPlugin.txt,v Plugin topic repository
lib/TWiki/Plugins/CalendarPlugin.pm Plugin Perl module
pub/TWiki/CalendarPlugin/exclam.gif Image file
pub/TWiki/CalendarPlugin/ICal.gif Image file
bin/getical Sync script
lib/TWiki/Contrib/CalSync.pm Perl module
lib/HTML/Bubble.js JavaScript displays event details in bubble
lib/HTML/Cal.css GoogleCalendar-like css
lib/HTML/CalendarMonthSimple.pm Plugin Perl module
lib/HTML/CalendarMonthSimple2.pm Plugin Perl module
lib/HTML/images/btn_next.gif Button image
lib/HTML/images/btn_prev.gif Button image
lib/HTML/images/continue.gif previous line in calendar
lib/HTML/images/bubble.png Bubble image
  • (Dakar) Visit configure in your TWiki installation, and enable the plugin in the {Plugins} section.
  • Test if the installation was successful:
    • You should see two calendars near the Event list above and a current month calendar below:
%CALENDAR2%

Plugin Info

Plugin Author: TWiki:Main/PavelJenicek
Copyright: © 2010, TWiki:Main/PavelJenicek
License: GPL (GNU General Public License)
Plugin Version: 2010-01-21 (V1.000)
Change History:
2010-01-21: Initial version
TWiki Dependency: $TWiki::Plugins::VERSION 1.1
CPAN Dependencies: CPAN:HTML::CalendarMonthSimple2 or CPAN:HTML::CalendarMonthSimple >= v1.23, CPAN:Date::Calc, CPAN:Date::ICal, CPAN:Data::ICal
Other Dependencies: none
Perl Version: 5.005
Benchmarks: GoodStyle nn%, FormattedSearch nn%, CalendarPlugin nn%
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/CalendarPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/CalendarPluginDev
Appraisal: http://TWiki.org/cgi-bin/view/Plugins/CalendarPluginAppraisal

Related Topics: TWikiPlugins, DeveloperDocumentationCategory, AdminDocumentationCategory, TWikiPreferences

Topic revision: r1 - 2019-10-14 - TWikiGuest
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.CalendarPlugin.