diff --git a/app.js b/app.js index 925f25c..34888a4 100644 --- a/app.js +++ b/app.js @@ -13,6 +13,7 @@ var IS_TESTING = 'IS_TESTING' in process.env; var PORT = process.env.PORT || 3000; var bundlejs; +var discoursejs; var screenshotConfig = new ScreenshotConfig(); var redisCache = new RedisCache(process.env.REDIS_URL || process.env.REDISTOGO_URL, @@ -48,6 +49,14 @@ app.get('/healthcheck', function(req, res, next) { }); }); +app.get('/js/discourse-onebox.js', function(req, res, next) { + if (!discoursejs || DEBUG) { + discoursejs = require('fs') + .readFileSync(__dirname + '/contrib/discourse-onebox.js'); + } + return res.type('text/javascript').send(discoursejs); +}); + app.get('/js/bundle.js', function(req, res, next) { if (!bundlejs || DEBUG) { var b = browserify(); diff --git a/static/manual-test/index.html b/static/manual-test/index.html index 9836baa..62d4e79 100644 --- a/static/manual-test/index.html +++ b/static/manual-test/index.html @@ -5,17 +5,16 @@ Manual Tests for Webmaker Screenshot @@ -38,5 +37,28 @@ show the changes you made earlier.

+

Manual Test for Discourse Onebox

+
+

Hi, I am a fake Discourse post. Here is a Webmaker link, which should look roughly like a Discourse onebox.

+

https://toolness.makes.org/thimble/hey-french-toast-refactored

+

Here is a non-Webmaker link, which should not look like a Discourse onebox.

+

http://mozilla.org/

+
+ + + diff --git a/test/app.test.js b/test/app.test.js index 7ec3c01..e42cbae 100644 --- a/test/app.test.js +++ b/test/app.test.js @@ -228,4 +228,13 @@ describe("app", function() { .expect(200) .end(done); }); + + it("should generate /js/discourse-onebox.js", function(done) { + request(app) + .get('/js/discourse-onebox.js') + .expect('Content-Type', 'text/javascript; charset=utf-8') + .expect(200) + .end(done); + }); + });