This is a MoinMoin macro for event calendar (similar to MonthCalendar macro). The development is based on the MoinMoin MonthCalendar macro but it is a little bit different from MonthCalendar. It is targeted to the one of PIM. It includes a parser which shows the event information in a well parsed format.

Features

Platform Support

Installation Guide

Download

Change Log

Usage

Event Format

Datetime Format

Event Data Example

Parameters

Sample & Screenshot

To do list

Completed To do's

Notes

Confirmed Bugs & Patches

v0.99a

1.9.1 & 1.9.2 require this patch:

v0.99

1.8.0 update Patch

For 1.8.0 MoinMoin, I have modified the CacheEntry function to use Page instance caching (scope='item') as the default scope of wiki fails to render the calendar. -- AlanSnelson 2008-11-05 16:49:00

Thankyou! :-) --DavidGore 2008-12-16 04:01:00

1.6.1 update Patch

For 1.6.1 MoinMoin, I remove imported module that do not use, and edit two line because of argument's count. In addition, I add encode,decode code for caching based on non-alphabet character pagenames.

example page My Journal Page --NeoCoin 2008-02-14 05:15:54

UTC Offset Messes up Upcoming event view

I set my offset to -5.0 from UTC and my upcoming view is empty. FYI, the UTC was a day ahead when I tried --JaeStutzman

Days back in Upcoming view

Would be nice if the Upcoming view would offer a second range varable beside upcomingrange - something like backrange. With this, the upcoming view would be extended to a recent and upcoming event view - this would be very helpful for example to create an What happened lately and will happen soon view ...

And here's the patch:

26d25
<         * backrange: # of days for the backrange of upcoming event list. default: 0 (days)
184d182
<     backrange = 0   # days
217d214
<     backrange = 0
382,388d378
<     # backrange: # of days for backrange in upcoming event list
<     # default: 0
<     try:
<         Params.backrange = int(params.get('backrange', Globs.backrange))
<     except (TypeError, ValueError):
<         Params.backrange = Globs.backrange
<
832d821
<     dayback_delta = datetime.timedelta(days=Params.backrange)
834d822
<     prev_range = cur_date - dayback_delta
838c826
<     datefrom = u'%04d%02d%02d' % (prev_range.year, prev_range.month, prev_range.day)
---
>     datefrom = u'%04d%02d%02d' % (year, month, day)
846,847c834
<     datefrom = formatcfgdatetime(formatdateobject(prev_range))
<     # datefrom = formatcfgdatetime(cur_date, nowtime)
---
>     datefrom = formatcfgdatetime(cur_date, nowtime)
857,858c844,846
<         if events[eid]['enddate'] >= formatdateobject(prev_range):
<             html_event_rows.append( listshow_event(events[eid]) )
---
>         if events[eid]['enddate'] >= formatdateobject(Globs.today):
>             if (not events[eid]['endtime']) or events[eid]['endtime'] >= formattimeobject(Globs.now):
>                 html_event_rows.append( listshow_event(events[eid]) )

Week Number

thanks for implementing the week numbers! but, if the first day of the week is monday, the weeknumber is wrong. I've patched it the following way:

# diff EventCalendar-099.py EventCalendar.py
176c176
< calendar.setfirstweekday(calendar.SUNDAY)
---
> calendar.setfirstweekday(calendar.MONDAY)
3629c3629
<         html_text = u'%s <font size="1" color="#aaaaaa"><i>(%d)</i></font>' %(html_text, (int(datetime.date(year, month, day).strftime('%W')) + 1))
---
>         html_text = u'%s <font size="1" color="#aaaaaa"><i>(%d)</i></font>' %(html_text, (int(datetime.date(year, month, day).strftime('%W'))))

Week Numbers in 2008

thanks for implementing the week numbers! but, in 2008 week numbers are wrong, just use the isocalendar. I've patched it the following way:

# diff EventCalendar-099.py EventCalendar.py
176c176
< calendar.setfirstweekday(calendar.SUNDAY)
---
> calendar.setfirstweekday(calendar.MONDAY)
3629c3629
<         html_text = u'%s <font size="1" color="#aaaaaa"><i>(%d)</i></font>' % (html_text, (int(datetime.date(year, month, day).strftime('%W')) + 1))
---
>         html_text = u'%s <font size="1" color="#aaaaaa"><i>(%d)</i></font>' % (html_text, (int(datetime.date(year, month, day).isocalendar()[1])))

Named Colours

I've patched EventCalendar v0.99 so that it allows named colours as well as hex values. This allows entries like this:

== Labels ==
 label_def:: sick, red
 label_def:: conference, yellow

