From 3960ec456021910ead8f4e65e59d4e764442822b Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sat, 24 Jan 2015 10:04:34 +0100 Subject: add the possibility to load binary projects dynamically --- binary.sh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'binary.sh') diff --git a/binary.sh b/binary.sh index 72c1ca2..259dd3a 100755 --- a/binary.sh +++ b/binary.sh @@ -7,7 +7,7 @@ fi if [[ $# < 2 ]] then - echo "Usage: binary.sh OPTION PLATFORM [FILE]" + echo "Usage: binary.sh OPTION PLATFORM [FILE/URL]" echo "" echo "OPTIONS:" echo " -m Mobile" @@ -17,7 +17,7 @@ then echo " Mobile amazon-fireos android blackberry10 firefoxos ios ubuntu wp8 win8 tizen" echo " Desktop win osx linux32 linux64" echo "" - echo "If FILE is given, it will be #open-ed inside Snap\! immediately" + echo "If FILE/URL is given, it will be #open-ed inside Snap\! immediately. URL will be loaded at runtime." exit 0 fi @@ -28,6 +28,7 @@ scriptdir=$(readlink -e ".") # UglifyJS2 (https://github.com/mishoo/UglifyJS2) ide=true +url=false platform=$2 # presentation mode @@ -40,9 +41,9 @@ if [ $ide == false ] then if [ -f "$3" ] then - content=$(cat $3) + content="'$(cat $3)'" else - ide=true + url=true fi fi @@ -63,16 +64,23 @@ then sed -i '/cloud\.js"/d' snap.html sed -i 's/gui\.js"/binary\.js"/' snap.html - # load custom project from file - sed -i '/sha512\.js"/a\ - ' snap.html + # load custom project from file or url + if [ $url == false ] + then + sed -i '/sha512\.js"/a\ + ' snap.html + + echo "var code =" > code.js + echo "$content" >> code.js + echo ";" >> code.js - echo "var code =" > code.js - echo "'$content'" >> code.js - echo ";" >> code.js + sed -i "/ide\.openIn/a\ + ide.droppedText(code); " snap.html + else + sed -i "/ide\.openIn/a\ + ide.droppedText(ide.getURL('$3')); " snap.html + fi - sed -i "/ide\.openIn/a\ - ide.droppedText(code); " snap.html else rm binary.js fi -- cgit v1.3.1