diff MoinMoin/action/links.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 8a750c0d229a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/action/links.py	Thu Sep 22 15:09:50 2005 +0000
@@ -0,0 +1,63 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - "links" action
+
+    Generate a link database like MeatBall:LinkDatabase.
+
+    @copyright: 2001 by Jürgen Hermann <jh@web.de>
+    @license: GNU GPL, see COPYING for details.
+"""
+
+from MoinMoin import config, wikiutil
+from MoinMoin.util import MoinMoinNoFooter
+
+
+def execute(pagename, request):
+    _ = request.getText
+    form = request.form
+
+    # get the MIME type
+    if form.has_key('mimetype'):
+        mimetype = form['mimetype'][0]
+    else:
+        mimetype = "text/html"
+
+    request.http_headers(["Content-Type: %s; charset=%s" % (mimetype,config.charset)])
+
+    if mimetype == "text/html":
+        wikiutil.send_title(request,
+                            _('Full Link List for "%s"') % request.cfg.sitename)
+        request.write('<pre>')
+
+    # Get page dict readable by current user
+    pages = request.rootpage.getPageDict()
+    pagelist = pages.keys()
+    pagelist.sort()
+
+    for name in pagelist:
+        if mimetype == "text/html":
+            request.write(pages[name].link_to(request))
+        else:
+            _emit(request, name)
+        for link in pages[name].getPageLinks(request):
+            request.write(" ")
+            if mimetype == "text/html":
+                if pages.has_key(link):
+                    request.write(pages[link].link_to(request))
+                else:
+                    _emit(request, link)
+            else:
+                _emit(request, link)
+        request.write('\n')
+
+    if mimetype == "text/html":
+        request.write('</pre>')
+        wikiutil.send_footer(request, pagename, editable=0, showactions=0, form=form)
+    else:
+        raise MoinMoinNoFooter
+
+def _emit(request, pagename):
+    """ Send pagename, encode it if it contains spaces
+    """
+    request.write(wikiutil.quoteWikinameURL(pagename))
+