# HG changeset patch # User Paul Boddie # Date 1382031905 -7200 # Node ID 82214eab5e7da38c32ae65ec7b3a8ee60ca0302f # Parent 90a5f79430e941376cf2b769148cdc533fff34b0 Added page export support using the RenderAsPDF action. diff -r 90a5f79430e9 -r 82214eab5e7d TO_DO.txt --- a/TO_DO.txt Thu Oct 17 19:13:26 2013 +0200 +++ b/TO_DO.txt Thu Oct 17 19:45:05 2013 +0200 @@ -42,16 +42,38 @@ Redirects for Confluence actions + (Search actions such as... + http://wiki.list.org/dosearchsite.action?searchQuery.spaceKey=DOC - http://wiki.list.org/spaces/space-bookmarks.action?spaceKey=COM - http://wiki.list.org/pages/doexportpage.action?pageId=786442&type=TYPE_PDF - http://wiki.list.org/spaces/exportspacexml.action?key=DEV + + ...are redirected to the Moin fullsearch action) + + (The dashboard action... + http://wiki.list.org/dashboard.action - Note that the following are handled by the identifier-to-page redirects: + ...should redirect to the front page of the wiki) + + (Page export actions... + + http://wiki.list.org/pages/doexportpage.action?pageId=786442&type=TYPE_PDF + + ...can be supported using the RenderAsPDF action) + + (Note that viewpage actions like the following... http://wiki.list.org/pages/viewpage.action?pageId=4030607 + ...are handled by the identifier-to-page redirects) + + The bookmarks action seems to be broken on wiki.list.org: + + http://wiki.list.org/spaces/space-bookmarks.action?spaceKey=COM + + Space export actions are not likely to be easily supported: + + http://wiki.list.org/spaces/exportspacexml.action?key=DEV + Issues diff -r 90a5f79430e9 -r 82214eab5e7d config/mailmanwiki-redirect --- a/config/mailmanwiki-redirect Thu Oct 17 19:13:26 2013 +0200 +++ b/config/mailmanwiki-redirect Thu Oct 17 19:45:05 2013 +0200 @@ -1,4 +1,5 @@ ScriptAlias /x "/var/www/mmwiki-scripts/redirect.py" ScriptAlias /pages/viewpage.action "/var/www/mmwiki-scripts/redirect.py" +ScriptAlias /pages/doexportpage.action "/var/www/mmwiki-scripts/redirect.py" ScriptAlias /dosearchsite.action "/var/www/mmwiki-scripts/search.py" ScriptAlias /dashboard.action "/var/www/mmwiki-scripts/dashboard.py" diff -r 90a5f79430e9 -r 82214eab5e7d config/mailmanwiki-redirect-htaccess --- a/config/mailmanwiki-redirect-htaccess Thu Oct 17 19:13:26 2013 +0200 +++ b/config/mailmanwiki-redirect-htaccess Thu Oct 17 19:45:05 2013 +0200 @@ -8,6 +8,10 @@ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^pages/doexportpage.action /redirect.py [PT,L,QSA] + +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^dosearchsite.action /search.py [PT,L,QSA] RewriteCond %{REQUEST_FILENAME} !-f diff -r 90a5f79430e9 -r 82214eab5e7d scripts/redirect.py --- a/scripts/redirect.py Thu Oct 17 19:13:26 2013 +0200 +++ b/scripts/redirect.py Thu Oct 17 19:45:05 2013 +0200 @@ -2,7 +2,8 @@ """ Handle Confluence wiki requests employing special identifiers that should map to -wiki pages. +wiki pages. This script also handles export actions because they also use page +identifiers. """ from urllib import quote @@ -44,8 +45,8 @@ """ % (pageid and " (%s)" % pageid or "") sys.exit(0) -def redirect(pagename): - location = "%s/%s" % (URL_PREFIX, quote(pagename)) +def redirect(pagename, export=False): + location = "%s/%s%s" % (URL_PREFIX, quote(pagename), export and "?action=RenderAsPDF" or "") print """\ Status: 302 Redirect to page @@ -66,25 +67,34 @@ for line in f.xreadlines(): columns = line.strip().split("\t") if columns[0] == pageid: - redirect(columns[1]) + return columns[1] + return None def main(): args = cgi.parse_qs(os.environ.get("QUERY_STRING", "")) path = os.environ.get("PATH_INFO", "").strip("/") + script = os.environ.get("SCRIPT_NAME", "") pageid = args.get("pageId", [None])[0] or identifier(path) if pageid is None: fail(pageid) + export = script.endswith("/pages/doexportpage.action") and args.get("type", [""])[0] == "TYPE_PDF" + f = open(MAPPING_ID_TO_PAGE) try: # With an identifier, find the corresponding page name. - find(f, pageid) + pagename = find(f, pageid) # Didn't find the page. - fail(pageid) + if not pagename: + fail(pageid) # exits + + # Redirect to the page. + + redirect(pagename, export) finally: f.close()