=== Meeting 1 ===
 start:: 2006-05-30
 end:: 2006-06-03
 description:: First Meeting
 label:: conference

=== Moon Trip ===
 start:: 2006-07-19
 description:: Trip to the Moon
 bgcolor:: blue

Here's the patch:

--- EventCalendar-0.99.py.orig  2006-07-18 10:00:48.000000000 +0100
+++ EventCalendar-0.99.py       2006-07-18 10:01:38.000000000 +0100
@@ -1575,7 +1575,7 @@
     regex_page_bgcolor = r"""
 (?P<req_field>^[ ]+default_bgcolor::[ ]+)
 (
-    (?P<pagebgcolor>\#[0-9a-fA-F]{6})
+    (?P<pagebgcolor>(\#[0-9a-fA-F]{6}|[a-zA-Z]+))
     \s*?
     $
 )?
@@ -1616,7 +1616,7 @@
 (
        (?P<name>[^,^:^\s]+?)
        [,: ]+
-       (?P<bgcolor>\#[0-9a-fA-F]{6})
+       (?P<bgcolor>(\#[0-9a-fA-F]{6}|[a-zA-Z]+))
        \s*?
        $
 )?
@@ -1888,7 +1888,7 @@
     regex_bgcolor = r"""
 (?P<reqfield>^[ ]+bgcolor::[ ]+)
 (
-    (?P<bgcolor>\#[0-9a-fA-F]{6})?
+    (?P<bgcolor>(\#[0-9a-fA-F]{6}|[a-zA-Z]+))?
     \s*?
     $
 )?

While this patch makes it possible for users to enter invalid colour names, I think that overall it makes life easier for users. Here's a list of HTML colour names. -- DavidOcallaghan 2006-07-18 09:12:56

This patch updates the pagelinks data, so that the links generated by the macro are registerd correctly for things like OrphanedPages and linkto searches

Show Page List

This patch adds the option to display a list of pages that were used to generate the callendar, below the callendar

Default Label Config Page

This patch adds looking for a defalut page for labels, (also reads events on the page) for all the calls to EventCalendar, this make it easy to have consistant set of labels without duplicating and getting the label duplication warnings, or every time there is a new calendar added needing to add it to the page with the default labels.

Label Priority

This patch fixes the problem where a labels color would be ignored if the page with the defaitions had a default event color

The cached data of calendar events may show to the un-authorized users by acl. -- SeungikLee 2006-10-09 08:27:28

A couple problems and a question. I am using EventCalendar with MMDE (DesktopEdition), installed as a service. a) If I put two event calendar macros in the same page, changes in view on one affect both. So, if I start one with upcoming and the other with monthly, moving one month ahead changes de upcoming view to monthly also.

b) I have to stop and start the MMDE service to include newly defined pages with events. After restart I do the normal cache clean and all works. Perhaps it is a MMDE problem ...

c) question: how one gets full blocks covering several days? (as done in the monthly view example ... I have to artificially make the title long enough but seems unpractical ...)

TIA CarlosBandar

Thanks SeungikLee. It's very useful but there is a error when I use unicode event pagename (ex, Hangul pagename) because "%" character in URL encode string. It is a temporary solution for escaping error.

# diff EventCalendar.py ~/EventCalendar-099.py
2864,2870c2864
<         try:
<             html_cols = u'\r\n'.join(html_hour_cols[hour_index]) % {'colspan': colspan, 'width': u'%d%%' % width}
<         except TypeError:
<             html_cols = u'\r\n'.join(html_hour_cols[hour_index]
<                     ).replace('%(colspan)d',u'%d'%colspan
<                     ).replace('%(width)s', u'%d%%'%width)
<
---
>         html_cols = u'\r\n'.join(html_hour_cols[hour_index]) % {'colspan': colspan, 'width': u'%d%%' % width}

-- HyungyongKim 2006-07-03 08:04:41

also need change a similar line for weekly view.

2864,2867c2864
<         try:
<               html_cols = u'\r\n'.join(html_hour_cols[hour_index]) % {'colspan': colspan, 'width': u'%d%%' % width}
<         except TypeError:
<               html_cols = u'\r\n'.join(html_hour_cols[hour_index]).replace('%(colspan)d',u'%d'%colspan).replace('%(width)s', u'%d%%'%width)
---
>         html_cols = u'\r\n'.join(html_hour_cols[hour_index]) % {'colspan': colspan, 'width': u'%d%%' % width}
3128,3131c3125
<             try:
<               html_cols = u'\r\n'.join(html_hour_cols[hour_index][dayindex]) % {'colspan': colspan, 'width': u'%d%%' % width}
<             except TypeError:
<               html_cols = u'\r\n'.join(html_hour_cols[hour_index][dayindex]).replace('%(colspan)d',u'%d'%colspan).replace('%(width)s', u'%d%%'%width)
---
>             html_cols = u'\r\n'.join(html_hour_cols[hour_index][dayindex]) % {'colspan': colspan, 'width': u'%d%%' % width}

