|
Revision 6326, 1.1 KB
(checked in by cboos, 12 months ago)
|
|
Follow-up to r6295: make the file revision string information global to the module.
Also enhances the plugins admin panel so that it can show that information.
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
LastChangedRevision HeadURL
|
| Line | |
|---|
| 1 | """Inserts the current time (in seconds) into the wiki page.""" |
|---|
| 2 | |
|---|
| 3 | revision = "$Rev$" |
|---|
| 4 | url = "$URL$" |
|---|
| 5 | |
|---|
| 6 | # |
|---|
| 7 | # The following shows the code for macro, old-style. |
|---|
| 8 | # |
|---|
| 9 | # The `execute` function serves no purpose other than to illustrate |
|---|
| 10 | # the example, it will not be used anymore. |
|---|
| 11 | # |
|---|
| 12 | # ---- (ignore in your own macro) ---- |
|---|
| 13 | # -- |
|---|
| 14 | import time # Trac before version 0.11 was using `time` module |
|---|
| 15 | |
|---|
| 16 | def execute(hdf, txt, env): |
|---|
| 17 | t = time.localtime() |
|---|
| 18 | return "<b>%s</b>" % time.strftime('%c', t) |
|---|
| 19 | # -- |
|---|
| 20 | # ---- (ignore in your own macro) ---- |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | # |
|---|
| 24 | # The following is the converted new-style macro |
|---|
| 25 | # |
|---|
| 26 | # ---- (reuse for your own macro) ---- |
|---|
| 27 | # -- |
|---|
| 28 | from datetime import datetime |
|---|
| 29 | # Note: since Trac 0.11, datetime objects are used internally |
|---|
| 30 | |
|---|
| 31 | from genshi.builder import tag |
|---|
| 32 | |
|---|
| 33 | from trac.util.datefmt import format_datetime, utc |
|---|
| 34 | from trac.wiki.macros import WikiMacroBase |
|---|
| 35 | |
|---|
| 36 | class TimestampMacro(WikiMacroBase): |
|---|
| 37 | """Inserts the current time (in seconds) into the wiki page.""" |
|---|
| 38 | |
|---|
| 39 | def expand_macro(self, formatter, name, args): |
|---|
| 40 | t = datetime.now(utc) |
|---|
| 41 | return tag.b(format_datetime(t, '%c')) |
|---|
| 42 | # -- |
|---|
| 43 | # ---- (reuse for your own macro) ---- |
|---|