From bff85c638b10eb112a6c3161913cd5cd964f9e52 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Thu, 20 Mar 2014 20:22:07 -0700 Subject: [PATCH] Compile .less on demand for test page Test Plan: Opened test page in Chrome and IE8, saw math. Reviewers: emily Reviewed By: emily Differential Revision: http://phabricator.khanacademy.org/D7581 --- server.js | 19 +++++++++++++++++++ static/index.html | 8 +------- test/huxley/test.html | 2 +- test/pdiff.html | 8 +------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/server.js b/server.js index 5d5d48669..2a98c6f0a 100644 --- a/server.js +++ b/server.js @@ -1,7 +1,9 @@ +var fs = require("fs"); var path = require("path"); var browserify = require("browserify"); var express = require("express"); +var less = require("less"); var app = express(); @@ -22,6 +24,23 @@ app.get("/katex.js", function(req, res, next) { }); }); +app.get("/katex.css", function(req, res, next) { + fs.readFile("static/katex.less", {encoding: "utf8"}, function(err, data) { + if (err) { + next(err); + return; + } + less.render(data, function(err, css) { + if (err) { + next(err); + return; + } + res.setHeader("Content-Type", "text/css"); + res.send(css); + }); + }); +}); + app.get("/test/katex-tests.js", function(req, res, next) { var b = browserify(); b.add("./test/katex-tests"); diff --git a/static/index.html b/static/index.html index 44f1617fe..9895d11a4 100644 --- a/static/index.html +++ b/static/index.html @@ -5,14 +5,8 @@ - + - - - - diff --git a/test/huxley/test.html b/test/huxley/test.html index 68177632b..d7f5a6c67 100644 --- a/test/huxley/test.html +++ b/test/huxley/test.html @@ -4,7 +4,7 @@ Huxley test - +