diff --git a/blog/builder.sh b/blog/builder.sh index 8ab7ac3..6a5fe67 100644 --- a/blog/builder.sh +++ b/blog/builder.sh @@ -16,6 +16,5 @@ cp -r public/$publicPath/* $out/ # Render math in HTML and XML files. node $server & -SERVER_ID=$! +sleep 1 find $out/ -regex "$out/.*\.html" | xargs ruby $converter -kill $SERVER_ID diff --git a/blog/convert.rb b/blog/convert.rb index 4c4420c..6fb86d7 100644 --- a/blog/convert.rb +++ b/blog/convert.rb @@ -6,7 +6,7 @@ require "json" def render_cached(cache, display, string, render_comment = nil) cache.fetch(string) do |new| puts " Rendering #{render_comment || new}" - res = Net::HTTP.post URI("http://localhost:3000/render"), + res = Net::HTTP.post URI("http://localhost:8000/render"), { :equations => [ { :str => string, :display => display } ] }.to_json, "Content-Type" => "application/json" cache[string] = JSON.parse(res.body)[0] diff --git a/blog/default.nix b/blog/default.nix index 3a245eb..a7f3ecb 100644 --- a/blog/default.nix +++ b/blog/default.nix @@ -24,7 +24,7 @@ let server = ./katexserver.js; buildInputs = [ hugo nodejs - requiredPackages.katex requiredPackages.express requiredPackages.body-parser + requiredPackages."katex-0.11.1" requiredPackages.express requiredPackages.body-parser (ruby.withPackages (ps: [ ps.nokogiri ])) ]; }; diff --git a/blog/katexserver.js b/blog/katexserver.js index c24814f..dc5ca0b 100644 --- a/blog/katexserver.js +++ b/blog/katexserver.js @@ -5,8 +5,7 @@ const bodyParser = require('body-parser'); app = express(); app.use(bodyParser.json()); app.post('/render', (req, res) => { - console.log(req.body) res.send(req.body.equations.map(eq => katex.renderToString(eq.str, { throwOnError: false, displayMode: eq.display }))); }); -app.listen(3000); +app.listen(8000); diff --git a/blog/node-packages.nix b/blog/node-packages.nix index 16807ed..4646c3c 100644 --- a/blog/node-packages.nix +++ b/blog/node-packages.nix @@ -457,13 +457,13 @@ let }; in { - katex = nodeEnv.buildNodePackage { + "katex-0.11.1" = nodeEnv.buildNodePackage { name = "katex"; packageName = "katex"; - version = "0.12.0"; + version = "0.11.1"; src = fetchurl { - url = "https://registry.npmjs.org/katex/-/katex-0.12.0.tgz"; - sha512 = "y+8btoc/CK70XqcHqjxiGWBOeIL8upbS0peTPXTvgrh21n1RiWWcIpSWM+4uXq+IAgNh9YYQWdc7LVDPDAEEAg=="; + url = "https://registry.npmjs.org/katex/-/katex-0.11.1.tgz"; + sha512 = "5oANDICCTX0NqYIyAiFCCwjQ7ERu3DQG2JFHLbYOf+fXaMoH8eg/zOq5WSYJsKMi/QebW+Eh3gSM+oss1H/bww=="; }; dependencies = [ sources."commander-2.20.3" diff --git a/blog/packages.json b/blog/packages.json index e3fd054..52512e2 100644 --- a/blog/packages.json +++ b/blog/packages.json @@ -1,3 +1,3 @@ [ - "katex", "express", "body-parser" + {"katex": "0.11.1"}, "express", "body-parser" ]