# Nix will execute this script with bash when asked to build the static web app.

# We assume that minified sources (which are checked into the git repo) have already been built.
# (the scripts in the toplevel 'scripts' directory take care of this)

# This 'build' only depends on 2 things
#   - 'coreutils' (mkdir, cp)
#   - src/main/webapp to copy things from

export PATH="$coreutils/bin"

# The environment variable 'out' points to the file or directory that is the result of the build. We aim to create a directory that contains the static part of the web app:
mkdir $out

cd $src_webapp # = src/main/webapp

cp -r images $out/images
cp -r js $out/js
cp -r math $out/math
cp -r mxgraph $out/mxgraph # contains minified version of mxGraph
cp -r plugins $out/plugins
cp -r myPlugins $out/myPlugins
cp -r resources $out/resources
cp -r styles $out/styles

cp disableUpdate.js $out/disableUpdate.js
cp dropbox.html $out/dropbox.html
cp electronFilesWorker.js $out/electronFilesWorker.js
cp electron.js $out/electron.js
cp export3.html $out/export3.html
cp export-fonts.css $out/export-fonts.css
cp favicon.ico $out/favicon.ico
cp github.html $out/github.html
cp gitlab.html $out/gitlab.html
cp index.html $out/index.html
cp onedrive3.html $out/onedrive3.html
cp open.html $out/open.html
cp service-worker.js $out/service-worker.js
cp shortcuts.svg $out/shortcuts.svg
cp vsdxImporter.html $out/vsdxImporter.html
