Plugin: jscalendar
Author: Grésille
Test page: test
This plugin provides a jscalendar
directive.
The directive displays a calendar, similar to the typical calendars shown on
some blogs.
The calendar created by this plugin is the same as the one created by plugin ?calendar, excepted that this one is written in javascript, and the page containing it does not need to be rebuilded each day or each time some page in the pagespec changes.
Setup
The calendar is essentially a fancy front end to archives of previous pages, usually used for blogs. It produce a calendar for a given month. The month format calendar simply links to any page posted on each day of the month.
The ikiwiki-calendar
command can be used to automatically generate the
archive pages. It also refreshes the wiki, updating the calendars to
highlight the current day. This command is typically run at midnight from
cron.
An example crontab:
0 0 * * * ikiwiki-calendar ~/ikiwiki.setup "posts/* and !*/Discussion"
Directive
This directive displays a javascript calendar, similar to the typical calendars shown on some blogs.
Examples
[[!jscalendar ]]
[[!jscalendar type="month" archivebase="calendar"]]
[[!jscalendar type="month" year=2014 month=08 pages="posts/* and !posts/*"]]
[[!jscalendar type="month" year=-1 month=08]]
Usage
type
- Used to specify the type of calendar wanted. Right now, "month" is the only accepted value (and is the default). This option is set to remain close to the ?calendar directive, and to anticipate later development.pages
- Specifies the PageSpec of pages to link to from the month calendar. Defaults to the value of optionarchive_pagespec
(see below).year
- The year for which the calendar is requested. Defaults to the current year. Can also use -1 to refer to last year, and so on.month
- The numeric month for which the calendar is requested, in the range 1..12. Defaults to the current month. Can also use -1 to refer to last month, and so on.archivebase
- Configures the base of the archives hierarchy. The default is defined in wiki optionarchivebase
(see below). Note that this default can also be overridden for the whole wiki by settingarchivebase
in ikiwiki's setup file. Calendars link to pages under here, with names like "2010/04" and "2010". These pages can be automatically created using theikiwiki-calendar
program.
Setup file
Options that can be set in the Ikiwiki's setup file.
archivebase
- Configures the base of the archives hierarchy. The default is "archives". Calendars link to pages under here, with names like "2010/04" and "2010". These pages can be automatically created using theikiwiki-calendar
program.archive_pagespec
- Specifies the default PageSpec of pages to link to from the month calendar. Defaults to "*".css_jscalendar_keyword
- In the name of classes used to display the calendar, replaces wordcalendar
by its value. E.g. ifcss_jscalendar_keyword
isjscalendar
, class used to display a day number with a link to a page ismonth-jscalendar-day-link
instead ofmonth-calendar-day-link
.week_start_day
- A number, in the range 0..6, which represents the day of the week that the month calendar starts with. 0 is Sunday, 1 is Monday, and so on. Defaults to 0, which is Sunday.month_link
- If true (which is the default), display the month name as a link toarchives/year/month
. Otherwise, no link is done, and you can ignoreikiwiki-calendar
.
Differences with ?calendar
- Pros
- No need to rebuild the page containing the calendar each time day changes, or a page (indexed by the calendar) is added, changed or deleted. This is particularly useful if you want to have this calendar in the sidebar.
- Smooth navigation among months.
- Cons
- Javascript .
Example
An example of this plugin can be found on the Grésille website.
CSS
The output is liberally sprinkled with classes, for fine grained CSS
customization. The classes are those used by the ?calendar plugin,
excepted if option css-calendar-keyword
is set in the setup file: in this
case, the classes are the one listed below, where calendar
is replaced by the
given keyword.
month-calendar
- The month calendar as a whole.month-calendar-head
- The head of the month calendar (ie,"March").month-calendar-arrow
- Arrow pointing to previous/next month.month-calendar-day-head
- A column head in the month calendar (ie, a day-of-week abbreviation).month-calendar-day-noday
,month-calendar-day-link
,month-calendar-day-nolink
,month-calendar-day-future
,month-calendar-day-this-day
- The day squares on the month calendar, for days that are not in the month (before or after the month itself), that don't have links, that do have links, that are in the future, or are that are the current day, respectively.Sunday
,Monday
,Tuesday
, ... - Each day square is also given a class matching its (localised) day of week, this can be used to highlight weekends.