comparison MoinMoin/macro/OrphanedPages.py @ 0:77665d8e2254

tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0 (automatically generated log message) imported from: moin--main--1.5--base-0
author Thomas Waldmann <tw-public@gmx.de>
date Thu, 22 Sep 2005 15:09:50 +0000
parents
children 17ab8fe4a94b
comparison
equal deleted inserted replaced
-1:000000000000 0:77665d8e2254
1 # -*- coding: iso-8859-1 -*-
2 """
3 MoinMoin - OrphanedPages Macro
4
5 @copyright: 2001 by Jürgen Hermann <jh@web.de>
6 @license: GNU GPL, see COPYING for details.
7 """
8
9 Dependencies = ["pages"]
10
11 def execute(macro, args):
12 _ = macro.request.getText
13
14 if macro.request.mode_getpagelinks: # prevent recursion
15 return ''
16
17 # delete all linked pages from a dict of all pages
18 pages = macro.request.rootpage.getPageDict()
19 orphaned = {}
20 orphaned.update(pages)
21 for page in pages.values():
22 links = page.getPageLinks(macro.request)
23 for link in links:
24 if orphaned.has_key(link):
25 del orphaned[link]
26
27 # check for the extreme case
28 if not orphaned:
29 return "<p>%s</p>" % _("No orphaned pages in this wiki.")
30
31 # return a list of page links
32 orphanednames = orphaned.keys()
33 orphanednames.sort()
34 result = []
35 result.append(macro.formatter.number_list(1))
36 for name in orphanednames:
37 if not name: continue
38 result.append(macro.formatter.listitem(1))
39 result.append(macro.formatter.pagelink(1, name, generated=1))
40 result.append(macro.formatter.text(name))
41 result.append(macro.formatter.pagelink(0, name))
42 result.append(macro.formatter.listitem(0))
43 result.append(macro.formatter.number_list(0))
44
45 return ''.join(result)
46