Back to index

moin  1.9.0~rc2
links.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - "links" action
00004 
00005     Generate a link database like MeatBall:LinkDatabase.
00006 
00007     @copyright: 2001 Juergen Hermann <jh@web.de>
00008     @license: GNU GPL, see COPYING for details.
00009 """
00010 from MoinMoin import config, wikiutil
00011 
00012 def execute(pagename, request):
00013     _ = request.getText
00014     # get the MIME type
00015     mimetype = request.values.get('mimetype', 'text/html')
00016     request.mimetype = mimetype
00017 
00018     if mimetype == "text/html":
00019         request.theme.send_title(_('Full Link List for "%s"') % request.cfg.sitename)
00020         request.write('<pre>')
00021 
00022     # Get page dict readable by current user
00023     pages = request.rootpage.getPageDict()
00024     pagelist = pages.keys()
00025     pagelist.sort()
00026 
00027     for name in pagelist:
00028         if mimetype == "text/html":
00029             request.write(pages[name].link_to(request))
00030         else:
00031             _emit(request, name)
00032         for link in pages[name].getPageLinks(request):
00033             request.write(" ")
00034             if mimetype == "text/html":
00035                 if link in pages:
00036                     request.write(pages[link].link_to(request))
00037                 else:
00038                     _emit(request, link)
00039             else:
00040                 _emit(request, link)
00041         request.write('\n')
00042 
00043     if mimetype == "text/html":
00044         request.write('</pre>')
00045         request.theme.send_footer(pagename)
00046         request.theme.send_closing_html()
00047 
00048 def _emit(request, pagename):
00049     """ Send pagename, encode it if it contains spaces
00050     """
00051     request.write(wikiutil.quoteWikinameURL(pagename))
00052