Installing MLJS in to an existing application
WARNING: Currently MLJS can only run in a REST API application installed directly in to MarkLogic server. It cannot be integrated to an application on another server, or that sits on a port that is not a REST API instance in MarkLogic. In future I will implement W3C CORS support to bypass this.
You may have an existing Roxy application or just a few html pages installed in a REST Server instance. If you do and you want to use MLJS then how do you get started?
Thankfully I've created a handy script that downloads the latest MLJS browser files and installs them to a Roxy app folder of your choice.
- To get this script go to https://github.com/adamfowleruk/mljs and download the mljsme.sh file.
- Install this script in a useful location. I'm going to assume it's in /Users/adamfowler/Documents/utilities/mljsme.sh
- Open a terminal session and edit your bash profile: vi ~/.bash_profile
- Add this line to it: alias mljsme=/Users/adamfowler/Documents/utilities/mljsme.sh "$@"
- Save the file and quit vi
- Exit all current terminals (only new terminals will pick up the alias)
Installing MLJS in to a Roxy Hybrid application
The mljsme script when executed will check for a -d option. This specifies the root folder of the Roxy app that MLJS should be installed in. i.e. the one that contains a 'src' and 'deploy' folder. If a -d option is not specified then mljsme assumes the present working directory is where your Roxy app resides.
- Open a terminal window
- cd in to your existing Roxy Hybrid application's folder
mljsmeand hit enter
Installing MLJS in a vanilla REST Server instance
WARNING: As of Fri 09 Aug 2013 the -j, -i and -c options are not working as expected. Please check back for updates, or suggest a fix yourself.
What does MLJSME do?
The script does several things in order:-
- Creates a new temporary directory for downloaded files
- Downloads the latest mljs-browser.tar.gz distribution file from MLJS GitHub
- Unpacks this in the temporary folder
- Copies the relevant files to the folders specified (Will always overwrite existing files with same names)
- Cleans up the temporary files created
Please let me know how you get on with this script.