annotate MoinMoin/macro/MonthCalendar.py @ 3011:5913913a4dc0

MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 06 Jan 2008 19:18:19 +0100
parents 388204baf00f
children a739558ca3dc
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 MoinMoin - MonthCalendar Macro
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4 You can use this macro to put a month's calendar page on a Wiki page.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
5
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
6 The days are links to Wiki pages following this naming convention:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 BasePageName/year-month-day
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8
1926
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
9 @copyright: 2002-2007 MoinMoin:ThomasWaldmann
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1868
diff changeset
10 @license: GNU GPL, see COPYING for details.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
11
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12 Revisions:
2183
d133bf86ed58 MonthCalendar: fix wrong relative links
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1927
diff changeset
13 * first revision without a number (=1.0):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14 * was only online for a few hours and then replaced by 1.1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 * 1.1:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 * changed name to MonthCalendar to avoid conflict with "calendar" under case-insensitive OSes like Win32
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17 * days as subpages
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18 * basepage argument
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19 * change order of year/month argument
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
20 * browsing links to prev/next month/year
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21 * current limitation: you can only browse one calendar on the same
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 page/url, if you try to browse another calendar on the same page,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23 the first one jumps back to its original display
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 * show basepage in calendar header if basepage<>currentpage
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25 * 1.2:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
26 * minor fixes in argument parsing
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
27 * cosmetic fix for netscape, other cosmetic changes, changed css
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
28 * i18n support (weekday short names)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 * 1.3:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30 * fixes to run with MoinMoin 0.11, thanks to JuergenHermann
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31 * fix: withspace before "," allowed in argument list
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
32 * BasePage in calendar header (if present) is a link now
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
33 * more i18n
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
34 * HTML cleanup, generating code avoids bracketing errors
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
35 * colour cosmetics
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
36 * 1.4:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37 * new parameter for enabling fixed height of 6 "calendar weeks",
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
38 if you want to show a whole year's calendar, this just looks
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
39 better than having some months with 4, some with 5 and some with 6.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
40 * group calendaring functions:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
41 * you can give mutliple BasePages UserName1*UserName2*UserName3
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42 * first BasePage is considered "your" Basepage,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
43 used days are bright red
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44 * 2nd and all other BasePages are considered "others" BasePages
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45 and lead to an increasing green component the more "used" days
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46 the others have. So white gets greener and red gets more yellowish.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47 * in the head part of the calendar, you can click on each name
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 to get to the Page of the same name
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49 * colouring of my and others BasePage is done in a way to show
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
50 the colouring used in the calendar:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51 * others use green colouring (increasingly green if multiply used)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
52 * I use red colouring, which gets more and more yellowish as
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53 the day is used by more and more others, too
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
54 * 1.5:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55 * fixed username colouring when using a BasePage
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
56 * fixed navigation header of MonthCalendar not to get broken into
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
57 multiple lines
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
58 * fixed SubPage handling (please do not use relative SubPages like
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
59 /SubPage yet. Use MyName/SubPage.)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60 * 1.6:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
61 * syntactic cleanup
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62 * removed i18n compatibility for moin<1.1 or cvs<2003-06-10
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
63 * integrated Scott Chapman's changes:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
64 * Made it configurable for Sunday or Monday as the first day of the week.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
65 Search for "change here".
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
66 * Made it so that today is not only set to a seperate css style, but also boldfaced.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
67 Some browsers don't show the other css style (Netscape).
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
68 * Made it so weekend dates have different color.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
69 * 1.7:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
70 * added request parameter where needed
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
71 * 1.8:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
72 * some fixes for moin 1.2 (use this version ONLY if you run moin 1.2, too):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
73 * .value backtrace fixed when selecting next/prev month/year
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
74 * request param added to macro function
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
75 * 1.9:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
76 * adapted to moin 1.3
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
77 * 2.0:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
78 * integrated into moin 1.3
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
79 * added some nice JS (thanks to Klaus Knopper) to show nice mouseovers
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
80 showing a preview of the day page linked (use first level headlines
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
81 to make entries)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
82 * merged "common navigation" change of OliverGraf
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
83 * merged AnnualMonthlyCalendar change of JonathanDietrich
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
84 * 2.1:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
85 * fixed CSS for IE users
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
86 * fix javascript for IE4
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87 * do a correct calculation of "today" using user's timezone
479
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
88 * 2.2:
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
89 * added template argument for specifying an edit template for new pages
2513
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
90 * 2.3:
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
91 * adapted to moin 1.7 new macro parameter parsing
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
92
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
93 Usage:
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
94 <<MonthCalendar(BasePage,year,month,monthoffset,monthoffset2,height6)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
95
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
96 each parameter can be empty and then defaults to currentpage or currentdate or monthoffset=0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
97
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
98 Samples (paste that to one of your pages for a first try):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
99
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
100 Calendar of current month for current page:
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
101 <<MonthCalendar>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
102
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
103 Calendar of last month:
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
104 <<MonthCalendar(,,,-1)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
105
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
106 Calendar of next month:
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
107 <<MonthCalendar(,,,+1)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
108
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
109 Calendar of Page SampleUser, this years december:
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
110 <<MonthCalendar(SampleUser,,12)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
111
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
112 Calendar of current Page, this years december:
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
113 <<MonthCalendar(,,12)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
114
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
115 Calendar of December, 2001:
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
116 <<MonthCalendar(,2001,12)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
117
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
118 Calendar of the month two months after December, 2001
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
119 (maybe doesn't make much sense, but is possible)
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
120 <<MonthCalendar(,2001,12,+2)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
121
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
122 Calendar of year 2002 (every month padded to height of 6):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
123 ||||||Year 2002||
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
124 ||<<MonthCalendar(,2002,1,,,1)>>||<<MonthCalendar(,2002,2,,,1)>>||<<MonthCalendar(,2002,3,,,1)>>||
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
125 ||<<MonthCalendar(,2002,4,,,1)>>||<<MonthCalendar(,2002,5,,,1)>>||<<MonthCalendar(,2002,6,,,1)>>||
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
126 ||<<MonthCalendar(,2002,7,,,1)>>||<<MonthCalendar(,2002,8,,,1)>>||<<MonthCalendar(,2002,9,,,1)>>||
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
127 ||<<MonthCalendar(,2002,10,,,1)>>||<<MonthCalendar(,2002,11,,,1)>>||<<MonthCalendar(,2002,12,,,1)>>||
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
128
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
129 Current calendar of me, also showing entries of A and B:
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
130 <<MonthCalendar(MyPage*TestUserA*TestUserB)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
131
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
132 SubPage calendars:
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
133 <<MonthCalendar(MyName/CalPrivate)>>
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
134 <<MonthCalendar(MyName/CalBusiness)>>
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
135 <<MonthCalendar(MyName/CalBusiness*MyName/CalPrivate)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
136
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
137
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
138 Anniversary Calendars: (no year data)
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
139 <<MonthCalendar(Yearly,,,+1,,6,1)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
140
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2183
diff changeset
141 This creates calendars of the format Yearly/MM-DD
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2183
diff changeset
142 By leaving out the year, you can set birthdays, and anniversaries in this
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
143 calendar and not have to re-enter each year.
479
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
144
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
145 This creates a calendar which uses MonthCalendarTemplate for directly editing
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
146 nonexisting day pages:
2725
388204baf00f change [[macro]] to <<macro>> in all built-in markup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2513
diff changeset
147 <<MonthCalendar(,,,,,,MonthCalendarTemplate)>>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
148 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
149
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 625
diff changeset
150 Dependencies = ['namespace', 'time', ]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
151
1926
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
152 import re, calendar, time
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
153
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
154 from MoinMoin import wikiutil
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
155 from MoinMoin.Page import Page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
156
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
157 # The following line sets the calendar to have either Sunday or Monday as
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
158 # the first day of the week. Only SUNDAY or MONDAY (case sensitive) are
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
159 # valid here. All other values will not make good calendars.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
160 # If set to Sunday, the calendar is displayed at "March 2003" vs. "2003 / 3" also.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
161 # XXX change here ----------------vvvvvv
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
162 calendar.setfirstweekday(calendar.MONDAY)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
163
1926
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
164 def cliprgb(r, g, b):
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
165 """ clip r,g,b values into range 0..254 """
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
166 def clip(x):
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
167 """ clip x value into range 0..254 """
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
168 if x < 0:
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
169 x = 0
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
170 elif x > 254:
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
171 x = 254
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
172 return x
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
173 return clip(r), clip(g), clip(b)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
174
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
175 def yearmonthplusoffset(year, month, offset):
1926
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
176 """ calculate new year/month from year/month and offset """
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
177 month += offset
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
178 # handle offset and under/overflows - quick and dirty, yes!
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
179 while month < 1:
1926
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
180 month += 12
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
181 year -= 1
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
182 while month > 12:
1926
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
183 month -= 12
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
184 year += 1
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
185 return year, month
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
186
2513
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
187 def parseargs(request, args, defpagename, defyear, defmonth, defoffset, defoffset2, defheight6, defanniversary, deftemplate):
1926
8b676947238a MonthCalendar: some cosmetic changes, refactorings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
188 """ parse macro arguments """
2513
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
189 args = wikiutil.parse_quoted_separated(args, name_value=False)
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
190 args += [None] * 8 # fill up with None to trigger defaults
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
191 parmpagename, parmyear, parmmonth, parmoffset, parmoffset2, parmheight6, parmanniversary, parmtemplate = args[:8]
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
192 parmpagename = wikiutil.get_unicode(request, parmpagename, 'pagename', defpagename)
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
193 parmyear = wikiutil.get_int(request, parmyear, 'year', defyear)
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
194 parmmonth = wikiutil.get_int(request, parmmonth, 'month', defmonth)
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
195 parmoffset = wikiutil.get_int(request, parmoffset, 'offset', defoffset)
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
196 parmoffset2 = wikiutil.get_int(request, parmoffset2, 'offset2', defoffset2)
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
197 parmheight6 = wikiutil.get_bool(request, parmheight6, 'height6', defheight6)
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
198 parmanniversary = wikiutil.get_bool(request, parmanniversary, 'anniversary', defanniversary)
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
199 parmtemplate = wikiutil.get_unicode(request, parmtemplate, 'template', deftemplate)
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
200
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
201 # multiple pagenames separated by "*" - split into list of pagenames
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
202 parmpagename = re.split(r'\*', parmpagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
203
479
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
204 return parmpagename, parmyear, parmmonth, parmoffset, parmoffset2, parmheight6, parmanniversary, parmtemplate
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 625
diff changeset
205
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
206 def execute(macro, text):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
207 request = macro.request
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
208 formatter = macro.formatter
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
209 _ = request.getText
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
210
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
211 # return immediately if getting links for the current page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
212 if request.mode_getpagelinks:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
213 return ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
214
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
215 currentyear, currentmonth, currentday, h, m, s, wd, yd, ds = request.user.getTime(time.time())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
216 thispage = formatter.page.page_name
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
217 # does the url have calendar params (= somebody has clicked on prev/next links in calendar) ?
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1866
diff changeset
218 if 'calparms' in macro.form:
2513
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
219 has_calparms = 1 # yes!
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
220 text2 = macro.form['calparms'][0]
2513
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
221 try:
479
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
222 cparmpagename, cparmyear, cparmmonth, cparmoffset, cparmoffset2, cparmheight6, cparmanniversary, cparmtemplate = \
2513
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
223 parseargs(request, text2, thispage, currentyear, currentmonth, 0, 0, False, False, u'')
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
224 except (ValueError, TypeError), err:
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
225 return macro.format_error(err)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
226 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
227 has_calparms = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
228
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
229 if text is None: # macro call without parameters
2513
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
230 text = u''
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
231
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
232 # parse and check arguments
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
233 try:
479
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
234 parmpagename, parmyear, parmmonth, parmoffset, parmoffset2, parmheight6, anniversary, parmtemplate = \
2513
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
235 parseargs(request, text, thispage, currentyear, currentmonth, 0, 0, False, False, u'')
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
236 except (ValueError, TypeError), err:
6de0e14591f7 macro.format_error to format what a macro shows in case of ValueError/TypeError happening, refactor MonthCalendar to use new arg parsing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2286
diff changeset
237 return macro.format_error(err)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
238
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
239 # does url have calendar params and is THIS the right calendar to modify (we can have multiple
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
240 # calendars on the same page)?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
241 #if has_calparms and (cparmpagename,cparmyear,cparmmonth,cparmoffset) == (parmpagename,parmyear,parmmonth,parmoffset):
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 625
diff changeset
242
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
243 # move all calendars when using the navigation:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
244 if has_calparms and cparmpagename == parmpagename:
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 625
diff changeset
245 year, month = yearmonthplusoffset(parmyear, parmmonth, parmoffset + cparmoffset2)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
246 parmoffset2 = cparmoffset2
479
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
247 parmtemplate = cparmtemplate
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
248 else:
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 625
diff changeset
249 year, month = yearmonthplusoffset(parmyear, parmmonth, parmoffset)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
250
3011
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
251 if request.isSpiderAgent and abs(currentyear - year) > 1:
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
252 return '' # this is a bot and it didn't follow the rules (see below)
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
253 if currentyear == year:
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
254 attrs = {}
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
255 else:
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
256 attrs = {'rel': 'nofollow' } # otherwise even well-behaved bots will index forever
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
257
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
258 # get the calendar
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
259 monthcal = calendar.monthcalendar(year, month)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
260
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
261 # european / US differences
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 625
diff changeset
262 months = ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
263 # Set things up for Monday or Sunday as the first day of the week
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
264 if calendar.firstweekday() == calendar.MONDAY:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
265 wkend = (5, 6)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
266 wkdays = ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
267 if calendar.firstweekday() == calendar.SUNDAY:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
268 wkend = (0, 6)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
269 wkdays = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
270
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
271 colorstep = 85
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
272 p = Page(request, thispage)
1866
0194beaf511e reduce reduce, filter and map usage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1816
diff changeset
273 qpagenames = '*'.join([wikiutil.quoteWikinameURL(pn) for pn in parmpagename])
479
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
274 qtemplate = wikiutil.quoteWikinameURL(parmtemplate)
625
42958bb7e500 fix MonthCalendar macro for non-ascii page names, update CHANGES
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 515
diff changeset
275 querystr = "calparms=%%s,%d,%d,%d,%%d,%%s" % (parmyear, parmmonth, parmoffset)
2183
d133bf86ed58 MonthCalendar: fix wrong relative links
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1927
diff changeset
276 prevlink = p.url(request, querystr % (qpagenames, parmoffset2 - 1, qtemplate), relative=False)
d133bf86ed58 MonthCalendar: fix wrong relative links
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1927
diff changeset
277 nextlink = p.url(request, querystr % (qpagenames, parmoffset2 + 1, qtemplate), relative=False)
d133bf86ed58 MonthCalendar: fix wrong relative links
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1927
diff changeset
278 prevylink = p.url(request, querystr % (qpagenames, parmoffset2 - 12, qtemplate), relative=False)
d133bf86ed58 MonthCalendar: fix wrong relative links
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1927
diff changeset
279 nextylink = p.url(request, querystr % (qpagenames, parmoffset2 + 12, qtemplate), relative=False)
3011
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
280
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
281 prevmonth = formatter.url(1, prevlink, 'cal-link', **attrs) + '&lt;' + formatter.url(0)
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
282 nextmonth = formatter.url(1, nextlink, 'cal-link', **attrs) + '&gt;' + formatter.url(0)
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
283 prevyear = formatter.url(1, prevylink, 'cal-link', **attrs) + '&lt;&lt;' + formatter.url(0)
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
284 nextyear = formatter.url(1, nextylink, 'cal-link', **attrs) + '&gt;&gt;' + formatter.url(0)
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 625
diff changeset
285
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
286 if parmpagename != [thispage]:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
287 pagelinks = ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
288 r, g, b = (255, 0, 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
289 l = len(parmpagename[0])
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
290 steps = len(parmpagename)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
291 maxsteps = (255 / colorstep)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
292 if steps > maxsteps:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
293 steps = maxsteps
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
294 chstep = int(l / steps)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
295 st = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
296 while st < l:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
297 ch = parmpagename[0][st:st+chstep]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
298 r, g, b = cliprgb(r, g, b)
1382
c3c8ff25e979 make more use of formatter / link_to for link rendering
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
299 link = Page(request, parmpagename[0]).link_to(request, ch,
3011
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
300 rel='nofollow',
1382
c3c8ff25e979 make more use of formatter / link_to for link rendering
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
301 style='background-color:#%02x%02x%02x;color:#000000;text-decoration:none' % (r, g, b))
c3c8ff25e979 make more use of formatter / link_to for link rendering
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
302 pagelinks = pagelinks + link
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
303 r, g, b = (r, g+colorstep, b)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
304 st = st + chstep
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
305 r, g, b = (255-colorstep, 255, 255-colorstep)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
306 for page in parmpagename[1:]:
1382
c3c8ff25e979 make more use of formatter / link_to for link rendering
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
307 link = Page(request, page).link_to(request, page,
3011
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
308 rel='nofollow',
1382
c3c8ff25e979 make more use of formatter / link_to for link rendering
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
309 style='background-color:#%02x%02x%02x;color:#000000;text-decoration:none' % (r, g, b))
c3c8ff25e979 make more use of formatter / link_to for link rendering
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1339
diff changeset
310 pagelinks = pagelinks + '*' + link
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
311 showpagename = ' %s<BR>\n' % pagelinks
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
312 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
313 showpagename = ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
314 if calendar.firstweekday() == calendar.SUNDAY:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
315 resth1 = ' <th colspan="7" class="cal-header">\n' \
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
316 '%s' \
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
317 ' %s&nbsp;%s&nbsp;<b>&nbsp;%s&nbsp;%s</b>&nbsp;%s\n&nbsp;%s\n' \
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
318 ' </th>\n' % (showpagename, prevyear, prevmonth, months[month-1], str(year), nextmonth, nextyear)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
319 if calendar.firstweekday() == calendar.MONDAY:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
320 resth1 = ' <th colspan="7" class="cal-header">\n' \
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
321 '%s' \
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
322 ' %s&nbsp;%s&nbsp;<b>&nbsp;%s&nbsp;/&nbsp;%s</b>&nbsp;%s\n&nbsp;%s\n' \
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
323 ' </th>\n' % (showpagename, prevyear, prevmonth, str(year), month, nextmonth, nextyear)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
324 restr1 = ' <tr>\n%s </tr>\n' % resth1
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
325
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
326 r7 = range(7)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
327 restd2 = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
328 for wkday in r7:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
329 wday = _(wkdays[wkday])
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
330 if wkday in wkend:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
331 cssday = "cal-weekend"
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
332 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
333 cssday = "cal-workday"
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
334 restd2.append(' <td class="%s" width="14%%">%s</td>\n' % (cssday, wday))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
335 restr2 = ' <tr>\n%s </tr>\n' % "".join(restd2)
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 625
diff changeset
336
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
337 if parmheight6:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
338 while len(monthcal) < 6:
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 625
diff changeset
339 monthcal = monthcal + [[0, 0, 0, 0, 0, 0, 0]]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
340
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
341 maketip_js = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
342 restrn = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
343 for week in monthcal:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
344 restdn = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
345 for wkday in r7:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
346 day = week[wkday]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
347 if not day:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
348 restdn.append(' <td class="cal-invalidday">&nbsp;</td>\n')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
349 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
350 page = parmpagename[0]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
351 if anniversary:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
352 link = "%s/%02d-%02d" % (page, month, day)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
353 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
354 link = "%s/%4d-%02d-%02d" % (page, year, month, day)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
355 daypage = Page(request, link)
1927
7803b0e56a0c MonthCalendar: ACL security fix (ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1926
diff changeset
356 if daypage.exists() and request.user.may.read(link):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
357 csslink = "cal-usedday"
479
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
358 query = {}
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
359 r, g, b, u = (255, 0, 0, 1)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
360 daycontent = daypage.get_raw_body()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
361 header1_re = re.compile(r'^\s*=\s(.*)\s=$', re.MULTILINE) # re.UNICODE
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
362 titletext = []
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
363 for match in header1_re.finditer(daycontent):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
364 if match:
107
fc0f131e591d fixed MonthCalendar tooltip escaping
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
365 title = match.group(1)
950
4eb66637ccd0 whitespace-only cleanup, small style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 625
diff changeset
366 title = wikiutil.escape(title).replace("'", "\\'")
107
fc0f131e591d fixed MonthCalendar tooltip escaping
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
367 titletext.append(title)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
368 tipname = link
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
369 tiptitle = link
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
370 tiptext = '<br>'.join(titletext)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
371 maketip_js.append("maketip('%s','%s','%s');" % (tipname, tiptitle, tiptext))
3011
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
372 attrs = {'onMouseOver': "tip('%s')" % tipname,
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
373 'onMouseOut': "untip()"}
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
374 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
375 csslink = "cal-emptyday"
479
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
376 if parmtemplate:
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
377 query = {'action': 'edit', 'template': parmtemplate}
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
378 else:
9a32bd1332af MonthCalendar can take an additional template page argument for creating new day pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 125
diff changeset
379 query = {}
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
380 r, g, b, u = (255, 255, 255, 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
381 if wkday in wkend:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
382 csslink = "cal-weekend"
3011
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
383 attrs = {'rel': 'nofollow'}
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
384 for otherpage in parmpagename[1:]:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
385 otherlink = "%s/%4d-%02d-%02d" % (otherpage, year, month, day)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
386 otherdaypage = Page(request, otherlink)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
387 if otherdaypage.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
388 csslink = "cal-usedday"
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
389 if u == 0:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
390 r, g, b = (r-colorstep, g, b-colorstep)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
391 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
392 r, g, b = (r, g+colorstep, b)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
393 r, g, b = cliprgb(r, g, b)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
394 style = 'background-color:#%02x%02x%02x' % (r, g, b)
3011
5913913a4dc0 MonthCalendar: avoid even bad behaved bots reading more than current year +/- 1 in the calendar, rel=nofollow for links to nonexisting day pages (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2725
diff changeset
395 fmtlink = formatter.url(1, daypage.url(request, query, relative=False), csslink, **attrs) + str(day) + formatter.url(0)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
396 if day == currentday and month == currentmonth and year == currentyear:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
397 cssday = "cal-today"
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
398 fmtlink = "<b>%s</b>" % fmtlink # for browser with CSS probs
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
399 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
400 cssday = "cal-nottoday"
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
401 restdn.append(' <td style="%s" class="%s">%s</td>\n' % (style, cssday, fmtlink))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
402 restrn.append(' <tr>\n%s </tr>\n' % "".join(restdn))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
403
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
404 restable = '<table border="2" cellspacing="2" cellpadding="2">\n%s%s%s</table>\n'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
405 restable = restable % (restr1, restr2, "".join(restrn))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
406
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
407 result = """\
125
2e94b859f3ce moved MonthCalendar JS code to a file
Thomas Waldmann <tw@waldmann-edv.de>
parents: 110
diff changeset
408 <script language="JavaScript" type="text/javascript" src="%s/common/js/infobox.js"></script>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
409 <div id="infodiv" style="position:absolute; visibility:hidden; z-index:20; top:-999em; left:0px;"></div>
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
410 <script language="JavaScript" type="text/javascript">
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
411 <!--
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
412 %s
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
413 // -->
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
414 </script>
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
415 %s
1318
760002b5ffa3 use url_prefix_static = '/moin_static160' instead of url_prefix = '/wiki' to avoid user confusion and stale caches
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1001
diff changeset
416 """ % (request.cfg.url_prefix_static, "\n".join(maketip_js), restable)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
417 return formatter.rawHTML(result)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
418
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
419 # EOF
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
420