1
# -*- coding: iso-8859-1 -*-
5
This macro is used to show the cumulative hits of the wikipage where the Macro is called from.
6
Optionally you could count how much this page or all pages were changed or viewed.
8
<<Hits([all=(0,1)],[event_type=(VIEWPAGE,SAVEPAGE)>>
10
all: if set to 1/True/yes then cumulative hits over all wiki pages is returned.
11
Default is 0/False/no.
12
filter: if set to SAVEPAGE then the saved pages are counted. Default is VIEWPAGE.
14
@copyright: 2004-2008 MoinMoin:ReimarBauer,
16
@license: GNU GPL, see COPYING for details.
18
Dependencies = ['time'] # do not cache
20
from MoinMoin.stats import hitcounts
22
def macro_Hits(macro, all=False, event_type=(u'VIEWPAGE', u'SAVEPAGE')):
23
request = macro.request
24
pagename = macro.formatter.page.page_name
27
cache_days, cache_views, cache_edits = hitcounts.get_data(pagename, request, filterpage=None)
29
cache_days, cache_views, cache_edits = hitcounts.get_data(pagename, request, filterpage=pagename)
31
if event_type == u'VIEWPAGE':
32
return u'%d' % sum(cache_views)
34
return u'%d' % sum(cache_edits)