-- GuoYong 2006-09-23 01:03:41

RuthIvimey here with 3 issues:

There is a small error in the list view, which doesn't sort events within a day, only for different days. Apply this patch (unified diff) to fix it:

@@ -1051,8 +1080,11 @@
 # sort events in the list by start date of the event
 def comp_list_events(xid, yid):
     events = Globs.events
-
-    return cmp(events[xid]['startdate'], events[yid]['startdate'])
+    if events[xid]['startdate'] == events[yid]['startdate']:
+        return cmp(events[xid]['starttime'], events[yid]['starttime'])
+    else:
+        return cmp(events[xid]['startdate'], events[yid]['startdate'])
+

 # load events from wiki pages
 def loadEvents(datefrom='', dateto='', nocache=0):

I also consider it a bug, but probably the author doesn't :-), that label background colours have a lower priority than the default background colour. If you want to change that, the following patch is what I'm using, although it might not be optimal...

@@ -1693,8 +1727,8 @@
             #    continue

             # set default values
-            if not e_bgcolor:
-                e_bgcolor = page_bgcolor
+            #if not e_bgcolor:
+                #e_bgcolor = page_bgcolor

             if not e_description:
                 e_description = page_description

And finally, in week view, if you have two events that end and start at the same 1/2 hour point, the calendar puts them side-by-side as if they overlap. I can see why this happens - the granularity of rendering week view is 1 hour, so it can't render a 30 min split. It would be nice if it could though. Would it be very hard to split the day into 48 rows each of 30 mins? For that matter, would it be possible to specify a start hour and end hour for the day - e.g 08:00 to 23:00?

Thanks anyway - it's looking good (see Our Diary ) -- RuthIvimey 2007-05-17 23:36:42

Sorry for beeing anonymus, but another user has used my mail-adress. I think that I have found a bug but can't believe that I am the first. As shown in the Screenshot the Event "Business Trip" is missing in the Upcoming-List. At 20:59 that Event was there. If I change the end to 22:00h it will be listed.

time_bug.PNG

-- Dirk 2007-06-12 21:50:42

