diff --git a/config.default.json b/config.default.json index ee3b4ed5..b9bd9c91 100644 --- a/config.default.json +++ b/config.default.json @@ -5,7 +5,8 @@ "host": "localhost:3000", "prefix": "/", "ssl": false, - "static": false + "static": false, + "runner": false }, "max-request-size": "1MB", "store": { diff --git a/lib/app.js b/lib/app.js index 6d238605..1ab4cae1 100644 --- a/lib/app.js +++ b/lib/app.js @@ -85,9 +85,10 @@ if (!process.env.TZ && options.timezone) { options.port = port; })(); -// Strip trailing slash from the prefix. +// Strip trailing slash from the prefix options.url.prefix = options.url.prefix.replace(/\/$/, ''); + // Apply the keys from the config file. All nested properties are // space delimited to match the express style. // @@ -121,6 +122,14 @@ if (options.url.static) { app.set('static url', app.set('url full')); } +if (options.url.runner) { + // strip trailing slash, just in case + options.url.runner = options.url.runner.replace(/\/$/, ''); + app.set('url runner', options.url.runner); +} else { + app.set('url runner', app.set('url full')); +} + app.engine('html', hogan.renderer).engine('txt', hogan.renderer); // Define some generic template variables. diff --git a/lib/handlers/bin.js b/lib/handlers/bin.js index e4ab3458..8028c085 100644 --- a/lib/handlers/bin.js +++ b/lib/handlers/bin.js @@ -617,6 +617,7 @@ module.exports = Observable.extend({ version: version, token: req.session._csrf, root: root, + runner: helpers.runner, static: helpers.urlForStatic(), settings: !bin.url ? config && config.settings : {}, // If we've pulled a just created bin out of the flash messages object @@ -799,6 +800,7 @@ module.exports = Observable.extend({ jsbin: function (bin, options) { return { root: options.root, + runner: this.helpers.runner, static: options.static || options.root, version: options.version, state: { diff --git a/lib/helpers.js b/lib/helpers.js index 65548cd5..8e92425e 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -11,6 +11,10 @@ module.exports.createHelpers = function createHelpers(app) { // Check to see if the app is in production. production: app.get('env') === app.PRODUCTION, + + // Pre-set the URL used for the runner + runner: app.set('url runner') + '/runner', + // Renders the analytics snippet. Accepts a callback that recieves // and error and html object. analytics: function (render, fn) { diff --git a/lib/routes.js b/lib/routes.js index 2bdbe50c..5d98ccd5 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -50,7 +50,7 @@ module.exports = function (app) { binHandler.on('latest-for-user', spike.updateUserSpikes.bind(spike)); binHandler.on('new-revision', spike.bumpRevision.bind(spike)); - binHandler.on('render-scripts', spike.appendScripts.bind(spike)); + binHandler.on('render-scripts', spike.appendScripts.bind(spike, app.settings.version)); // Load the bin from the store when encountered in the url. Also handles the // "latest" url action. diff --git a/lib/spike/index.js b/lib/spike/index.js index b7842452..d787ac99 100644 --- a/lib/spike/index.js +++ b/lib/spike/index.js @@ -300,11 +300,11 @@ module.exports = { }, delayTrigger); }, - appendScripts: function (scripts) { + appendScripts: function (version, scripts) { // TODO this should really detect that there's an active session going // on and the user is saving, and therefore include the spike intelligently - scripts.push('js/vendor/eventsource.js'); - scripts.push('js/spike.js'); + scripts.push('js/vendor/eventsource.js?' + version); + scripts.push('js/spike.js?' + version); }, utils: utils diff --git a/package.json b/package.json index 330890d5..ad40b10a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "name": "jsbin", "description": "Collaborative JavaScript Debugging App", "main": "./lib/app", - "version": "3.7.1", + "version": "3.7.3", "preferGlobal": "true", "homepage": "http://jsbin.com", "bin": "./bin/jsbin", diff --git a/public/js/render/live.js b/public/js/render/live.js index 0f1f1a1f..c8da8772 100644 --- a/public/js/render/live.js +++ b/public/js/render/live.js @@ -264,7 +264,7 @@ var renderLivePreview = (function () { iframe.setAttribute('sandbox', 'allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts'); iframe.setAttribute('frameBorder', '0'); $live.prepend(iframe); - iframe.src = jsbin.root.replace('jsbin', 'run.jsbin') + '/runner'; + iframe.src = jsbin.runner; try { iframe.contentWindow.name = '/' + jsbin.state.code + '/' + jsbin.state.revision; } catch (e) {