Back to index

moin  1.9.0~rc2
PageSize.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - PageSize Macro
00004 
00005     @copyright: 2002 Juergen Hermann <jh@web.de>
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 
00009 Dependencies = ["pages"]
00010 
00011 def macro_PageSize(macro):
00012     if macro.request.isSpiderAgent: # reduce bot cpu usage
00013         return ''
00014 
00015     # get list of pages and their objects
00016     pages = macro.request.rootpage.getPageDict()
00017 
00018     # get sizes and sort them
00019     sizes = []
00020     for name, page in pages.items():
00021         sizes.append((page.size(), page))
00022     sizes.sort()
00023     sizes.reverse()
00024 
00025     # format list
00026     result = []
00027     result.append(macro.formatter.number_list(1))
00028     for size, page in sizes:
00029         result.append(macro.formatter.listitem(1))
00030         result.append(macro.formatter.code(1))
00031         result.append(("%6d" % size).replace(" ", "&nbsp;") + " ")
00032         result.append(macro.formatter.code(0))
00033         result.append(macro.formatter.pagelink(1, page.page_name, generated=1))
00034         result.append(macro.formatter.text(page.page_name))
00035         result.append(macro.formatter.pagelink(0, page.page_name))
00036         result.append(macro.formatter.listitem(0))
00037     result.append(macro.formatter.number_list(0))
00038 
00039     return ''.join(result)
00040