From 3c87e6585b77943bf129fac13617cba29d3552c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Tue, 12 Jan 2016 00:22:58 +0000 Subject: [PATCH] allow any type of attachments; fixed cordova build in docker --- ChangeLog | 21 ++++++ build-in-docker.conf | 3 + build-in-docker.sh | 17 +++++ ...PICOL-PIctorial-COmmunication-Language.svg | 58 +++++++++++++++ nodejs/public/javascripts/safechat.js | 72 ++++++++++++------- nodejs/public/stylesheets/safechat.css | 7 +- nodejs/views/index.ejs | 26 ++++--- 7 files changed, 161 insertions(+), 43 deletions(-) create mode 100644 nodejs/public/images/Document_sans_PICOL-PIctorial-COmmunication-Language.svg diff --git a/ChangeLog b/ChangeLog index ac77692..0f8c1b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2016-01-11 15:48 marc + + * cordova/makefile.am: removed cordova plugin in makefile + +2016-01-11 15:46 marc + + * nodejs/public/javascripts/openpgp.js, + nodejs/public/javascripts/openpgp.worker.js, + nodejs/public/javascripts/safechat.js, + nodejs/public/stylesheets/safechat.css, nodejs/sockets/index.js, + nodejs/views/index.ejs: some fixes; asynchronous message + decryption to keep browser responsive + +2016-01-11 10:48 marc + + * ChangeLog, nodejs/package.json.in, + nodejs/public/javascripts/safechat.js, + nodejs/public/stylesheets/safechat.css, nodejs/routes/index.js, + nodejs/sockets/index.js, nodejs/views/index.ejs: some small + fixes: grey-out send button if not ready + 2016-01-11 09:16 marc * nodejs/makefile.am: added forgotten makefile diff --git a/build-in-docker.conf b/build-in-docker.conf index 0e734e7..4bc8840 100644 --- a/build-in-docker.conf +++ b/build-in-docker.conf @@ -11,6 +11,9 @@ if test -n "${ANDROID_HOME}"; then commands+=("update-alternatives --install /usr/bin/node nodejs /usr/bin/nodejs 100") commands+=("wheezy:::curl https://www.npmjs.com/install.sh | sh") commands+=("npm install -g cordova") + commands+=("npm install -g bplist-parser") + commands+=("npm install -g path-is-absolute") + commands+=("npm install -g inflight") commands+=("chown $(id -u) ${HOME}") commands+=("chown -R $(id -u) ${HOME}/.npm") commands+=("useradd -d ${HOME} -u $(id -u) $(id -un)") diff --git a/build-in-docker.sh b/build-in-docker.sh index 4fc1652..a959c83 100755 --- a/build-in-docker.sh +++ b/build-in-docker.sh @@ -10,6 +10,7 @@ dirs=("-v $(pwd):/workdir") packages=() targets="all check distcheck" commands=() +wait=0 if test -e ./build-in-docker.conf; then # you can preconfigure the variables in file build-in-docker.conf # if you do so, add the file to EXTRA_DIST in makefile.am @@ -31,6 +32,7 @@ while test $# -gt 0; do echo " -d, --dir access given directory read only" echo " -p, --package install extra debian packages" echo " -c, --cmd execute commands as root in docker" + echo " -w, --wait on error keep docker container and wait for enter" echo echo " The options -r -k -e -d -p -c can be repeated several times." echo @@ -82,6 +84,9 @@ while test $# -gt 0; do (-c|--cmd) shift; commands+=("$1") ;; + (-w|--wait) + wait=1 + ;; (*) echo "**** ERROR: unknown option '$1', try --help" 1>&2 exit 1 @@ -113,6 +118,12 @@ function traperror() { fi echo fi + if [ "$wait" -eq 1 ]; then + echo " ... now you can access the docker container:" + echo " docker exec -it bash" + echo -n " ... press enter to cleanup: " + read + fi echo -n " ... cleanup docker: " docker rm -f "${DOCKER_ID}" echo "returning status: $e" @@ -120,6 +131,12 @@ function traperror() { exit $e fi done + if [ "$wait" -eq 1 ]; then + echo " ... now you can access the docker container:" + echo " docker exec -it bash" + echo -n " ... press enter to cleanup: " + read + fi echo -n " SUCCESS ... cleanup docker: " docker rm -f "${DOCKER_ID}" exit 0 diff --git a/nodejs/public/images/Document_sans_PICOL-PIctorial-COmmunication-Language.svg b/nodejs/public/images/Document_sans_PICOL-PIctorial-COmmunication-Language.svg new file mode 100644 index 0000000..771a703 --- /dev/null +++ b/nodejs/public/images/Document_sans_PICOL-PIctorial-COmmunication-Language.svg @@ -0,0 +1,58 @@ + +image/svg+xmlPICOL Icon2009-03-15Melih BilgilCreative Commons BY-SAPICOL - Pictorial Communication Languagehttp://blog.picol.orghttp://blog.picol.orgenPICOLiconiconssignGUIvectorinterfaceThis is one icon out of all PICOL iconsMelih Bilgil (www.lonja.de), Christopher Adjei (www.boffer.net) \ No newline at end of file diff --git a/nodejs/public/javascripts/safechat.js b/nodejs/public/javascripts/safechat.js index cb92f99..a1a407f 100644 --- a/nodejs/public/javascripts/safechat.js +++ b/nodejs/public/javascripts/safechat.js @@ -330,9 +330,19 @@ function clearmessage() { /// Display Image Attachments function attachments(files, id) { if (files) files.forEach(function(file) { + console.log(file); var img = document.createElement('img'); - img.src = file.content; - $(id).append(img); + img.title = file.name; + if (file.type.match('^image/')) { + img.src = file.content; + } else { + img.src = "images/Document_sans_PICOL-PIctorial-COmmunication-Language.svg"; + } + var a = document.createElement('a'); + a.href = file.content; + a.target = '_blank'; + a.appendChild(img); + $(id).append(a); }); } @@ -348,39 +358,47 @@ function fileupload(evt) { return error("your browser does not support file upload", true); for (var i=0, f; f=evt.target.files[i]; ++i) { var file = f; + console.log(file); var reader = new FileReader(); reader.onload = function(evt) { if (evt.target.error) return error("error reading file", true); if (evt.target.readyState==0) return notice("waiting for data …"); if (evt.target.readyState==1) return notice("loading data …"); - if (!file.type.match('^image/')) - return error(file.name+": not an image", true); - var img = document.createElement("img"); - img.onload = function() { - var MAX = 400; - var width = img.width; - var height = img.height; - if (width > MAX) { - height *= MAX / width; - width = MAX; - } - if (height > MAX) { - width *= MAX / height; - height = MAX; - } - var canvas = document.createElement("canvas"); - canvas.width = width; - canvas.height = height; - var ctx = canvas.getContext("2d"); - ctx.drawImage(img, 0, 0, width, height); + if (file.type.match('^image/')) { + var img = document.createElement("img"); img.onload = function() { - filecontent.push({type: file.type, content: img.src}); - $("#preview").append(img); - success('image of type '+file.type+' is ready to be sent'); + var MAX = 400; + var width = img.width; + var height = img.height; + if (width > MAX) { + height *= MAX / width; + width = MAX; + } + if (height > MAX) { + width *= MAX / height; + height = MAX; + } + var canvas = document.createElement("canvas"); + canvas.width = width; + canvas.height = height; + var ctx = canvas.getContext("2d"); + ctx.drawImage(img, 0, 0, width, height); + img.onload = function() { + filecontent.push({name:file.name, type: file.type, content: img.src}); + $("#preview").append(img); + success('image of type '+file.type+' is ready to be sent'); + } + img.title = file.name; + img.src = canvas.toDataURL(file.type); } - img.src = canvas.toDataURL(file.type); + img.src=evt.target.result; + } else { + filecontent.push({name:file.name, type: file.type, content: evt.target.result}); + var img = document.createElement("img"); + img.src = "images/Document_sans_PICOL-PIctorial-COmmunication-Language.svg"; + img.title = file.name; + $("#preview").append(img); } - img.src=evt.target.result; } reader.readAsDataURL(file); } diff --git a/nodejs/public/stylesheets/safechat.css b/nodejs/public/stylesheets/safechat.css index e2faaff..dbba77f 100644 --- a/nodejs/public/stylesheets/safechat.css +++ b/nodejs/public/stylesheets/safechat.css @@ -247,9 +247,12 @@ label[for=send] img { float: left; padding: .5ex 1ex .5ex 1ex; } -#msgs .msg img { +#msgs .msg .text img { + border-radius: 2ex; + -moz-border-radius: 2ex; + -webkit-border-radius: 2ex; display: block; - width: 99%; + width: 100%; } #preview img { diff --git a/nodejs/views/index.ejs b/nodejs/views/index.ejs index 7d402bb..9f5e49e 100644 --- a/nodejs/views/index.ejs +++ b/nodejs/views/index.ejs @@ -120,20 +120,18 @@ - + + + + + + + + + + + +