diff --git a/src/routes.json b/src/routes.json index 49adc172d..ef64a6b38 100644 --- a/src/routes.json +++ b/src/routes.json @@ -168,8 +168,8 @@ }, { "name": "download", - "pattern": "^/scratch2download/", - "routeAlias": "/scratch2download/?$", + "pattern": "^/download/", + "routeAlias": "/download/?$", "view": "download/download", "title": "Scratch Offline Editor" }, @@ -252,6 +252,12 @@ "routeAlias": "/explore(?!/ajax)", "redirect": "/explore/studios/all" }, + { + "name": "download-redirect", + "pattern": "^/scratch2download/?$", + "routeAlias": "/scratch2download", + "view": "/download" + }, { "name": "microworld-art", "pattern": "^/microworlds/art", diff --git a/src/views/download/download.jsx b/src/views/download/download.jsx index 1a6cffad3..a80447e03 100644 --- a/src/views/download/download.jsx +++ b/src/views/download/download.jsx @@ -4,6 +4,7 @@ var render = require('../../lib/render.jsx'); var FormattedHTMLMessage = require('react-intl').FormattedHTMLMessage; var FormattedMessage = require('react-intl').FormattedMessage; +var api = require('../../lib/api'); var Page = require('../../components/page/www/page.jsx'); var TitleBanner = require('../../components/title-banner/title-banner.jsx'); var FlexRow = require('../../components/flex-row/flex-row.jsx'); @@ -14,7 +15,33 @@ require('../../components/forms/button.scss'); var Download = React.createClass({ type: 'Download', + getInitialState: function () { + return { + swfVersion: '456.0.3' + }; + }, + componentDidMount: function () { + api({ + host: '', + uri: '/scratchr2/static/sa/version.xml', + responseType: 'string' + }, function (err, body) { + if (err) return; + + var doc = new DOMParser().parseFromString(body, 'text/xml'); + return this.setState({ + swfVersion: doc.getElementsByTagName('versionNumber')[0].childNodes[0].nodeValue + }); + }.bind(this)); + }, render: function () { + var downloadUrls = { + mac: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.dmg', + mac105: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.air', + windows: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.exe', + linux: '/scratchr2/static/sa/Scratch-'+ this.state.swfVersion + '.air' + }; + return (
@@ -95,25 +122,25 @@ var Download = React.createClass({