svn commit: samba-web r416 - in trunk: . scripts
deryck at samba.org
deryck at samba.org
Mon Nov 15 18:58:26 GMT 2004
Author: deryck
Date: 2004-11-15 18:58:25 +0000 (Mon, 15 Nov 2004)
New Revision: 416
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba-web&rev=416
Log:
This script reads web_hosts.html and generates the javascript
in redirect_us.html that redirects to a random mirror. This
should prevent us from having to do a last minute scramble
when a mirror goes offline again.
--deryck
Added:
trunk/scripts/js_redirect.py
Modified:
trunk/redirect_us.html
Changeset:
Modified: trunk/redirect_us.html
===================================================================
--- trunk/redirect_us.html 2004-11-15 15:33:54 UTC (rev 415)
+++ trunk/redirect_us.html 2004-11-15 18:58:25 UTC (rev 416)
@@ -9,14 +9,7 @@
<meta name="keywords" content="Samba SMB CIFS" />
<meta name="description" content="Home of Samba, the SMB file server" />
-<script type="text/javascript">
-
- randomMirror = new Array;
- randomMirror[0] = "http://us1.samba.org/samba/"
- randomMirror[1] = "http://us1.samba.org/samba/"
-
- n=Math.floor(Math.random()*2)
-
+<script type="text/javascript" src="/samba/scripts/redirect.js">
</script>
</head>
@@ -31,7 +24,7 @@
<!--#include virtual="/samba/web_hosts.html" -->
<h4>For download ftp sites:</h4>
-<!--#include virtual="ftp_hosts.html" -->
+<!--#include virtual="/samba/ftp_hosts.html" -->
</noscript>
</body>
</html>
Added: trunk/scripts/js_redirect.py
===================================================================
--- trunk/scripts/js_redirect.py 2004-11-15 15:33:54 UTC (rev 415)
+++ trunk/scripts/js_redirect.py 2004-11-15 18:58:25 UTC (rev 416)
@@ -0,0 +1,25 @@
+#! /usr/bin/python
+
+# Create javascript for redirecting to a random mirror.
+
+import os, re
+
+os.chdir('/data/httpd/html/samba')
+hosts = open('web_hosts.html', 'r').readlines()
+fluff = re.compile('(<li><a href=)|(samba.html)|(>.+)|(\n)')
+urls = []
+
+for line in hosts:
+ if line[:4] == '<li>':
+ nline = fluff.sub('', line)
+ urls.append(nline)
+
+os.chdir('/data/httpd/html/samba/scripts')
+js = open('redirect.js', 'w')
+js.write('randomMirror = new Array;\n')
+for i in range(len(urls)):
+ js.write('randomMirror[' + str(i) + '] = ' + urls[i] + '\n')
+js.write('\n')
+js.write('n = Math.floor(Math.random()*' + str(len(urls)) + ')')
+js.close()
+
Property changes on: trunk/scripts/js_redirect.py
___________________________________________________________________
Name: svn:executable
+ *
More information about the samba-cvs
mailing list