changeset 871:8ad0dad8c515

added google sitemap action, missing file (ported from 1.5)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 22 Jun 2006 22:29:51 +0200
parents 1b9748f84aea
children b0f7ec792299
files MoinMoin/action/sitemap.py
diffstat 1 files changed, 41 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/action/sitemap.py	Thu Jun 22 22:29:51 2006 +0200
@@ -0,0 +1,41 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - "sitemap" action
+
+    Generate a URL list of all your pages (using google's sitemap XML format).
+
+    @copyright: 2006 by Thomas Waldmann, MoinMoin:ThomasWaldmann
+    @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
+
+    mimetype = "text/xml"
+
+    base = request.getBaseURL()
+
+    request.http_headers(["Content-Type: %s; charset=%s" % (mimetype, config.charset)])
+
+    request.write("""<?xml version="1.0" encoding="UTF-8"?>\r\n"""
+                  """<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">\r\n""")
+
+    request.write("<url><loc>%s/</loc></url>\r\n" % (base,))
+
+    # Get page dict readable by current user
+    pages = request.rootpage.getPageDict()
+    pagelist = pages.keys()
+    pagelist.sort()
+
+    for name in pagelist:
+        url = pages[name].url(request)
+        request.write("<url><loc>%s%s</loc></url>\r\n" % (base, url))
+
+    request.write("""</urlset>\r\n""")
+
+    raise MoinMoinNoFooter
+