You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by hw...@apache.org on 2011/05/10 16:57:06 UTC
svn commit: r1101491 - in /subversion/site/publish: do_ssi.py download.cgi
Author: hwright
Date: Tue May 10 14:57:06 2011
New Revision: 1101491
URL: http://svn.apache.org/viewvc?rev=1101491&view=rev
Log:
Add a well-intentioned, but probably woefully-executed hack to get
server-side includes working on the download page.
Because the content for this page is generated by the ASF-supplied mirrors.cgi
script, it doesn't go through mod_include, so our server-side includes
aren't handled properly. The new script works for what I'm trying to do,
though it is far from a general solution.
The Ideal solution here would be to hack mirrors.cgi to allow it to
recognize SSI directives, but I'm just not there yet.
* publish/download.cgi:
Pass the output of the mirrors.cgi script through our ssi handler.
* publish/do_ssi.py:
New.
Added:
subversion/site/publish/do_ssi.py (with props)
Modified:
subversion/site/publish/download.cgi
Added: subversion/site/publish/do_ssi.py
URL: http://svn.apache.org/viewvc/subversion/site/publish/do_ssi.py?rev=1101491&view=auto
==============================================================================
--- subversion/site/publish/do_ssi.py (added)
+++ subversion/site/publish/do_ssi.py Tue May 10 14:57:06 2011
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+import sys
+import re
+
+regex = re.compile('<!--#include virtual="(.*)" -->')
+
+
+def include_repl(match):
+ filename = match.group(1)
+
+ # We have no idea where the document root is, so just pretend
+ if filename[0] == '/':
+ filename = filename[1:]
+
+ try:
+ return open(filename).read()
+ except IOError:
+ return match.group(0)
+
+
+def main(infile):
+ for line in infile:
+ sys.stdout.write(regex.sub(include_repl, line))
+
+
+if __name__ == '__main__':
+ main(sys.stdin)
Propchange: subversion/site/publish/do_ssi.py
------------------------------------------------------------------------------
svn:executable = *
Modified: subversion/site/publish/download.cgi
URL: http://svn.apache.org/viewvc/subversion/site/publish/download.cgi?rev=1101491&r1=1101490&r2=1101491&view=diff
==============================================================================
--- subversion/site/publish/download.cgi (original)
+++ subversion/site/publish/download.cgi Tue May 10 14:57:06 2011
@@ -3,4 +3,4 @@
# (we must change to that directory in order for python to pick up the
# python includes correctly)
cd /www/www.apache.org/dyn/mirrors
-exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $*
+exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $* | ./do_ssi.py