svn commit: samba-web r475 - in trunk: . scripts

deryck at samba.org deryck at samba.org
Fri Dec 17 05:40:27 GMT 2004


Author: deryck
Date: 2004-12-17 05:40:26 +0000 (Fri, 17 Dec 2004)
New Revision: 475

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba-web&rev=475

Log:

Fixing my mirrors script to do a us mirror redirect again.
Adding back the redirect page for the same reason.  

--deryck

Added:
   trunk/redirect_us.html
Modified:
   trunk/scripts/js_redirect.py


Changeset:
Added: trunk/redirect_us.html
===================================================================
--- trunk/redirect_us.html	2004-12-16 15:35:06 UTC (rev 474)
+++ trunk/redirect_us.html	2004-12-17 05:40:26 UTC (rev 475)
@@ -0,0 +1,30 @@
+<html>
+
+<head>
+
+<title>Samba -- Opening Windows to a Wider World</title>    
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv="Content-Language" content="en-us" />
+<meta name="keywords" content="Samba SMB CIFS" />
+<meta name="description" content="Home of Samba, the SMB file server" />
+
+<!--#include virtual="/samba/redirect_include.html" -->
+
+</head>
+
+
+<body onload="javascript:window.location=randomMirror[n]">
+<noscript>
+<h2>Samba -- Opening Windows to a Wider World</h2>
+<h3>Please choose a mirror</h3>
+
+<h4>For the samba.org web site:</h4>
+<!--#include virtual="/samba/web_hosts.html" -->
+
+<h4>For download ftp sites:</h4>
+<!--#include virtual="/samba/ftp_hosts.html" -->
+</noscript>
+</body>
+</html>
+  

Modified: trunk/scripts/js_redirect.py
===================================================================
--- trunk/scripts/js_redirect.py	2004-12-16 15:35:06 UTC (rev 474)
+++ trunk/scripts/js_redirect.py	2004-12-17 05:40:26 UTC (rev 475)
@@ -1,23 +1,46 @@
 #! /usr/bin/python
+#
+# js_redirect.ps -- setup by Deryck Hodge <deryck at samba.org>
+# to run via cron every hour on dp.
+#
+# This does two things:
+# 1) Create the list of options for the select-a-mirror drop-down menu, and 
+# 2) generate the Javascript to redirect samba.org to a random US mirror.
+#
 
-# Create list of options for mirrors drop-down menu 
-
 import os, re
 
 os.chdir('/data/httpd/html/samba')
 hosts = open('web_hosts.html', 'r').readlines()
 mirrors = []  
+us_mirrors = []
 
 for line in hosts:
     if line[:4] == '<li>':
         parts = re.match('<li><a href=(.*)samba.html">(.*)</a>', line)
         # Make list of mirror_name/url pairs to preserve web_hosts sort. 
         mirrors.append((parts.group(2), parts.group(1)))
+        # While we're here, get the US mirrors on their own
+        if re.match('<li><a href="(.*)samba.html">USA</a>', line):
+            us_mirrors.append(re.match('<li><a href="(.*)samba.html">USA</a>', line).group(1))
 
-# For drop-down mirror selection list
+# Write all mirrors to drop-down menu
 menu = open('menu_options.html', 'w')
 for m in mirrors:
     menu.write('<option value=' + m[1] + '">' + m[0] + '</option>\n')
 menu.close()
 
+us_mirrors.sort
+# Write the js for a US mirror redirect
+js = open('redirect_include.html', 'w')
+js.write('<script language="Javascript" type="text/javascript">\n')
+js.write('<!-- Hide from old browsers\n')
+js.write('randomMirror = new Array;\n')
+for i in range(len(us_mirrors)):
+    js.write('randomMirror[' + str(i) + '] = "' + us_mirrors[i] + '"\n')
+js.write('\n')
+js.write('n = Math.floor(Math.random()*' + str(len(us_mirrors)) + ')\n')
+js.write('// end hide -->\n')
+js.write('</script>')
+js.close()
 



More information about the samba-cvs mailing list