!Summary

Attached is a ''CalendarPlugin'' that I wrote for my own wiki-mutant. I tend to use the system for personal organization and note-keeping, and a calendar-like system is very convenient to have. [Janne|JanneJalkanen]'s ~WeblogPlugins (still alpha) are a bit more geared toward a public bloggy thing - not suitable for my purposes. Still, I stole some ideas from there.

A calendar has a unique name. This corresponds to a WikiPage, which you would probably configure to show information related to the calendar. It is also the basis of entries for single days: the name of a day entry is of the form ''name_YYMMDD''. The calendar can be used both to display and navigate a small calendar table, and to display a collection of several daily entries.

Hope you enjoy it;
--[ebu]



!Calendar mode

In my ~LeftMenu, I have a default invocation for a calendar called '~EbuCal1':
{{{
      [{CalendarPlugin name='EbuCal1'}]
}}}
The CalendarPlugin expects that a WikiPage called ''~EbuCal1'' exists. (No disaster if it doesn't - this is just a CalendarPlugin convention for convenient summary views.)

The invocation above creates a small HTML calendar that lets you scroll the month and year (staying on the same page), or select a date:

[screenshot.png]

The currently selected page is inverted (white on reddish background); dates that have page entries are black on a brownish background. If the current day's date were visible, it would be rendered black, just to clutter things up. 

What happens when you click on a day depends on the options. In default form, each day-link takes you to a WikiPage named after the calendar, ''and'' sets the calendar's date to that day. If you add ''linkto='current''' to the invocation, day-links keep you on the current page, and just set the calendar to that date. (This is useful in ''summary'' mode: navigate to ''~EbuCal1'' and select dates to view a month's worth of entries. See ''summary'' mode, below.)

Clicking on the month or year also take you to ''~EbuCal1'', but they set the date to the end of the month or year and ask the ''summary'' view to display a month's or year's worth of entries (operation not functional yet).

On the bottom right of the calendar, two links provide a shortcuts. T returns the calendar to today; E takes you to the WikiPage that corresponds to the selected day's entry. Think Edit Entry. (This is not useful in the default mode, more so in ''linkto='current''' mode.)

Try the default and current-page modes out and see which suits you best.


!Summary mode

After adding the calendar to my menu, I clicked on the month title and was prompted to create a new page called ''~EbuCal1''. This is what I added:
{{{
      [{CalendarPlugin name='EbuCal1' view='summary' days='31'}]
}}}

The ''view'' option here switches the plugin to ''summary'' mode, displaying a maximum of 31 
daily entries. This is reminescent of the WeblogPlugin mode, but we don't care as much about 
author information, comments, and the like. 


!Personal calendars

You'll notice that if you have the calendar on the ~LeftMenu page, all your WikiUsers will see it. If you want to have a personal calendar, you'll need to place it on a page of your own (and perhaps apply access restrictions), or do what I did here: each (authenticated) user has their own left menu bar. This requires modification of the ''~LeftMenu.jsp'' file to check the user profile and use the name __~LeftMenu__.''username'' instead of the default.

The above does require some knowledge of the latest JSPWiki version (CVS, 2.1.89, or newer), its as yet rather undocumented Authentication/Authorization system, and JSP.


!Installation

To install CalendarPlugin using the [binary distribution|CalendarPlugin-binary.zip]:

# Extract the [binary distribution|CalendarPlugin-binary.zip] into {{WEB-INF/classes}}.
# Restart JSPWiki.

or

# Extract {{WEB-INF/lib/JSPWiki.jar}} from your JSPWiki installation into another folder, say {{JSPWiki}}.
# Extract the [binary distribution|CalendarPlugin-binary.zip] into folder {{JSPWiki}}.
# From within folder {{JSPWiki}}, zip its contents to {{JSPWiki.zip}}.  The files in {{JSPWiki.zip}} must not contain the folder {{JSPWiki}} in their pathnames.  Rename {{JSPWiki.zip}} to {{JSPWiki.jar}}.
# With the {{JSPWiki.jar}} that you built, overwrite {{WEB-INF/lib/JSPWiki.jar}} in your installed JSPWiki application.
# Restart JSPWiki.

To install CalendarPlugin from [source|CalendarPlugin.zip]:

# Download a JSPWiki source distribution.
# Copy the CalendarPlugin source files into {{src/com/ecyrd/jspwiki/plugin}}.
# Build {{JSPWiki.jar}} with the command {{ant jar-optimized}} or build a {{JSPWiki.war}} Web application with the command {{ant war}}. (In order to build JSPWiki, you must install [Ant|http://ant.apache.org/]).
# With the {{JSPWiki.jar}} that you built, overwrite {{WEB-INF/lib/JSPWiki.jar}} in your installed JSPWiki application or, using the {{JSPWiki.war}} that you built, re-install JSPWiki on your JSP and Servlet container.  For [Tomcat|http://jakarta.apache.org/tomcat], this usually requires that you copy {{JSPWiki.war}} into the Tomcat {{webapps}} directory.
# Restart JSPWiki.


