diff --git a/.gitignore b/.gitignore index 4ff7cc8d4..78b126172 100644 --- a/.gitignore +++ b/.gitignore @@ -41,9 +41,12 @@ lib/* js/copayBundle.js config.js -webapp -chrome-extension -firefox-addon + +webapp/webapp +chrome/copay-chrome-extension +chrome/copay-chrome-extension.zip +firefox/firefox-addon + version.js android/package diff --git a/chrome/README.md b/chrome/README.md new file mode 100644 index 000000000..981137717 --- /dev/null +++ b/chrome/README.md @@ -0,0 +1,9 @@ +System Requirements + +* Just run: + +``` +$ sh chrome/build.sh +``` + +* The copay-chrome-extension.zip is into ./chrome folder diff --git a/chrome/build.sh b/chrome/build.sh new file mode 100644 index 000000000..c00dbe0cb --- /dev/null +++ b/chrome/build.sh @@ -0,0 +1,56 @@ +#! /bin/bash + +# Description: This script compiles and copy the needed files to later package the application for Chrome + +OpenColor="\033[" +Red="1;31m" +Yellow="1;33m" +Green="1;32m" +CloseColor="\033[0m" + +# Check function OK +checkOK() { + if [ $? != 0 ]; then + echo "${OpenColor}${Red}* ERROR. Exiting...${CloseColor}" + exit 1 + fi +} + +# Configs +BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +APPDIR="$BUILDDIR/copay-chrome-extension" +ZIPFILE="copay-chrome-extension.zip" +VERSION=`git describe --tags --abbrev=0 | cut -c 2-` + +# Move to the build directory +cd $BUILDDIR + +# Create/Clean temp dir +echo "${OpenColor}${Green}* Checking temp dir...${CloseColor}" +if [ -d $APPDIR ]; then + rm -rf $APPDIR +fi + +mkdir -p $APPDIR + +# Re-compile copayBundle.js +echo "${OpenColor}${Green}* Generating copay bundle...${CloseColor}" +grunt --target=dev shell +checkOK + +# Copy all chrome-extension files +echo "${OpenColor}${Green}* Copying all chrome-extension files...${CloseColor}" +sed "s/APP_VERSION/$VERSION/g" manifest.json > $APPDIR/manifest.json +checkOK + +cd $BUILDDIR/.. +cp -af {css,font,img,js,lib,sound,config.js,version.js,index.html,./popup.html} $APPDIR +checkOK + +# Zipping chrome-extension +echo "${OpenColor}${Green}* Zipping all chrome-extension files...${CloseColor}" +cd $BUILDDIR +zip -r $ZIPFILE "`basename $APPDIR`" +checkOK + +echo "${OpenColor}${Yellow}\nAwesome! We have a brand new Chome Extension, enjoy it!${CloseColor}" diff --git a/manifest.json b/chrome/manifest.json similarity index 100% rename from manifest.json rename to chrome/manifest.json diff --git a/firefox/README.md b/firefox/README.md new file mode 100644 index 000000000..06e602e8a --- /dev/null +++ b/firefox/README.md @@ -0,0 +1,13 @@ +System Requirements + +* Download [Add-on SDK](https://addons.mozilla.org/en-US/developers/builder) +* Install it. [Mozilla Docs](https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Installation) + +Run + +``` +$ sh firefox/build.sh +``` + +- Copy the content of firefox/firefox-addon (lib, data, package.json) to your development path. +- Compile the XPI file [Mozilla Docs](https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_started) diff --git a/firefox/build.sh b/firefox/build.sh new file mode 100644 index 000000000..c09a56c9d --- /dev/null +++ b/firefox/build.sh @@ -0,0 +1,51 @@ +#! /bin/bash + +# Description: This script compiles and copy the needed files to later package the application for Firefox + +OpenColor="\033[" +Red="1;31m" +Yellow="1;33m" +Green="1;32m" +CloseColor="\033[0m" + +# Check function OK +checkOK() { + if [ $? != 0 ]; then + echo "${OpenColor}${Red}* ERROR. Exiting...${CloseColor}" + exit 1 + fi +} + +# Configs +BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +APPDIR="$BUILDDIR/firefox-addon" +ZIPFILE="copay-firefox-addon.zip" +VERSION=`git describe --tags --abbrev=0 | cut -c 2-` + +# Move to the build directory +cd $BUILDDIR + +# Create/Clean temp dir +echo "${OpenColor}${Green}* Checking temp dir...${CloseColor}" +if [ -d $APPDIR ]; then + rm -rf $APPDIR +fi + +mkdir -p "$APPDIR/data" + +# Re-compile copayBundle.js +echo "${OpenColor}${Green}* Generating copay bundle...${CloseColor}" +grunt --target=dev shell +checkOK + +# Copy all chrome-extension files +echo "${OpenColor}${Green}* Copying all firefox-addon files...${CloseColor}" +sed "s/APP_VERSION/$VERSION/g" package.json > $APPDIR/package.json +checkOK + +cd $BUILDDIR/.. +cp -af {css,font,img,js,lib,sound,config.js,version.js,index.html,./popup.html} "$APPDIR/data" +cp -af "$BUILDDIR/lib" $APPDIR +checkOK + +echo "${OpenColor}${Yellow}\nAwesome! We have a brand new Firefox Addon, enjoy it!${CloseColor}" diff --git a/firefox/lib/main.js b/firefox/lib/main.js new file mode 100644 index 000000000..c5a200d3f --- /dev/null +++ b/firefox/lib/main.js @@ -0,0 +1,43 @@ +var { ToggleButton } = require('sdk/ui/button/toggle'); +var panels = require('sdk/panel'); +var self = require('sdk/self'); + +var panelScript = "window.addEventListener('click', function(event) {" + + " var t = event.target;" + + " if (t.nodeName == 'A')" + + " self.port.emit('click-link');" + + "}, false);" + +var button = ToggleButton({ + id: 'copay-addon', + label: 'Copay', + icon: { + '16': './img/icons/icon-16.png', + '32': './img/icons/icon-32.png', + '64': './img/icons/icon-64.png' + }, + onChange: handleChange +}); + +var panel = panels.Panel({ + contentURL: self.data.url('popup.html'), + contentScript: panelScript, + onHide: handleHide, + height: 150 +}); + +function handleChange(state) { + if (state.checked) { + panel.show({ + position: button + }); + } +} + +function handleHide() { + button.state('window', {checked: false}); +} + +panel.port.on('click-link', function(url) { + panel.hide(); +}); diff --git a/firefox/package.json b/firefox/package.json new file mode 100644 index 000000000..e6a8ff3cf --- /dev/null +++ b/firefox/package.json @@ -0,0 +1,10 @@ +{ + "name": "copay-addon", + "title": "Copay", + "id": "jid1-shqjFWBfQ0pYhQ", + "description": "A multisignature Bitcoin wallet", + "author": "", + "license": "MIT", + "version": "APP_VERSION" +} + diff --git a/util/generate-app-extension.sh b/util/generate-app-extension.sh deleted file mode 100755 index fff25d41f..000000000 --- a/util/generate-app-extension.sh +++ /dev/null @@ -1,101 +0,0 @@ -#! /bin/bash - -#Description: A simple script to compile and copy only the needed files for the web app. - -ROOTDIR=`pwd` -BASENAME=`basename $ROOTDIR` - -if [ $BASENAME = "util" ]; then - # Moving to root path - cd ../ -fi - -# Configs -APPDIR="./webapp" -VERSION=`git describe --tags --abbrev=0 | cut -c 2-` -CHROMEDIR="./chrome-extension" -FIREFOXDIR="./firefox-addon" - -LIBDIR="$APPDIR/lib" -DOWNLOADDIR="$APPDIR/download" -CHROMEDOWNLOADDIR="$DOWNLOADDIR/chrome" -FIREFOXDOWNLOADDIR="$DOWNLOADDIR/firefox" - -ZIPFILE="copay.zip" -CHROMEZIPFILE="copay-chrome-extension.zip" - -OpenColor="\033[" -Red="1;31m" -Yellow="1;33m" -Green="1;32m" -CloseColor="\033[0m" - -# Check function OK -checkOK() { - if [ $? != 0 ]; then - echo -e "${OpenColor}${Red}* ERROR. Exiting...${CloseColor}" - exit 1 - fi -} - -# Create/Clean temp dir -echo -e "${OpenColor}${Green}* Checking temp dir...${CloseColor}" -if [ -d $APPDIR ]; then - rm -rf $APPDIR -fi - -mkdir -p $APPDIR - -# Create/Clean chrome-extension dir -if [ -d $CHROMEDIR ]; then - rm -rf $CHROMEDIR -fi - -mkdir -p $CHROMEDIR - -# Create/Clean chrome-extension dir -if [ -d $FIREFOXDIR ]; then - rm -rf $FIREFOXDIR -fi - -mkdir -p $FIREFOXDIR - -# Re-compile copayBundle.js -echo -e "${OpenColor}${Green}* Generating copay bundle...${CloseColor}" -grunt --target=dev shell -checkOK - -# Copy all app files -echo -e "${OpenColor}${Green}* Copying all app files...${CloseColor}" -cp -af {css,font,img,js,lib,sound,config.js,version.js,index.html} $APPDIR -checkOK - -# Copy all chrome-extension files -echo -e "${OpenColor}${Green}* Copying all chrome-extension files...${CloseColor}" -sed "s/APP_VERSION/$VERSION/g" manifest.json > $CHROMEDIR/manifest.json -cp -af {css,font,img,js,lib,sound,config.js,version.js,index.html,popup.html} $CHROMEDIR -checkOK - -# Copy all firefox-addon files -echo -e "${OpenColor}${Green}* Copying all firefox-addon files...${CloseColor}" -cp -af {css,font,img,js,lib,sound,config.js,version.js,index.html,popup.html} $FIREFOXDIR -checkOK - -# Zipping apps -echo -e "${OpenColor}${Green}* Zipping all app files...${CloseColor}" -zip -r $ZIPFILE $APPDIR -checkOK - -# Zipping chrome-extension -echo -e "${OpenColor}${Green}* Zipping all chrome-extension files...${CloseColor}" -zip -r $CHROMEZIPFILE $CHROMEDIR -checkOK - -mkdir -p $CHROMEDOWNLOADDIR -mkdir -p $FIREFOXDOWNLOADDIR -mv $ZIPFILE $DOWNLOADDIR -mv $CHROMEZIPFILE $CHROMEDOWNLOADDIR -cp index-download-chrome.html $CHROMEDOWNLOADDIR/index.html -cp index-download-firefox.html $FIREFOXDOWNLOADDIR/index.html - -echo -e "${OpenColor}${Yellow}\nAwesome! Now you have the webapp in ./webapp and the chrome extension files in ./webapp/download/.${CloseColor}" diff --git a/webapp/build.sh b/webapp/build.sh new file mode 100644 index 000000000..351751a15 --- /dev/null +++ b/webapp/build.sh @@ -0,0 +1,65 @@ +#! /bin/bash + +# Description: This script compiles and copy the needed for the web application + +OpenColor="\033[" +Red="1;31m" +Yellow="1;33m" +Green="1;32m" +CloseColor="\033[0m" + +# Check function OK +checkOK() { + if [ $? != 0 ]; then + echo "${OpenColor}${Red}* ERROR. Exiting...${CloseColor}" + exit 1 + fi +} + +# Configs +BUILDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +APPDIR="$BUILDDIR/webapp" +ZIPFILE="copay.zip" +VERSION=`git describe --tags --abbrev=0 | cut -c 2-` + +DOWNLOADDIR="$APPDIR/download" +CHROMEDOWNLOADDIR="$DOWNLOADDIR/chrome" +FIREFOXDOWNLOADDIR="$DOWNLOADDIR/firefox" +ZIPFILE="copay.zip" + + +# Move to the build directory +cd $BUILDDIR + +# Create/Clean temp dir +echo "${OpenColor}${Green}* Checking temp dir...${CloseColor}" +if [ -d $APPDIR ]; then + rm -rf $APPDIR +fi + +mkdir -p $APPDIR + +# Re-compile copayBundle.js +echo "${OpenColor}${Green}* Generating copay bundle...${CloseColor}" +grunt --target=dev shell +checkOK + +# Copy all chrome-extension files +echo "${OpenColor}${Green}* Copying all chrome-extension files...${CloseColor}" +cd $BUILDDIR/.. +cp -af {css,font,img,js,lib,sound,config.js,version.js,index.html} $APPDIR +checkOK + +# Zipping chrome-extension +echo "${OpenColor}${Green}* Zipping all webapp files...${CloseColor}" +cd $BUILDDIR +zip -r $ZIPFILE "`basename $APPDIR`" +checkOK + +mkdir -p $CHROMEDOWNLOADDIR +mkdir -p $FIREFOXDOWNLOADDIR +mv $ZIPFILE $DOWNLOADDIR +cp "$BUILDDIR/index-download-chrome.html" $CHROMEDOWNLOADDIR/index.html +cp "$BUILDDIR/index-download-firefox.html" $FIREFOXDOWNLOADDIR/index.html + +echo "${OpenColor}${Yellow}\nAwesome! We have a brand new Webapp, enjoy it!${CloseColor}" diff --git a/index-download-chrome.html b/webapp/index-download-chrome.html similarity index 100% rename from index-download-chrome.html rename to webapp/index-download-chrome.html diff --git a/index-download-firefox.html b/webapp/index-download-firefox.html similarity index 100% rename from index-download-firefox.html rename to webapp/index-download-firefox.html