#!/bin/bash
FILE=offline.html
AFRAME=aframe-local.min.js
if [ ! -f "$AFRAME" ]; then
echo "$AFRAME does not exist. Make sure to run get-local-aframe first"
exit
fi
git clone --depth 1 https://github.com/networked-aframe/networked-aframe
cd networked-aframe/
cp package-glitch.json package.json
npm i
cd examples/
mkdir offline
cd offline/
wget $(grep 'script src="https' ../basic.html | grep -v aframe.min.js | sed "s/.*\(https.*\)\".*/\1/")
cd ..
cp -r ../../$AFRAME ../../local-fonts ../../local-models offline/
cp basic.html $FILE
sed "s/https.*aframe.min.js/offline\/aframe-local.min.js/" -i $FILE
sed "s/script src=\"https:.*[^<]\//script src=\"offline\//" -i $FILE
cd ..
echo "to test run : cd networked-aframe && node server/easyrtc-server.js"
echo "then visit http://localhost:8080/$FILE"