On 3/3/2011 7:38 AM, Masopust, Christian wrote:
On 2/28/2011 10:13 AM, Christian Boos wrote:
On 2/28/2011 9:26 AM, Masopust, Christian wrote:
Hi all,
I'm maintaining several trac-instances (one code-base)
for different projects here
on my server. Everytime when maintenance has to be done
I've to write mails to
project-admins, members....
What I would like to have would be a plugin that shows something
like a "motd"
when a user opens trac (any page). This motd should, in
it's simpiest form, come
from a text-file and just inform the user about some
upcoming maintenance.
Any idea if such a plugin exists?
No idea, but sounds useful and should be *very* easy to do
(hint: request post-processor and add_info).
Anyone's up for the challenge of the smallest (useful) Trac
plugin ever? ;-)
9 lines to beat, the path to the motd file should be
configurable, TracDev/CodingStyle not mandatory ;-)
Hm, so nobody managed to make it in less than 9 lines, ... or nobody
tried?
Ok, tomorrow I'll post my solution, then...
-- Christian
Hello Christian,
not in less then 9 lines, but you can check
http://trac-hacks.org/wiki/MotdPlugin ...
it's my first plugin, so don't blame me on that, but at least it works here for
me :-))
Hey, that looks great! And certainly more full featured than my
9-liners ;-)
from trac import config, core, web
class MotdPlugin(core.Component):
core.implements(web.api.IRequestFilter)
motd_file = config.PathOption('motd', 'file', 'trac.motd')
def pre_process_request(self, req, handler): return handler
def post_process_request(self, req, template, data, content_type):
try: web.chrome.add_notice(req, file(self.motd_file).read())
except: pass
return template, data, content_type
-- Christian
--
You received this message because you are subscribed to the Google Groups "Trac
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en.