# HG changeset patch # User Paul Boddie # Date 1382027841 -7200 # Node ID 6719176d28084202ef7b1fc839e118f4f6f874ed # Parent b2bc15213b1f3334d379fb38a3d67112c3e500f6 Added a script supporting the Confluence site search URL path. diff -r b2bc15213b1f -r 6719176d2808 README.txt --- a/README.txt Thu Oct 17 17:52:58 2013 +0200 +++ b/README.txt Thu Oct 17 18:37:21 2013 +0200 @@ -151,6 +151,23 @@ or it should be placed in a different location and the MAPPING_ID_TO_PAGE variable changed in the script to refer to this different location. +Supporting Confluence Action URLs +--------------------------------- + +Besides the "viewpage" action mapping identifiers to pages (covered by the +mapping described above), some other action URLs may be used in wiki content +and must either be translated or supported using redirects. Since external +sites may also employ such actions, a redirect strategy perhaps makes more +sense. To support this, the following resources are involved: + + * scripts/search.py + * config/mailmanwiki-redirect + +The latter configuration file is also involved in identifier-to-page mapping, +but in this case it causes requests to the "dosearchsite" action to be +directed to the search.py script, which in turn redirects the request in a +suitable form to the MoinMoin "fullsearch" action. + Identifying and Migrating Users ------------------------------- diff -r b2bc15213b1f -r 6719176d2808 config/mailmanwiki-redirect --- a/config/mailmanwiki-redirect Thu Oct 17 17:52:58 2013 +0200 +++ b/config/mailmanwiki-redirect Thu Oct 17 18:37:21 2013 +0200 @@ -1,2 +1,3 @@ ScriptAlias /x "/var/www/mmwiki-scripts/redirect.py" ScriptAlias /pages/viewpage.action "/var/www/mmwiki-scripts/redirect.py" +ScriptAlias /dosearchsite.action "/var/www/mmwiki-scripts/search.py" diff -r b2bc15213b1f -r 6719176d2808 config/mailmanwiki-redirect-htaccess --- a/config/mailmanwiki-redirect-htaccess Thu Oct 17 17:52:58 2013 +0200 +++ b/config/mailmanwiki-redirect-htaccess Thu Oct 17 18:37:21 2013 +0200 @@ -5,3 +5,7 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^pages/viewpage.action /redirect.py [PT,L,QSA] + +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^dosearchsite.action /search.py [PT,L,QSA] diff -r b2bc15213b1f -r 6719176d2808 scripts/search.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/search.py Thu Oct 17 18:37:21 2013 +0200 @@ -0,0 +1,55 @@ +#!/usr/bin/env python + +""" +Handle Confluence wiki requests performing searches. +""" + +from urllib import urlencode +import cgi, os, sys + +# An empty string means that the wiki is anchored at the site root. + +URL_PREFIX = "" + +def redirect(args): + location = "%s/?%s" % (URL_PREFIX, urlencode(args)) + + print """\ +Status: 302 Redirect to page +Location: %s +Content-Type: text/html + + +Redirecting to Page + +

Redirecting to Page

+

If you see this message, try following this link.

+ + +""" % (location, cgi.escape(location, True)) + sys.exit(0) + +def main(): + args = cgi.parse_qs(os.environ.get("QUERY_STRING", "")) + path = os.environ.get("PATH_INFO", "").strip("/") + space = (args.get("searchQuery.spaceKey") or args.get("where") or [None])[0] + query = (args.get("searchQuery.queryString") or args.get("queryString") or [None])[0] + + search = [] + if space: + search.append("title:%s/" % space) + if query: + search.append(query) + search = " ".join(search) + + redirect({ + "action" : "fullsearch", # Moin action performing searches + "context" : "180", # Textual context in characters + "value" : search, + "fullsearch" : "Text" # Indicates a page text (not title) search + }) + +if __name__ == "__main__": + main() + +# vim: tabstop=4 expandtab shiftwidth=4