!CSS for CalendarPlugin

You will want to add something to the ''jspwiki.css'' style definitions. You might start with the following, and tweak to suit your color scheme. This is not optimized in any manner, nor is it pretty...

{{{
div.calendar { background-color: #f0f0f0; 
               font-family: monospace; font-size: 
               xx-small; 
               font-weight: normal; }
div.calendartitle       { background-color: #e0e0e0; }
div.calendar a          { font-weight: lighter; }
div.calendar a.today    { color: #000000; }
div.calendar a.selected { color: #ffffff; background-color: #a04020; }
div.calendar a.exists   { color: #000000; background-color: #d0b0a0; }
div.calendarentry       { border: 1px solid #a0a0a0; padding: 4px; }
div.calendarentryheader { background-color: #e0e0e0; }
div.calendarentryfooter { background-color: #f0f0f0; }
}}}


!Bug-like things

* Need decent, universal UTF-8 symbols for the 'today' and 'entry' links...
* The default view mode may not be too useful. Considering just using ''linkto='current''' as default.
* Others? Please report to me here.

* I have strange behaviour regarding the font-size when using CalendarPlugin together with the mgr template. Most of the time the font-size is normal (small) but sometimes it shifts to the size of the remaining text in the left menu. Why ever. This behaviour might of course also result from my browser... --[Christoph Grimmer]
** As a guess, I'd say there's something with the template that causes your browser to switch the rendering mode. The original JSPWiki template did this to me on mozilla browsers; sometimes the <hr> separators would render wrong. I never figured out what exactly caused that; my own template doesn't seem to. --[ebu]

!Things to come

* The calendar overrides request parameters with plugin parameters. The point is that CalendarPlugin is meant to be used with the [WikiFormsPlugin] to provide easier perusal of dates. The current date selection system is a bit rudimentary.
* The summary mode now displays a running list of entries. Will consider implementing views for the current month, year.

Yes, please do so. I'm trying to have a month summary on the Main page of our Wiki but simply handing d='31' over to the plugin doesn't work. Suggestions? -- [Christoph Grimmer]

----
''Question: Is there a way to show future events via Summary mode? -- [Stefan Hübner]''

Yes, you simply have to click the year instead of the month in the calendar head. -- [Christoph Grimmer]

To see future events one first has to select a month (or year) in the future and then click on the calendar head. I find this not intuitive. There sould be some kind of button wich immediately shows all future events (a '' E T F'' where F is for display of future events?) -- [Christoph Sauer]

I've uploaded a new file (''zlec-CalendarPlugin.java'') that has a ''view="upcoming"'' mode that is basically the summary mode, but with events in the future upto ''time='' days in the future.  Perhaps this is what you wanted. (I'm using the CalendarPlugin to announce scheduled downtime internally for our app server). I would have just uploaded a patch diff, but I feel victim to a  rather overzealous ctrl-shift-f in eclipse.
e.g. 
{{{
[{CalendarPlugin name='ScheduledWork' view='upcoming' days='5'}]
}}}
--[LewinChan]
----
----
''Question: Can you get summary to show the dates in ascending rather than descending order? In other words, I want August 5th to display higher on the page than August 6th -- Sherman Mohler''

----

----
''Question: How do I change the filename to be opened after clicking a day ? -- Manu Anand''

----
There is a bug in uploaded [zlec-CalendarPlugin.java] in {{private String collectPages(WikiEngine wiki, Calendar from, CalendarPrinter cal, String style, int totalDays, int add)}} method which makes calendar unusable in summary and upcoming modes - a record for current date is duplicated {{days}} times.
See [IK-CalendarPlugin.java] attachment for fixed revision.
-- [IllyaKysil]
----



----

When i was trying out this plug-in, the calendar had some bad alignment, the top row was not aligned with the other rows. So then we converted the calendar into a table, so everything becomes aligned. 

If you want your calendar in a table format, then download the [CCMH_CalendarPrinter.java]. 

__And for the CSS__ 
You will want to add something to the jspwiki.css style definitions.
Here's the screenshot of the calendar with the CSS below. \\
[CCMH_calendar.PNG]

You may use this, or edit it a little to the colors you want. 
In this specific calendar, __pink__ is today’s date and __yellow__ is the ones with page entries.

{{{
td.calendar 
	{ background-color: #E2F1F6; 
font-color: #ff0000;
      font-family: arial; 
      font-size: small; 
      font-weight: bold; 
      text-align: center; 
           }
                   
td.calendar a.today    
	{  font-family: monospace; color: #000000; }	

td.calendartitle      
 	{ background-color: #A3DEF4; font-family: arial; text-align: center; color: #000000; font-weight: bold; text-decoration: none;}

td.calendar a    /* dates on the calendar*/
	{  font-family: monospace; font-weight: lighter; color: #000000; text-decoration: none; }

td.calendar a.selected /* today's date*/
	{ font-family: monospace;  color: #000000; background-color: #FFA6E5; font-weight: bold;  }

td.calendar a.exists /*dates that have page entries*/   
	{ font-family: monospace; color: #000000; background-color: #FFF600; }
	 

/* edits the summary page */
div.calendarentry       
	{ border: 1px solid #000000; padding: 4px; } 

div.calendarentryheader 
	{ background-color: #A3DEF4; color: #000000; font-weight: bold; text-decoration: none;}

div.calendarentryfooter 
	{ background-color: #E2F1F6; color: #000000; font-weight: bold; text-decoration: none; } 
}}}
    


--[Connie Chan|ConnieChan], 19-Jul-2006


----

I am having trouble to run the Calendar Plugin with JSPWiki 2.4.15-beta. 
After upgrading JSPWiki from 2.0.52 and unzipping the binary into WEB-INF/classes it still  keeps telling me: {{{Plugin insertion failed: class "com.ecyrd.jspwiki.plugin.CalendarPlugin"'s signer information does not match signer information of other classes in the same package.}}}
\\ What do I need to do?

--Eva Lippert-Stephan, 25-Jul-2006
----
Hi.  I am having the same problem with JSPWiki 2.4.15-beta.  I tried to sign the Calendar Plugin classes with the same certificate as the main JSPWiki classes, but while the jspwiki.jsk file contains the certificate, I don't know the password to use to sign the files.
\\ \\Also, is it possible to change the layout of the calendar to (Sun,Mon,Tues,Wed,Thur,Fri,Sat)?
 
\\Thanks,
\\[Ryan Sawatzky|rsawatzky], 26-Jul-2006


----

Plugin insertion failed: class "com.ecyrd.jspwiki.plugin.CalendarPlugin"'s signer information does not match signer information of other classes in the same package

i've got the same error.

By the way, thanks for the plugin, that's amazing, i started looking for it like 4 days ago only :)


--Longbeach, 28-Jul-2006
----
Hello.  I have gotten this plugin to work with JSPWiki 2.4.15-beta.  I had to download the source of the plugin, change the source files to put the two classes into my own package, compile into a JAR file, and publish.  According to Janne, all classes in the com.ecyrd.jspwiki package must be signed with the same certificate.  So, by simply moving the two classes for this plugin to your own package, you should be able to get around this issue.  I structured my JAR file as explained in [this page|http://doc.jspwiki.org/2.4/wiki/DevelopingPlugins] that Janne showed me.  To compile the code, I needed to add JSPWiki.jar and either my j2ee.jar or servlet-api.jar(from tomcat) to the classpath.

As another bonus, since I had to download the source and compile it, I was able to hack in the (Su,Mo,Tu,We,Th,Fr,Sa) calendar format! ;)
\\Hope this helps,
\\[Ryan Sawatzky|rsawatzky], 03-Aug-2006


----

Hi Ryan,

Could you please post the "fixed" Calendar Plugin?
Thanks,\\
-- [NascifAbousalhNeto]

----
Hi, I've posted my JAR file as an attachment to this page (called "calendar.jar").  You should be able to drop this JAR file into your /WEB-INF/lib directory, restart your Wiki, and be good to go.  Please note, that the JAR file I've posted includes the CCMH printer and my hack to change the days to (su,mo,tu,we,th,fi,sa).  So if you don't want those changes, you'll have to build the JAR file on your own, but if you're familiar with compiling Java, it shouldn't be hard at all.
\\[Ryan Sawatzky|rsawatzky], 04-Aug-2006


----

I will give it a try. Thanks for sharing it!

--Nascif Abousalh-Neto, 04-Aug-2006
----



----

There is a bug when you try to view summary for a month. If you click on June, it will give you the summary of May. See the URL below, this is for June. The MinimumsCal.m=5 should be MinimumsCal.m=6

Wiki.jsp?page=Calender&MinimumsCal.y=2007&MinimumsCal.m=5

--[Siva Nookala|mailto:karanbagh@gmail.com], 02-Jun-2007


----

This is not possible to use with the __jspwiki.urlConstructor =ShortURLConstructor__ you have to switch to __jspwiki.urlConstructor = DefaultURLConstructor__ wich is lame.

--Sebastian Dieguez, 21-Aug-2007