From be3ab85f96582e3b0c0600f0813722a7b760b441 Mon Sep 17 00:00:00 2001 From: Dustin Miller Date: Mon, 9 Sep 2013 17:58:33 -0500 Subject: [PATCH 1/7] Added option url.runnerhost, remove regexp jsbin to run.jsbin in URL --- config.default.json | 3 ++- lib/app.js | 11 ++++++++++- lib/handlers/bin.js | 2 ++ lib/helpers.js | 1 + public/js/render/live.js | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/config.default.json b/config.default.json index ee3b4ed5..7c0b53fa 100644 --- a/config.default.json +++ b/config.default.json @@ -5,7 +5,8 @@ "host": "localhost:3000", "prefix": "/", "ssl": false, - "static": false + "static": false, + "runnerhost": false }, "max-request-size": "1MB", "store": { diff --git a/lib/app.js b/lib/app.js index 6d238605..fe469f72 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.runnerhost) { + // strip trailing slash, just in case + options.url.runnerhost = options.url.runnerhost.replace(/\/$/, ''); + app.set('url runnerhost', options.url.runnerhost); +} else { + app.set('url runnerhost', 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 2d94025f..e71dbb42 100644 --- a/lib/handlers/bin.js +++ b/lib/handlers/bin.js @@ -608,6 +608,7 @@ module.exports = Observable.extend({ version: version, token: req.session._csrf, root: root, + runnerHost: helpers.runnerHost, static: helpers.urlForStatic(), settings: config && config.settings, // If we've pulled a just created bin out of the flash messages object @@ -786,6 +787,7 @@ module.exports = Observable.extend({ jsbin: function (bin, options) { return { root: options.root, + runnerHost: this.helpers.runnerHost, static: options.static || options.root, version: options.version, state: { diff --git a/lib/helpers.js b/lib/helpers.js index 65548cd5..35177470 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -10,6 +10,7 @@ module.exports.createHelpers = function createHelpers(app) { // Check to see if the app is in production. production: app.get('env') === app.PRODUCTION, + runnerHost: app.set('url runnerhost') + '/runner', // Renders the analytics snippet. Accepts a callback that recieves // and error and html object. diff --git a/public/js/render/live.js b/public/js/render/live.js index 0f1f1a1f..cc91ba30 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.runnerHost; try { iframe.contentWindow.name = '/' + jsbin.state.code + '/' + jsbin.state.revision; } catch (e) { From 10164212d6ad2ea76fc26c57482e1338ca7d0cd9 Mon Sep 17 00:00:00 2001 From: Dustin Miller Date: Tue, 10 Sep 2013 10:57:43 -0500 Subject: [PATCH 2/7] Added comment to helper for runnerHost --- lib/helpers.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/helpers.js b/lib/helpers.js index 35177470..d97e92d1 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -10,6 +10,9 @@ 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 runnerHost: app.set('url runnerhost') + '/runner', // Renders the analytics snippet. Accepts a callback that recieves From e3718aca56e3ee86198087ba5b378c50ed4197ca Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Thu, 12 Sep 2013 12:04:15 +0100 Subject: [PATCH 3/7] s/runnerHost/runner/g --- config.default.json | 2 +- lib/app.js | 8 ++++---- lib/handlers/bin.js | 2 +- lib/helpers.js | 6 +++--- public/js/render/live.js | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/config.default.json b/config.default.json index 7c0b53fa..b9bd9c91 100644 --- a/config.default.json +++ b/config.default.json @@ -6,7 +6,7 @@ "prefix": "/", "ssl": false, "static": false, - "runnerhost": false + "runner": false }, "max-request-size": "1MB", "store": { diff --git a/lib/app.js b/lib/app.js index fe469f72..1ab4cae1 100644 --- a/lib/app.js +++ b/lib/app.js @@ -122,12 +122,12 @@ if (options.url.static) { app.set('static url', app.set('url full')); } -if (options.url.runnerhost) { +if (options.url.runner) { // strip trailing slash, just in case - options.url.runnerhost = options.url.runnerhost.replace(/\/$/, ''); - app.set('url runnerhost', options.url.runnerhost); + options.url.runner = options.url.runner.replace(/\/$/, ''); + app.set('url runner', options.url.runner); } else { - app.set('url runnerhost', app.set('url full')); + app.set('url runner', app.set('url full')); } app.engine('html', hogan.renderer).engine('txt', hogan.renderer); diff --git a/lib/handlers/bin.js b/lib/handlers/bin.js index 19ab576c..bb4076f9 100644 --- a/lib/handlers/bin.js +++ b/lib/handlers/bin.js @@ -609,7 +609,7 @@ module.exports = Observable.extend({ version: version, token: req.session._csrf, root: root, - runnerHost: helpers.runnerHost, + 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 diff --git a/lib/helpers.js b/lib/helpers.js index d97e92d1..8e92425e 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -10,10 +10,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 - runnerHost: app.set('url runnerhost') + '/runner', + runner: app.set('url runner') + '/runner', // Renders the analytics snippet. Accepts a callback that recieves // and error and html object. diff --git a/public/js/render/live.js b/public/js/render/live.js index cc91ba30..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.runnerHost; + iframe.src = jsbin.runner; try { iframe.contentWindow.name = '/' + jsbin.state.code + '/' + jsbin.state.revision; } catch (e) { From bb9933f31a730655efb449e5241f9d2344c9b78b Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Thu, 12 Sep 2013 12:05:14 +0100 Subject: [PATCH 4/7] 3.7.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 330890d5..4197be73 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.2", "preferGlobal": "true", "homepage": "http://jsbin.com", "bin": "./bin/jsbin", From 678c7bc68c1472e9ff896b8a25f46d73b5e91efe Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Thu, 12 Sep 2013 14:28:22 +0100 Subject: [PATCH 5/7] Runner wasn't being set properly :-\ --- lib/handlers/bin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/handlers/bin.js b/lib/handlers/bin.js index bb4076f9..dd8c693d 100644 --- a/lib/handlers/bin.js +++ b/lib/handlers/bin.js @@ -792,7 +792,7 @@ module.exports = Observable.extend({ jsbin: function (bin, options) { return { root: options.root, - runnerHost: this.helpers.runnerHost, + runner: this.helpers.runner, static: options.static || options.root, version: options.version, state: { From b0a95a6240618ba725f380a419cfc969e0d57b3a Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Thu, 12 Sep 2013 14:45:00 +0100 Subject: [PATCH 6/7] Cache bust the spike.js in the preview. Fixes #801...I hope --- lib/routes.js | 2 +- lib/spike/index.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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 From dda0d697254972de7276d33cfdf766ba1499f88c Mon Sep 17 00:00:00 2001 From: Remy Sharp Date: Thu, 12 Sep 2013 14:45:42 +0100 Subject: [PATCH 7/7] 3.7.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4197be73..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.2", + "version": "3.7.3", "preferGlobal": "true", "homepage": "http://jsbin.com", "bin": "./bin/jsbin",