googlecreativelab / coder

A simple way to make web stuff on Raspberry Pi
http://goo.gl/coder
Apache License 2.0
2.42k stars 276 forks source link

Not able to create/export/delete/import "hello world" app #51

Closed jda2000 closed 10 years ago

jda2000 commented 10 years ago

Steps to reproduce:

1) Create app (no editing) 2) Export app 3) Delete app 4) Import app

Result: alert box that says: The page at https://coder.local says: This doesn't appear to be a Coder project zip file coder_reimport

jmstriegel commented 10 years ago

Can you tell me what's inside your zip file and can you post the contents of your meta.json file? The zip should have this stuff in it:

/app/app.js
/app/meta.json
/views/index.html
/static/css/index.css
/static/js/index.js
/static/media/

Also, I assume this is a stock coder device and you haven't changed anything on the pi's filesystem. Let me know if that's not the case.

jda2000 commented 10 years ago

https://db.tt/FP0PCzZt

Oops! Looks like I lied about it being a virginal hello world app.

Here's the zip file.

jda2000 commented 10 years ago

Oh, that's embarrassing. That's the one where I was trying to make a second page and put a dead link in thinking coder would just add the page. Let me re-test tomorrow and actually do what I thought I was doing.

jda2000 commented 10 years ago

OK, I can now confirm I followed the steps exactly (Name & create)/(export & delete)/(upload & fail) Same error message. Were you able to get it to fail with the above-linked-to zip file?

jda2000 commented 10 years ago

The install is just a few days old. I don't think I've changed anything vi ssh. In fact, there are only 18 lines in the bash history and nothing that changes anything.

1  dpkg -l '*'
2  dpkg -l '*' | grep '^ii' | less
3  exit
4  top
5  ps -e
6  ps
7  df -h
8  ls /home
9  ls /home/pi

10 ls /home/coder 11 sudo ntstat -a 12 sudo netstat -a 13 sudo netstat -a | less 14 sudo netstat -a -p | less 15 sudo netstat -a -p -n | less 16 exit 17 sudo poweroff 18 history

dnlopez commented 10 years ago

The import process is failing at this point in coder-apps/pi/coder/static/js/index.js (which incidentally, runs on the client):

    if (!importfile.type.match('application/zip')) {
        alert('This doesn\'t appear to be a Coder project zip file');
        return false;
    }

'importfile' is something the browser passed to you from the 'change' event of an <input type="file"> and 'importfile.type' in my case is "", hence the fail.

According to recent specs, importfile.type is supposed to be the browser's guess at the file type, reported as a MIME type string. If the browser fails to recognize the file it is allowed to return an empty string.

So it turns out that both Chrome and Firefox here on Windows just now are not able to recognize my (freshly exported) Coder ZIP files as ZIP files, and are reporting their type as an empty string.

Coder should let this case pass seeing as the browser's file type sniffing is not guaranteed to work anyway. After changing the line above to

    if (!(importfile.type == '' || importfile.type.match('application/zip'))) {

I was able to import projects successfully.

By the way, I tried to push this change to the repo (on a new branch of my own, naturally, named 'export_fix') in preparation for a pull request, but Git wouldn't finish the push no matter what I did.

"Permission to googlecreativelab/coder.git denied to dnlopez."

Latest version of Git, tried it on Linux as well, HTTPS url, SSH url. Always that. Which is a different message to what I got if I deliberately entered my password wrong. Is this repo somehow closed to pushes? This is only the second time I've tried to push to a Github repo so forgive my noobness. The first time went fine though.

dnlopez commented 10 years ago

While I'm here on my Linux machine, I thought I'd do some further browser tests.

Linux Chromium v32.0.1700.77 (244343) - identifies file type as "application/zip". File import works!

Linux Firefox v26.0 - identifies file type as "application/unknown". So the file does not import, even with the addition I suggested above. Removing the type 'check' altogether is probably the way to go since browsers are clearly just all over the shop on this at the moment.

I'ma boot back to Windows to recap my results there with added version numbers...

Windows Chromium v26.0.1373.0 (174757) - identifies file type as "".

Windows Chromium (dev) v34.0.1788.0 - identifies file type as "".

Windows Firefox v26.0 - identifies file type as "application/unknown" (which is different to what I said before, isn't it. I guess I was mistaken back then. Because now I've got an alert() right in there to pop up this information clearly so I'm pretty sure I'm right this time).

No joy on Windows at all then.

jda2000 commented 10 years ago

Kudos, dnlopez!

shday commented 10 years ago

Chrome is returning 'application/x-zip-compressed' for me, which also fails. The following code fixed it:

if (!importfile.type.search('zip')) {
        alert('This doesn\'t appear to be a Coder project zip file');
        return false;
    }
plietar commented 10 years ago

Firefox 28.0 on OS X 10.9 gives me application/x-7z-compressed

jmstriegel commented 10 years ago

Sorry for the slow turnaround here. I think I have this patched and tested. I'll put up a new image soon, but if you want to get this manually: sudo su coder -s /bin/bash cd ~/coder-dist/ git pull cd coder-apps sh install_pi ../coder_base/

Please holler if you still have issues here.

jmstriegel commented 10 years ago

I've just uploaded Coder v0.6 which corrects this issue. Get it here: http://googlecreativelab.github.io/coder/#download

Closing this issue, but please re-open and let me know if you continue to encounter any errors with this.