-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/repeatable-build' of github.com:ONSdigital/mathjax-api
- Loading branch information
Showing
8 changed files
with
2,214 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v4.8.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM node:4 | ||
FROM node:4.8.1 | ||
|
||
WORKDIR /src | ||
ADD . /src | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
MIT License | ||
|
||
Copyright (c) Crown Copyright (Office for National Statistics) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
NVM_SOURCE_PATH ?= $(HOME)/.nvm/nvm.sh | ||
|
||
ifneq ("$(wildcard $(NVM_SOURCE_PATH))","") | ||
NVM_EXEC = source $(NVM_SOURCE_PATH) && nvm exec -- | ||
endif | ||
NPM = $(NVM_EXEC) npm | ||
NODE = $(NVM_EXEC) node | ||
|
||
.PHONY: all | ||
all: audit test build | ||
|
||
.PHONY: audit | ||
audit: | ||
# $(NPM) audit --audit-level=high | ||
@echo audit not yet implemented for this repo | ||
exit 1 | ||
|
||
.PHONY: build | ||
build: | ||
$(NPM) install | ||
|
||
.PHONY: debug | ||
debug: build | ||
$(NODE) app.js | ||
|
||
.PHONY: test | ||
test: | ||
@echo tests not yet implemented for this repo | ||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,69 @@ | ||
# mathjax-api | ||
A Node.js HTTP API to render MathJax equations in HTML content | ||
|
||
This service uses the MathJax-node implementation that is optimised for mathjax embedded in HTML content. It is currently limited to LaTex to SVG conversion, but feel free to extend it :) | ||
A Node.js HTTP API to render MathJax equations in HTML content. | ||
|
||
Defaults port 8080. | ||
This service uses the MathJax-node implementation that is optimised for mathjax embedded in HTML content. It is currently limited to Tex to SVG conversion. | ||
|
||
Node usage: | ||
``` | ||
$ npm install | ||
$ node app.js | ||
``` | ||
## Getting started | ||
|
||
Test the server is working by doing a HTTP GET or navigate to http://localhost:8080 | ||
### Prerequisites | ||
|
||
``` | ||
$ curl http://localhost:8080 | ||
``` | ||
To run the API locally you must have the following: | ||
|
||
To post content to the service for conversion, put your content in the "input" field using a application/x-www-form-urlencoded format: | ||
1. [nvm](https://github.com/nvm-sh/nvm) installed: | ||
|
||
```shell | ||
brew install nvm | ||
``` | ||
|
||
Then add the following to your `~/.bashrc` or `~/.zshrc`: | ||
|
||
```shell | ||
export NVM_DIR="$HOME/.nvm" | ||
[ -s "$(brew --prefix nvm)/nvm.sh" ] && \. "$(brew --prefix nvm)/nvm.sh" | ||
[ -s "$(brew --prefix nvm)/etc/bash_completion.d/nvm" ] && \. "$(brew --prefix nvm)/etc/bash_completion.d/nvm" | ||
``` | ||
|
||
and reload your shell: | ||
|
||
```shell | ||
exec $SHELL -l | ||
``` | ||
|
||
2. The node version specified in [`.nvmrc`](./.nvmrc) installed through nvm: | ||
|
||
```shell | ||
nvm install | ||
``` | ||
|
||
### Build and run | ||
|
||
Once you have node installed, run the following to install the dependencies and run the server: | ||
|
||
```shell | ||
make debug | ||
``` | ||
$ curl --data "input=$ \\Gamma(z) = \\int_0^\\infty t^{z-1} $" http://localhost:8080 | ||
``` | ||
|
||
The API binds to port 8080, and is currently not configurable. | ||
|
||
### Test the API is running | ||
|
||
To test the API is running correctly: | ||
|
||
1. Test the server is working by doing a HTTP GET or navigate to http://localhost:8080: | ||
|
||
```shell | ||
curl http://localhost:8080 | ||
``` | ||
|
||
2. Test `POST`ing content to the service for conversion: | ||
|
||
```shell | ||
curl -X POST -H "Content-Type: text/plain" --data "input=$ Gamma(z) = int_0^infty t^{z-1} $" http://localhost:8080 | ||
``` | ||
|
||
## Licence | ||
|
||
Copyright © Crown Copyright ([Office for National Statistics](https://www.ons.gov.uk)) | ||
|
||
Released under MIT license, see [LICENCE](LICENCE.md) for details. |
Oops, something went wrong.