# HG changeset patch # User David Champion # Date 1290304387 21600 # Node ID fb3ce83c1a484c8619a72ddde19370c51f30a8a4 # Parent 7cb309f3e33aa9e2c222482b7d944d91107fcff1 download: use sources.js instead of jinja static templates See http://mercurial.selenic.com/wiki/BinaryReleasePlan 1. [hg-website] update the main page (templates/base.html and static/js/download.js) to use sources.js as a dynamic binary release information source instead of using a jinja template maintained as part of the web site. templates/data no longer required; removed. 2. [hg-website-content] update the /downloads page use the sources.js information also. This changes some of the detection and package naming, naturally, but that likely must be addressed in latest.dat files or in the protocol for creating sources.js. diff -r 7cb309f3e33a -r fb3ce83c1a48 .hgsubstate --- a/.hgsubstate Sat Nov 20 19:56:37 2010 -0600 +++ b/.hgsubstate Sat Nov 20 19:53:07 2010 -0600 @@ -1,2 +1,2 @@ -571b7970a0ba32b912ec07acad337b9d9669656b content +6e7e8b5aa2c317fb1d185265b87d64f054e6c9fa content 62caa522bc653951b323f79e9e8fd557a1dd2709 rendered diff -r 7cb309f3e33a -r fb3ce83c1a48 static/js/download.js --- a/static/js/download.js Sat Nov 20 19:56:37 2010 -0600 +++ b/static/js/download.js Sat Nov 20 19:53:07 2010 -0600 @@ -1,40 +1,68 @@ -function Download() { - this.downloads = {}; +function Download (source) { + this.version = source[0]; + this.regex = source[1]; + this.url = source[2]; + this.desc = source[3]; } Download.prototype = { + matches: function (ua) { + if (ua.match(this.regex)) + return true; + return false; + }, - parse_os: function() { - var OSName="Source code"; - if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows"; - if (navigator.appVersion.indexOf("Mac")!=-1) { - if (navigator.userAgent.indexOf("10.6")!=-1 || /* firefox */ - navigator.userAgent.indexOf("10_6") !=-1) { /* chrome */ - OSName="Mac OS X 10.6"; - } else { - OSName="Mac OS X 10.5"; - } - } - if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX"; - if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux"; + download: function () { + document.location.href = this.url; + return false; + }, - return OSName; + attr: function (key) { + return this[key]; }, - os_detection: function() { - document.write(this.parse_os()); + write: function (key) { + document.write(this[key]); + } +} + + +var Downloader = { + downloads: [], + + init: function (sources) { + for (i in sources) { + var source = new Download(sources[i]); + this.downloads.push(source); + } }, - os_link: function() { - var os = this.parse_os(); - if (this.downloads[os]) { - document.location.href = this.downloads[os]; - return false; + select: function () { + var ua = navigator.userAgent; + for (i in this.downloads) { + if (this.downloads[i].matches(ua)) { + return this.downloads[i]; + } } - return true; + return null; }, - register_download:function(type, url) { - this.downloads[type] = url; + listall: function () { + // copy the download list + var downloads = this.downloads.slice(0); + // alpha-sort it by description (case-folded) + downloads.sort(function (a, b) { + a = a.desc.toLowerCase(); + b = b.desc.toLowerCase(); + return (b < a) - (a < b); + }); + + for (i in downloads) { + var dl = downloads[i]; + document.write('\n' + dl.desc + '' + + '' + + 'download' + + ''); + } } -} +}; diff -r 7cb309f3e33a -r fb3ce83c1a48 templates/base.html --- a/templates/base.html Sat Nov 20 19:56:37 2010 -0600 +++ b/templates/base.html Sat Nov 20 19:53:07 2010 -0600 @@ -1,5 +1,3 @@ -{% from 'data' import downloads %} - @@ -8,16 +6,12 @@ + + - - @@ -58,10 +52,10 @@
{% block sidebar %} - + Download now - Mercurial {{ downloads['current'] }} - + Mercurial +
Another OS?
Get Mercurial for:
diff -r 7cb309f3e33a -r fb3ce83c1a48 templates/data --- a/templates/data Sat Nov 20 19:56:37 2010 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -{% set downloads = { - 'current': '1.7.1', - '1.7.1' : { - 'TortoiseHg for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1.6.1-hg-1.7.1-x64.msi', - 'TortoiseHg for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1.6.1-hg-1.7.1-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.7.1.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.7.1-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.7.1-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.7.1.tar.gz'}, - '1.7' : { - 'TortoiseHG for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1.5-hg-1.7-x64.msi', - 'TortoiseHG for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1.5-hg-1.7-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.7.0.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.7-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.7-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.7.tar.gz'}, - '1.6.4' : { - 'TortoiseHG for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1.4-hg-1.6.4-x64.msi', - 'TortoiseHG for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1.4-hg-1.6.4-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.6.4.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.6.4-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.6.4-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.6.4.tar.gz'}, - '1.6.3' : { - 'TortoiseHG for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1.3-hg-1.6.3-x64.msi', - 'TortoiseHG for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1.3-hg-1.6.3-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.6.3.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.6.3-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.6.3-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.6.3.tar.gz'}, - '1.6.2' : { - 'TortoiseHG for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1.2-hg-1.6.2-x64.msi', - 'TortoiseHG for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1.2-hg-1.6.2-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.6.2.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.6.2-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.6.2-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.6.2.tar.gz'}, - '1.6.1' : { - 'TortoiseHG for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.2-hg-1.6.1-x64.msi', - 'TortoiseHG for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.2-hg-1.6.1-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.6.1.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.6.1-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.6.1-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.6.1.tar.gz'}, - '1.6' : { - 'TortoiseHG for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1-hg-1.6-x64.msi', - 'TortoiseHG for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.1-hg-1.6-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.6.0.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.6-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.6-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.6.tar.gz'}, - '1.5.4' : { - 'TortoiseHG for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.0.4-hg-1.5.4-x64.msi', - 'TortoiseHG for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.0.4-hg-1.5.4-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.5.4.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.5.4-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.5.4-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.5.4.tar.gz'}, - '1.5.3' : { - 'TortoiseHG for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.0.3-hg-1.5.3-x64.msi', - 'TortoiseHG for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.0.3-hg-1.5.3-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.5.3.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.5.3-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.5.3-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.5.3.tar.gz'}, - '1.5.2' : { - 'TortoiseHG for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.0.2-hg-1.5.2-x64.msi', - 'TortoiseHG for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.0.2-hg-1.5.2-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.5.2.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.5.2-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.5.2-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.5.2.tar.gz'}, - '1.5' : { - 'TortoiseHG for Windows 64bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.0-hg-1.5-x64.msi', - 'TortoiseHG for Windows 32bit': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-1.0-hg-1.5-x86.msi', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.5.0.msi', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.5-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.5-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.5.tar.gz'}, - '1.4.3' : { - 'Windows (TortoiseHg)': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-0.9.3-hg-1.4.3.exe', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.4.3.exe', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.4.3-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.4.3-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.4.3.tar.gz'}, - '1.4.2': { - 'Windows (TortoiseHg)': 'http://bitbucket.org/tortoisehg/stable/downloads/tortoisehg-0.9.2-1-hg-1.4.2.exe', - 'Windows': 'http://bitbucket.org/tortoisehg/thg-winbuild/downloads/mercurial-1.4.2.exe', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.4.2-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.4.2-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.4.2.tar.gz'}, - '1.4.1': { - 'Windows (TortoiseHg)': 'http://bitbucket.org/tortoisehg/stable/downloads/TortoiseHg-0.9.1.1-hg-1.4.1.exe', - 'Windows': 'http://mercurial.berkwood.com/binaries/Mercurial-1.4.1.exe', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.4.1-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.4.1-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.4.1.tar.gz'}, - '1.4': { - 'Windows (TortoiseHg)': 'http://bitbucket.org/tortoisehg/stable/downloads/TortoiseHg-0.9-hg-1.4.exe', - 'Windows': 'http://mercurial.berkwood.com/binaries/Mercurial-1.4.exe', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.4-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.4-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.4.tar.gz'}, - '1.3.1': { - 'Windows (TortoiseHg)': 'http://bitbucket.org/tortoisehg/stable/downloads/TortoiseHg-0.8.1-hg-1.3.1.exe', - 'Windows': 'http://mercurial.berkwood.com/binaries/Mercurial-1.3.1.exe', - 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.3.1-py2.6-macosx10.6.zip', - 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.3.1-py2.5-macosx10.5.zip', - 'Source code': 'http://mercurial.selenic.com/release/mercurial-1.3.1.tar.gz'}} -%}