Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.macro.OrphanedPages Namespace Reference

Functions

def macro_OrphanedPages

Variables

list Dependencies = ["pages"]

Function Documentation

Definition at line 11 of file OrphanedPages.py.

00011 
00012 def macro_OrphanedPages(macro):
00013     _ = macro.request.getText
00014 
00015     if macro.request.mode_getpagelinks: # prevent recursion
00016         return ''
00017     if macro.request.isSpiderAgent: # reduce bot cpu usage
00018         return ''
00019 
00020     # delete all linked pages from a dict of all pages
00021     pages = macro.request.rootpage.getPageDict()
00022     orphaned = {}
00023     orphaned.update(pages)
00024     for page in pages.values():
00025         links = page.getPageLinks(macro.request)
00026         for link in links:
00027             if link in orphaned:
00028                 del orphaned[link]
00029 
00030     result = []
00031     f = macro.formatter
00032     if not orphaned:
00033         result.append(f.paragraph(1))
00034         result.append(f.text(_("No orphaned pages in this wiki.")))
00035         result.append(f.paragraph(0))
00036     else:
00037         # return a list of page links
00038         orphanednames = orphaned.keys()
00039         orphanednames.sort()
00040         result.append(f.number_list(1))
00041         for name in orphanednames:
00042             if not name:
00043                 continue
00044             result.append(f.listitem(1))
00045             result.append(f.pagelink(1, name, generated=1))
00046             result.append(f.text(name))
00047             result.append(f.pagelink(0, name))
00048             result.append(f.listitem(0))
00049         result.append(f.number_list(0))
00050 
00051     return ''.join(result)
00052 

Variable Documentation

Definition at line 9 of file OrphanedPages.py.