[Moin-devel] CVS: MoinMoin/macro EventStats.py,NONE,1.1
J?rgen Hermann
jhermann at users.sourceforge.net
Fri Feb 1 14:54:11 EST 2002
Update of /cvsroot/moin/MoinMoin/macro
In directory usw-pr-cvs1:/tmp/cvs-serv11576/macro
Added Files:
EventStats.py
Log Message:
EventStats macro and chart action
--- NEW FILE: EventStats.py ---
"""
MoinMoin - EventStats Macro
Copyright (c) 2002 by Jürgen Hermann <jh at web.de>
All rights reserved, see COPYING for details.
This macro creates charts from the data in "event.log".
$Id: EventStats.py,v 1.1 2002/02/01 22:53:41 jhermann Exp $
"""
# Imports
import string
from MoinMoin import config, webapi
from MoinMoin.Page import Page
from MoinMoin.i18n import _
width = 480
height = 300
def execute(macro, args, **kw):
page = Page(macro.formatter.page.page_name)
result = []
result.append('<img src="%s" width="%d" height="%d" border="1">' % (
page.url("action=chart¯o=EventStats"), width, height))
return string.join(result, '')
def chart(pagename, form):
import sys, shutil, cStringIO
from MoinMoin.stats import chart
image = cStringIO.StringIO()
c = chart.Chart()
c.addData(chart.ChartData(range(20), color='green'))
c.option(
title = 'Page hits',
xtitle = 'date',
ytitle = '# of hits'
)
c.draw(c.GDC_LINE, (width, height), image)
# send HTTP headers
headers = [
"Content-Type: image/gif",
"Content-Length: %d" % len(image.getvalue()),
]
webapi.http_headers(headers)
# copy the image
image.reset()
shutil.copyfileobj(image, sys.stdout, 8192)
sys.exit(0)
More information about the Moin-devel
mailing list