1.1 --- a/README.txt Thu Oct 17 17:52:58 2013 +0200
1.2 +++ b/README.txt Thu Oct 17 18:37:21 2013 +0200
1.3 @@ -151,6 +151,23 @@
1.4 or it should be placed in a different location and the MAPPING_ID_TO_PAGE
1.5 variable changed in the script to refer to this different location.
1.6
1.7 +Supporting Confluence Action URLs
1.8 +---------------------------------
1.9 +
1.10 +Besides the "viewpage" action mapping identifiers to pages (covered by the
1.11 +mapping described above), some other action URLs may be used in wiki content
1.12 +and must either be translated or supported using redirects. Since external
1.13 +sites may also employ such actions, a redirect strategy perhaps makes more
1.14 +sense. To support this, the following resources are involved:
1.15 +
1.16 + * scripts/search.py
1.17 + * config/mailmanwiki-redirect
1.18 +
1.19 +The latter configuration file is also involved in identifier-to-page mapping,
1.20 +but in this case it causes requests to the "dosearchsite" action to be
1.21 +directed to the search.py script, which in turn redirects the request in a
1.22 +suitable form to the MoinMoin "fullsearch" action.
1.23 +
1.24 Identifying and Migrating Users
1.25 -------------------------------
1.26
2.1 --- a/config/mailmanwiki-redirect Thu Oct 17 17:52:58 2013 +0200
2.2 +++ b/config/mailmanwiki-redirect Thu Oct 17 18:37:21 2013 +0200
2.3 @@ -1,2 +1,3 @@
2.4 ScriptAlias /x "/var/www/mmwiki-scripts/redirect.py"
2.5 ScriptAlias /pages/viewpage.action "/var/www/mmwiki-scripts/redirect.py"
2.6 +ScriptAlias /dosearchsite.action "/var/www/mmwiki-scripts/search.py"
3.1 --- a/config/mailmanwiki-redirect-htaccess Thu Oct 17 17:52:58 2013 +0200
3.2 +++ b/config/mailmanwiki-redirect-htaccess Thu Oct 17 18:37:21 2013 +0200
3.3 @@ -5,3 +5,7 @@
3.4 RewriteCond %{REQUEST_FILENAME} !-f
3.5 RewriteCond %{REQUEST_FILENAME} !-d
3.6 RewriteRule ^pages/viewpage.action /redirect.py [PT,L,QSA]
3.7 +
3.8 +RewriteCond %{REQUEST_FILENAME} !-f
3.9 +RewriteCond %{REQUEST_FILENAME} !-d
3.10 +RewriteRule ^dosearchsite.action /search.py [PT,L,QSA]
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/scripts/search.py Thu Oct 17 18:37:21 2013 +0200
4.3 @@ -0,0 +1,55 @@
4.4 +#!/usr/bin/env python
4.5 +
4.6 +"""
4.7 +Handle Confluence wiki requests performing searches.
4.8 +"""
4.9 +
4.10 +from urllib import urlencode
4.11 +import cgi, os, sys
4.12 +
4.13 +# An empty string means that the wiki is anchored at the site root.
4.14 +
4.15 +URL_PREFIX = ""
4.16 +
4.17 +def redirect(args):
4.18 + location = "%s/?%s" % (URL_PREFIX, urlencode(args))
4.19 +
4.20 + print """\
4.21 +Status: 302 Redirect to page
4.22 +Location: %s
4.23 +Content-Type: text/html
4.24 +
4.25 +<html>
4.26 +<head><title>Redirecting to Page</title></head>
4.27 +<body>
4.28 +<h1>Redirecting to Page</h1>
4.29 +<p>If you see this message, try following <a href="%s">this link</a>.</p>
4.30 +</body>
4.31 +</html>
4.32 +""" % (location, cgi.escape(location, True))
4.33 + sys.exit(0)
4.34 +
4.35 +def main():
4.36 + args = cgi.parse_qs(os.environ.get("QUERY_STRING", ""))
4.37 + path = os.environ.get("PATH_INFO", "").strip("/")
4.38 + space = (args.get("searchQuery.spaceKey") or args.get("where") or [None])[0]
4.39 + query = (args.get("searchQuery.queryString") or args.get("queryString") or [None])[0]
4.40 +
4.41 + search = []
4.42 + if space:
4.43 + search.append("title:%s/" % space)
4.44 + if query:
4.45 + search.append(query)
4.46 + search = " ".join(search)
4.47 +
4.48 + redirect({
4.49 + "action" : "fullsearch", # Moin action performing searches
4.50 + "context" : "180", # Textual context in characters
4.51 + "value" : search,
4.52 + "fullsearch" : "Text" # Indicates a page text (not title) search
4.53 + })
4.54 +
4.55 +if __name__ == "__main__":
4.56 + main()
4.57 +
4.58 +# vim: tabstop=4 expandtab shiftwidth=4