my modifications to includepages make included calendar pages have the day of the week appended to the end of the title. this will work with both regular calendars and my annual calendars
""" MoinMoin - IncludePages macro Copyright (c) 2003 by Jun Hu <j.hu@tue.nl> Copyright (c) 2002 by Michael Reinsch <mr@uue.org> All rights reserved, see COPYING for details. Code based on the MoinMoin PageList macro Copyright (c) 2000, 2001, 2002 by J¨¹rgen Hermann <jh@web.de> This macro includes the formatted content of the given pages, following recursive includes if encountered. Cycles are detected! It uses the MoinMoin Include macro which does the real work. Usage: [[IncludePages(pagepattern,level, sort=ascending|descending, items=n)]] pagepattern Pattern of the page(s) to include level Level (1..5) of the generated heading (optional) sort Sorting order (optional). items Maximum number of pages to include. The headings for the included pages will be generated from the page names Examples: [[IncludePages(FooBar/20.*)]] -- includes all pages which start with FooBar/20 this is usefull in combination with the MonthCalendar macro [[IncludePages(FooBar/20.*, 2)]] -- set level to 2 (default is 1) [[IncludePages(FooBar/20.*, 2, sort=descending]] -- reverse the ordering (default is ascending) [[IncludePages(FooBar/20.*, 2, sort=descending, items=1]] -- Only the last item will be included. $Id$ """ import re #from MoinMoin import user from MoinMoin import config from MoinMoin import wikiutil #from MoinMoin.i18n import _ import MoinMoin.macro.Include import time, calendar _arg_level = r',\s*(?P<level>\d+)' _arg_sort = r'(,\s*sort=(?P<sort>(ascending|descending)))?' _arg_items = r'(,\s*items=(?P<items>\d+))?' _args_re_pattern = r'^(?P<pattern>[^,]+)((%s)?%s%s)?$' % (_arg_level,_arg_sort,_arg_items) def execute(macro, text, args_re=re.compile(_args_re_pattern)): ret = '' # parse and check arguments args = args_re.match(text) if not args: return ('<p><strong class="error">%s</strong></p>' % _('Invalid include arguments "%s"!')) % (text,) # get the pages inc_pattern = args.group('pattern') if args.group('level'): level = int(args.group('level')) else: level = 1 try: needle_re = re.compile(inc_pattern, re.IGNORECASE) except re.error, e: return ('<p><strong class="error">%s</strong></p>' % _("ERROR in regex '%s'") % (inc_pattern,), e) all_pages = wikiutil.getPageList(config.text_dir) hits = filter(needle_re.search, all_pages) hits.sort() sort_dir = args.group('sort') if sort_dir == 'descending': hits.reverse() max_items = args.group('items') if max_items: hits = hits[:int(max_items)] calcheck_pattern = r'^(.*?((?P<year>\d\d\d\d)-)?(?P<month>\d\d)-(?P<day>\d\d)$)' calcheck = re.compile(calcheck_pattern) days =[ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ] for inc_name in hits: cal = calcheck.match(inc_name) #print inc_name if not cal: inc_header = inc_name else: if cal.group('year') is None: year = time.localtime()[0] else: year = int(cal.group('year')) month = int(cal.group('month')) day = int(cal.group('day')) inc_header = inc_name + " " + days[calendar.weekday(year, month, day)] params = '%s,"%s",%s' % (inc_name,inc_header, level) #ret = ret +"<p>"+ MoinMoin.macro.Include.execute(macro, params) +"\n" ret = ret + MoinMoin.macro.Include.execute(macro, params) +"\n" # return include text return ret