Attachment 'IncludeCalendarPage-moin12.py'
Download 1 """
2 MoinMoin - IncludeCalendarPage macro
3
4 version 1.0
5
6 (c) 2003 Charles Crichton, Oxford University Computing Laboratory
7 Charles.Crichton (in the domain) comlab.ox.ac.uk
8 Licensed under GNU GPL - see COPYING for details.
9
10
11 The date code is modified from code in MonthCalendar.py by Thomas Waldmann
12 Thanks! :-)
13
14 The argument matching code is modified from IncludePages.py by Michael Reinsch
15 Cheers!
16
17 I spotted the name Richard Jones in Include.py on which this ultimately relies.
18 Thankyou.
19
20 Obviously credit should also go to Jürgen Hermann for making this all possible!
21
22 ----
23
24 This simple macro allows the contents of a calendar page created
25 using the MonthCalendar.py macro. To be displayed on the current page.
26
27 I use it to display a week of calendar entries on my front page.
28
29 To install:
30 * Install the MonthCalendar.py and the IncludePages.py macros
31 * Save this macro in your macros directory
32
33 To use:
34
35 [[IncludeCalendarPage(pagepattern,level,0)]] - include todays page
36 [[IncludeCalendarPage(pagepattern,level,-1)]] - include yesterdays page
37 [[IncludeCalendarPage(pagepattern,level,1)]] - include tomorrows page
38 [[IncludeCalendarPage(pagepattern,level,365)]] - include next years page
39
40 * pagepattern: (A page pattern to which a date will be appended
41 * level: has the same meaning as in IncludePages.py macro.
42
43 Todays date is 2003-03-16. So the macro
44
45 [[IncludeCalendarPage(Calendar,2,0)]]
46
47 includes the contents of page Calendar/2003-03-16 down to level 2 headings.
48
49 [[IncludeCalendarPage(CharlieDiary,2,-1)]] - include CharlieDiary/2003-03-15
50
51 You get the idea!
52
53 $Id$
54 """
55
56 import calendar, cgi, time, re, string
57 from MoinMoin import config
58 from MoinMoin import wikiutil
59 import MoinMoin.macro.Include
60
61 _arg_dayoffset = r',\s*(?P<dayoffset>-?\d+)'
62 _arg_level = r',\s*(?P<level>\d+)'
63 _args_re_pattern = r'^(?P<pattern>[^,]+)(%s)(%s)$' % (_arg_level, _arg_dayoffset)
64 #_args_re_pattern = '^(?P<pattern>[^,]+)$'
65
66 def execute(macro, text, args_re=re.compile(_args_re_pattern)):
67 # parse and check arguments
68 args = args_re.match(text)
69 #return ('<p><string class="error">%s</string></p>') % (_args_re_pattern,)
70 if not args:
71 return ('<p><strong class="error">%s</strong></p>' %
72 ('Invalid include calendar page arguments "%s"!')) % (text,)
73
74 # get the arguments
75 pattern = args.group('pattern')
76 dayoffset = int(args.group('dayoffset'))
77
78 # There are 86400 seconds in a day.
79 datetofind = time.time() + dayoffset * 86400
80 (year,month,day,h,m,s,wd,yd,ds) = time.localtime(datetofind)
81
82 params = '%s/%d-%02d-%02d' % (pattern, year, month, day)
83
84 return MoinMoin.macro.Include.execute(macro,params)
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.