The call "request.cfg.url_prefix" returns "None" in MoinMoin1.6.2 (it might also be because I'm using ProxyReverse in Apache). This causes the <SCRIPT> tag to incorrectly point to src="None/common/js/infobox.js" and tooltips are unavailable. I changed "request.cfg.url_prefix" to "request.cfg.url_prefix_static" in line 3366 to avoid this error.

-- DaveGore 2008-04-04 20:37:00

Discussion / Support / Request / Contribution

v0.99

It should be possible to put multiple of EventCalendar macros on a single page. I have created many CategoryCalendarEvents for various purposes. For instance I have create a different category for each user of the system. Now I would like to do the following:

Person One

[[EventCalendar(firstview=upcoming,category=CategoryPersonOneEvents)]]

Person Twe

[[EventCalendar(firstview=upcoming,category=CategoryPersonTwoEvents)]]

This would be very useful when creating an overview page for a secretary or something.

Another nice extension would be the ability to specify multiple even calendar categories for the same calendar. This could be a good compromise to enabling multiple event calendar instances to exist on the same page. (I assume that is a page cache issue) -- AllenCurtis 2007-10-06 20:54:18

Is there a way to create yearly events without specifying the year? I simply don't know or don't want to publish the year for birthday events. --AnkeHeinrich 2007-10-31 10:42:00

I like the interface of this macro. I think it would be nicer if this macro has following functions. Thanks. -- TakeoKatsuki 2010-01-19 07:19:47

  1. Incorporating data of MonthCalendar. For example, could contents of MonthCalendar pages (file names are in year-month-day format) be recognized as the start date and end date of single-day events?

  2. In addition to start:: and end:: syntax, time information in the heading may also be useful for specifying start time and end time of the event. For example, = 14:00-16:00 meeting =.

  3. Creating new events directly from the calendar probably by clicking the date link, which is the case in MonthCalendar.

  4. (./) Faster page rendering. Currently, a category with many subpages such as MonthCalandar pages takes very long time to be rendered.

    • I found this problem only on Windows. On Linux machines this macro is fast enough even with hundreds of subpages.
  5. (./) Specification of multiple categories for one calendar. This would be useful if one wants to obtain data from certain months from MonthCalendar.

    • This can be achieved by <<EventCalendar(category=(CategoryOne OR CategoryTwo))>> 

  6. Importing iCal or GoogleCalendar data. Ideally synchronization with these calendars.

  7. Mouseover on an event displays a box that shows detailed info from the "description" field, and URLs/WikiLinks there are clickable.
  8. Email notification for a specified event.

Is there an EventCalendar-RSS-Feed or is something like that planned? -- MelaEckenfels 2009-08-04 00:46:21

How can I make the calendar starts from Sunday instead of Monday? I changed the code calendar.setfirstweekday(calendar.MONDAY) to calendar.setfirstweekday(calendar.SUNDAY), and restarted the system. It works for the first view, but if I do "delete cache" action, the calendar again starts from Monday. I tested on WinXP and Linux. -- TakeoKatsuki 2010-06-03 02:18:54

Hi, I've made a quick patch (really quick, so probably there still may be bugs :) ) which adds a new field called 'url'. If this one is given for an event then the link in the calendar will point to the given URL instead of the page with the list of events.

497a498
>     url = event['url']
517a519,521
>     if len(url) > 0:
>         targetlink = '<a href="%s">%s</a>' % ( url, wikiutil.escape(targettext))
>
1756c1760
<                 e_start_date, e_start_time, e_end_date, e_end_time, e_bgcolor, e_label, e_description, e_recur_freq, e_recur_type, e_recur_until = geteventfield(eventdetail)
---
>                 e_start_date, e_start_time, e_end_date, e_end_time, e_bgcolor, e_label, e_description, e_recur_freq, e_recur_type, e_recur_until, e_url = geteventfield(eventdetail)
1791a1796
>             eventitem['url'] = e_url
1978a1984,1993
>
>     regex_url = r"""
> (?P<reqfield>^[ ]+url::[ ]+)
> (
>     (?P<url>.*?)
>     \s*?
>     $
> )?
> """
>
2040a2056
>     pattern_url = re.compile(regex_url, re.UNICODE + re.MULTILINE + re.IGNORECASE + re.DOTALL + re.VERBOSE)
2312a2329,2340
>     ##################### retrieve URL for details
>     match = pattern_url.search(detail)
>
>     if match:
>         if match.group('url'):
>             url = match.group('url')
>         else:
>             errormsgcode('empty_url')
>             url = ''
>     else:
>         url = ''
>
2472c2500
<     return startdate, starttime, enddate, endtime, bgcolor, label, description, recur_freq, recur_type, recur_until
---
>     return startdate, starttime, enddate, endtime, bgcolor, label, description, recur_freq, recur_type, recur_until, url

-- AlexanderAgibalov 2010-06-18 12:43:25

v0.99a

I noticed two problems here on Debian running MoinMoin v1.9.3-1+squeeze1 with Python 2.6:

  1. the macro variable seems to lack a "form" attribute. I am not aware of the specific problematic circumstances. This exception is raised:

      File "/data/moin/sites/spontanplanung/plugin/macro/EventCalendar.py", line 271, in execute
        for item in macro.form.items():
    AttributeError: Macro instance has no attribute 'form'
  2. the function show_page_link is referenced without underscore (showpagelink)

The following patch fixes both problems. The first part is just a quick workaround for problem (1) - I don't know if this breaks anything. The second part is simple and foolproof, I guess.

--- EventCalendar.py.orig   2009-07-16 03:35:13.000000000 +0200
+++ EventCalendar.py    2012-06-21 22:03:43.000000000 +0200
@@ -267,12 +267,13 @@
     if args:
         args=request.getText(args)
 
-    for item in macro.form.items():
-        if not form_vals.has_key(item[0]):
-           try:
-                   form_vals[item[0]]=item[1][0]
-           except AttributeError:
-               pass
+    if hasattr(macro, "form"):
+        for item in macro.form.items():
+            if not form_vals.has_key(item[0]):
+               try:
+                       form_vals[item[0]]=item[1][0]
+               except AttributeError:
+                   pass
     
     # PROCESSING ACTIONS ----------------------------------------
     cal_action = form_vals.get('calaction', default_action)
@@ -692,7 +693,7 @@
 
     return html
         
-def show_page_list():
+def showpagelist():
     html = ""
     request = Globs.request
     formatter = Globs.formatter

-- Lars 2012-06-21 23:27:25

Bugs and Discssion Older than 0.99

MoinMoin: MacroMarket/EventCalendar (last edited 2013-01-26 09:56:51 by host70-2)