1.1 --- a/TO_DO.txt Thu Oct 17 19:13:26 2013 +0200
1.2 +++ b/TO_DO.txt Thu Oct 17 19:45:05 2013 +0200
1.3 @@ -42,16 +42,38 @@
1.4
1.5 Redirects for Confluence actions
1.6
1.7 + (Search actions such as...
1.8 +
1.9 http://wiki.list.org/dosearchsite.action?searchQuery.spaceKey=DOC
1.10 - http://wiki.list.org/spaces/space-bookmarks.action?spaceKey=COM
1.11 - http://wiki.list.org/pages/doexportpage.action?pageId=786442&type=TYPE_PDF
1.12 - http://wiki.list.org/spaces/exportspacexml.action?key=DEV
1.13 +
1.14 + ...are redirected to the Moin fullsearch action)
1.15 +
1.16 + (The dashboard action...
1.17 +
1.18 http://wiki.list.org/dashboard.action
1.19
1.20 - Note that the following are handled by the identifier-to-page redirects:
1.21 + ...should redirect to the front page of the wiki)
1.22 +
1.23 + (Page export actions...
1.24 +
1.25 + http://wiki.list.org/pages/doexportpage.action?pageId=786442&type=TYPE_PDF
1.26 +
1.27 + ...can be supported using the RenderAsPDF action)
1.28 +
1.29 + (Note that viewpage actions like the following...
1.30
1.31 http://wiki.list.org/pages/viewpage.action?pageId=4030607
1.32
1.33 + ...are handled by the identifier-to-page redirects)
1.34 +
1.35 + The bookmarks action seems to be broken on wiki.list.org:
1.36 +
1.37 + http://wiki.list.org/spaces/space-bookmarks.action?spaceKey=COM
1.38 +
1.39 + Space export actions are not likely to be easily supported:
1.40 +
1.41 + http://wiki.list.org/spaces/exportspacexml.action?key=DEV
1.42 +
1.43
1.44
1.45 Issues
2.1 --- a/config/mailmanwiki-redirect Thu Oct 17 19:13:26 2013 +0200
2.2 +++ b/config/mailmanwiki-redirect Thu Oct 17 19:45:05 2013 +0200
2.3 @@ -1,4 +1,5 @@
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 /pages/doexportpage.action "/var/www/mmwiki-scripts/redirect.py"
2.7 ScriptAlias /dosearchsite.action "/var/www/mmwiki-scripts/search.py"
2.8 ScriptAlias /dashboard.action "/var/www/mmwiki-scripts/dashboard.py"
3.1 --- a/config/mailmanwiki-redirect-htaccess Thu Oct 17 19:13:26 2013 +0200
3.2 +++ b/config/mailmanwiki-redirect-htaccess Thu Oct 17 19:45:05 2013 +0200
3.3 @@ -8,6 +8,10 @@
3.4
3.5 RewriteCond %{REQUEST_FILENAME} !-f
3.6 RewriteCond %{REQUEST_FILENAME} !-d
3.7 +RewriteRule ^pages/doexportpage.action /redirect.py [PT,L,QSA]
3.8 +
3.9 +RewriteCond %{REQUEST_FILENAME} !-f
3.10 +RewriteCond %{REQUEST_FILENAME} !-d
3.11 RewriteRule ^dosearchsite.action /search.py [PT,L,QSA]
3.12
3.13 RewriteCond %{REQUEST_FILENAME} !-f
4.1 --- a/scripts/redirect.py Thu Oct 17 19:13:26 2013 +0200
4.2 +++ b/scripts/redirect.py Thu Oct 17 19:45:05 2013 +0200
4.3 @@ -2,7 +2,8 @@
4.4
4.5 """
4.6 Handle Confluence wiki requests employing special identifiers that should map to
4.7 -wiki pages.
4.8 +wiki pages. This script also handles export actions because they also use page
4.9 +identifiers.
4.10 """
4.11
4.12 from urllib import quote
4.13 @@ -44,8 +45,8 @@
4.14 """ % (pageid and " (%s)" % pageid or "")
4.15 sys.exit(0)
4.16
4.17 -def redirect(pagename):
4.18 - location = "%s/%s" % (URL_PREFIX, quote(pagename))
4.19 +def redirect(pagename, export=False):
4.20 + location = "%s/%s%s" % (URL_PREFIX, quote(pagename), export and "?action=RenderAsPDF" or "")
4.21
4.22 print """\
4.23 Status: 302 Redirect to page
4.24 @@ -66,25 +67,34 @@
4.25 for line in f.xreadlines():
4.26 columns = line.strip().split("\t")
4.27 if columns[0] == pageid:
4.28 - redirect(columns[1])
4.29 + return columns[1]
4.30 + return None
4.31
4.32 def main():
4.33 args = cgi.parse_qs(os.environ.get("QUERY_STRING", ""))
4.34 path = os.environ.get("PATH_INFO", "").strip("/")
4.35 + script = os.environ.get("SCRIPT_NAME", "")
4.36
4.37 pageid = args.get("pageId", [None])[0] or identifier(path)
4.38 if pageid is None:
4.39 fail(pageid)
4.40
4.41 + export = script.endswith("/pages/doexportpage.action") and args.get("type", [""])[0] == "TYPE_PDF"
4.42 +
4.43 f = open(MAPPING_ID_TO_PAGE)
4.44 try:
4.45 # With an identifier, find the corresponding page name.
4.46
4.47 - find(f, pageid)
4.48 + pagename = find(f, pageid)
4.49
4.50 # Didn't find the page.
4.51
4.52 - fail(pageid)
4.53 + if not pagename:
4.54 + fail(pageid) # exits
4.55 +
4.56 + # Redirect to the page.
4.57 +
4.58 + redirect(pagename, export)
4.59
4.60 finally:
4.61 f.close()