Question : How-to make the Calendar to adapt to each blog page instead of staying fixed on the Main_blogentry?#

--FrancoisParlant

OK, sorry for taking so long. I was initially going to say that it cannot be done, but then I realized that yes, it's quite doable. It basically just requires changing the "jspwiki.tld" file to have the following:

  <tag>
    <name>Calendar</name>
    <tagclass>com.ecyrd.jspwiki.tags.CalendarTag</tagclass>
    <bodycontent>empty</bodycontent>
    <attribute>
       <name>pageformat</name>
       <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
       <name>urlformat</name>
       <rtexprvalue>true</rtexprvalue>
    </attribute>
    <attribute>
       <name>monthurlformat</name>
       <rtexprvalue>true</rtexprvalue>
    </attribute>
  </tag>  

Note that for each attribute you will have to define the "rtexprvalue" to be "true". This has now been enabled for JSPWiki 2.1.60 onwards, so you don't have to change anything if you're tracking the CVS version.

It does add some performance penalty, though.

After the change, you can do it like this:

<% String pagename = ((com.ecyrd.jspwiki.WikiContext)pageContext.getAttribute("jspwiki.context",
         PageContext.REQUEST_SCOPE)).getPage().getName(); %>

<wiki:Calendar pageformat="<%="'"+pagename+"_blogentry_'ddMMyy'_1'"%>"
      urlformat="<%="'Wiki.jsp?page="+pagename+"&weblog.startDate='ddMMyy'&weblog.days=1'"%>"
      monthurlformat="<%="'Wiki.jsp?page="+pagename+"&weblog.startDate='ddMMyy'&weblog.days=%d'"%>" />

Yup. It's extraordinarily ugly, but it works. The problem is that for some really, really strange reason (at least with JakartaTomcat 4.1) it is impossible to specify a tag within the ' -signs. It all works fine if you skip the single quotes, but those are required for the SimpleDateFormat.

-- JanneJalkanen

Thank you for this nice bit of code which works really great (without any performance change, and I'm running a 233mhz) REALLY COOL.--FrancoisParlant


Question: Can I insert the Calendar Plugin inside an entry?#

Exemple:#

[{INSERT com.ecyrd.jspwiki.tags.CalendarTag WHERE pageformat="'Main_blogentry_'ddMMyy'_1'"; urlformat="'Wiki.jsp?page=Main&weblog.startDate='ddMMyy'&weblog.days=1'"}]

--FrancoisParlant

No, this is not possible, as the CalendarTag is a JSP Tag, not a plugin. It is meant for building your template, not for inserting on a page.

There is actually a (good) reason for it being a tag instead of a plugin, but I just can't remember it right now.

--JanneJalkanen

Apart from this (good) reason I would prefer a CalendarPlugin so the same JSPWiki instance could be used as a Wiki and as a Weblog. Now if they are integrated I should decide between show the calendar in whe Wiki pages (something weird) or miss the Calendar in the blogs.

--JoseMRus

In 2.2 you can do it by saying [{SET template='weblogtemplate'}] on your weblog page. This allows you to have different templates: one with the calendar and one without the calendar (for normal wiki pages). You can also do the same thing with stylesheets...

-- JanneJalkanen


I'd like to use the Calendar not only for blogs#

-- MDeichsel
CalendarExample.png
In my wiki-installation I would like to add 'blog-entries' to days in the past or in the future (like a normal calendar) not only for the current day. I know that you can do this by editing the URL but I was looking for a more convenient method. For this reason I've done some minor modifications:
  • remove the condition that restricts the calendar-navigation to the current date.
  • changed the implementation of getDayLink(). The main goal of this change is that days without existing blog-entry are rendered using an anchor-tag whose onDblClick-event is used to switch to the edit-view for the blog-entry of this date. So a double-click will create a new blog-entry for the relevant day.
	private String getDayLink(Calendar day)
	{
		WikiEngine engine = m_wikiContext.getEngine();
		StringBuffer result = new StringBuffer();

		Calendar cal = Calendar.getInstance();
		cal.set(Calendar.HOUR_OF_DAY, 0);
		cal.set(Calendar.MINUTE, 0);
		cal.set(Calendar.SECOND, 0);
		cal.set(Calendar.MILLISECOND, 0);

		Date today = cal.getTime();
		cal.add(Calendar.DAY_OF_MONTH, 1);
		Date tomorrow = cal.getTime();
		String pagename =
			m_pageFormat != null ? m_pageFormat.format(day.getTime()) : null;
		String url =
			m_urlFormat != null ? m_urlFormat.format(day.getTime()) : null;

		StringBuffer sb = new StringBuffer();
		sb.append("days");
		int weekDay = day.get(Calendar.DAY_OF_WEEK);
		if (weekDay == Calendar.SATURDAY || weekDay == Calendar.SUNDAY)
		{
			sb.append("Weekend");
		}

		boolean isToday =
			!day.getTime().before(today) && day.getTime().before(tomorrow);
		if (isToday)
		{
			sb.append("Today");
		}

		result.append("<td class=\"");

		if ((pagename != null && engine.pageExists(pagename)) || url != null)
		{
			sb.append("Link");
		}

		result.append(sb.toString()).append("\"><a");

		if (pagename != null && engine.pageExists(pagename))
		{
			if (url != null)
			{
				result.append(" href=\"").append(url).append("\"");
			}
			else
			{
				result.append(" href=\"").append(
					engine.getViewURL(pagename)).append(
					"\"");
			}
		}
		else if (pagename == null && url != null)
		{
			result.append(" href=\"").append(url).append("\"");
		}
		else
		{
			if (pagename != null)
			{
				result
					.append(" onDblClick=\"javascript:document.location.replace('")
					.append(engine.getEditURL(pagename))
					.append("')\"");
			}
		}

		result.append(">").append(day.get(Calendar.DATE));
		result.append("</a></td>");
		return result.toString();
	}
  • Add some styles to jsswiki.css
	/* ----- For the CalendarTag -----------------------------*/

	TABLE.calendar  {
	    padding: 4;
	    spacing: 4;
	    color: white;
	    text-align: center;
	}

	TD.month        { font-weight: bold; }

	TD.weekdays     { font-size: 85%; }
		     
	TD.days                { background: #9999aa; }
	TD.daysWeekend         { background: #ccccee; }
	TD.daysToday           { background: #9999aa; border-style: solid; border-color: #dd2222;}
	TD.daysWeekendToday    { background: #ccccee; border-style: solid; border-color: #dd2222;}

	TD.daysLink                { background: #dddddd; }
	TD.daysWeekendLink         { background: white; }
	TD.daysTodayLink           { background: #dddddd; border-style: solid; border-color: #dd2222;}
	TD.daysWeekendTodayLink    { background: white; border-style: solid; border-color: #dd2222;}

	TD.othermonth   { color: #707070;
                  font-size: 75%; }

Question: How can i get the calendar to show >> to next month.#

When viewing the current month, I would like the calendar to show << and >> but currently it only has a link to past dates (Imagine today is April & look at the atached png).
thanks
CalendarTag Ideas

Add new attachment

Only authorized users are allowed to upload new attachments.

List of attachments

Kind Attachment Name Size Version Date Modified Author Change note
png
CalendarExample.png 2.9 kB 1 20-Apr-2004 18:09 MDeichsel
« This page (revision-17) was last changed on 09-Mar-2006 16:11 by 192.18.1.5