Attachment 'date+verbatim-macro.patch'
Download 1 diff -r 5208abaee26d MoinMoin/macro/Date.py
2 --- a/MoinMoin/macro/Date.py Sun Oct 31 01:29:15 2010 +0200
3 +++ b/MoinMoin/macro/Date.py Mon Nov 22 00:20:24 2010 -0800
4 @@ -6,8 +6,9 @@
5 @copyright: 2008-2010 MoinMoin:ThomasWaldmann
6 @license: GNU GPL, see COPYING for details
7 """
8
9 +import datetime
10 import time
11
12 from flask import flaskg
13 from flaskext.babel import format_date
14 @@ -22,9 +23,9 @@
15 float/int UNIX timestamp
16 @returns: UNIX timestamp (UTC)
17 """
18 if args is None:
19 - tm = time.time() # always UTC
20 + tm = datetime.datetime.utcnow() # always UTC
21 elif (len(args) >= 19 and args[4] == '-' and args[7] == '-' and
22 args[10] == 'T' and args[13] == ':' and args[16] == ':'):
23 # we ignore any time zone offsets here, assume UTC,
24 # and accept (and ignore) any trailing stuff
25 @@ -39,26 +40,28 @@
26 tzh, tzm = int(tz[1:3]), int(tz[3:])
27 tzoffset = (tzh * 60 + tzm) * 60
28 if sign == '-':
29 tzoffset = -tzoffset
30 - tm = year, month, day, hour, minute, second, 0, 0, 0
31 + tm = datetime.datetime(year, month, day, hour, minute, second)
32 except ValueError, err:
33 raise ValueError("Bad timestamp %r: %s" % (args, err))
34 # as mktime wants a localtime argument (but we only have UTC),
35 # we adjust by our local timezone's offset
36 try:
37 - tm = time.mktime(tm) - time.timezone - tzoffset
38 + offset = datetime.timedelta(seconds=(time.timezone - tzoffset))
39 + tm = tm - offset
40 except (OverflowError, ValueError):
41 - tm = 0 # incorrect, but we avoid an ugly backtrace
42 + tm = (0,0,0,0,0,0) # incorrect, but we avoid an ugly backtrace
43 else:
44 # try raw seconds since epoch in UTC
45 try:
46 tm = float(args)
47 - except ValueError, err:
48 + tm = datetime.datetime.fromtimestamp(tm)
49 + except (ValueError, TypeError), err:
50 raise ValueError("Bad timestamp %r: %s" % (args, err))
51 return tm
52
53 class Macro(MacroDateTimeBase):
54 - def macro(self, stamp=None):
55 + def macro(self,content, arguments, page_url, alternative):
56 + stamp = arguments[0]
57 tm = self.parse_time(stamp)
58 return format_date(tm)
59 -
60 diff -r 5208abaee26d MoinMoin/macro/Verbatim.py
61 --- a/MoinMoin/macro/Verbatim.py Sun Oct 31 01:29:15 2010 +0200
62 +++ b/MoinMoin/macro/Verbatim.py Mon Nov 22 00:20:24 2010 -0800
63 @@ -8,7 +8,7 @@
64
65 from MoinMoin.macro._base import MacroInlineBase
66
67 class Macro(MacroInlineBase):
68 - def macro(self, text=u''):
69 - return text
70 + def macro(self,content, arguments, page_url, alternative):
71 + return u" ".join(arguments.values())
72
73 diff -r 5208abaee26d MoinMoin/macro/_base.py
74 --- a/MoinMoin/macro/_base.py Sun Oct 31 01:29:15 2010 +0200
75 +++ b/MoinMoin/macro/_base.py Mon Nov 22 00:20:24 2010 -0800
76 @@ -15,11 +15,8 @@
77
78 # The output of a immutable macro only depends on the arguments and the content
79 immutable = False
80
81 - def __init__(self, request):
82 - self.request = request
83 -
84 def __call__(self, content, arguments, page_url, alternative, context_block):
85 raise NotImplementedError
86
87 class MacroBlockBase(MacroBase):
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.