Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Have "code links" upload code to a service and generate an ID instead of sending raw code #60

Open
mattbrailsford opened this issue Mar 25, 2014 · 12 comments

Comments

@mattbrailsford
Copy link
Contributor

I was just thinking, max url length is around 2000 characters so are we going to be limited by how much code can be sent in a URL with the code links we added in #55

Maybe we could use github gists? or do you have any other ideas for sending larger amounts of code?

@gfwilliams
Copy link
Member

Hmm. It'd be nice to keep it in the URL wherever possible (especially as Espruino doesn't have that much memory anyway) - I think for now we could just refuse to make a URL that was too large - but Gist might be an idea.

I wonder what compressed and base64 encoded would get down to: http://stackoverflow.com/questions/294297/javascript-implementation-of-gzip

It'd be quite easy to implement...

@mattbrailsford
Copy link
Contributor Author

Yea, I wanted to start this issue just to get options being discussed really, as like I say, I think we could hit the limit really quickly.

I guess we could support both to be honest. If we capture /code as being raw code, but /gist could capture a gist snippet for things that are more complex?

I do like the idea of compression, but I'm also wondering how this would affect people linking code snippets from their site? Would they need to use a javascript widget type thing to do the compression and generating the link?

Matt

(I might have a go at that Gist lookup :))

@mattbrailsford
Copy link
Contributor Author

Cool, that was easy :)

Pull, reload, Click Me!

@gfwilliams
Copy link
Member

We could provide a bit of code that makes the URL from code blocks I guess - just a <script> tag that references a GitHub'd script. It'd be a nice way for people to do websites, and anyone who just wants a page can use the share link on the Web IDE.

By the way, just did some rough tests: http://jsfiddle.net/36hDP/3/

I can't seem to use btoa on lzw-encoded text (which seems a bit strange).

@gfwilliams
Copy link
Member

Neat! Now you just need to be able to automatically submit it :)

Also - we ought to think of a way of handling Blockly - I think that just looking for '' as the first 5 chars might be good enough?

@mattbrailsford
Copy link
Contributor Author

ooh yea, good thinking.

From a gist perspective, you can say you need to set a filename. If it ends with .js treat it as JS, if it ends in .xml or .blk or something, we can treat it as blocks?

From a code perspective though, I guess there are 2 options 1) parse it and look for a pattern or 2) have two urls ?code= is js and ?blocks= is blockly?

@gfwilliams
Copy link
Member

Sorry, I got markdown'd. All we need to do is to search for < xml > at the start - I think that's pretty safe in both cases?

@mattbrailsford
Copy link
Contributor Author

for the submitting thing within the IDE, I'd be tempted for that to be a custom webservice we call as I think it'll get abused with lots of dummy / throw away code snippets? or do you think it would be better to submit it to gist? (maybe under a specific account?)

@mattbrailsford
Copy link
Contributor Author

if that's how blockly files start then yea, can't see a problem with that (make sure you account for whitespace though)

@gfwilliams
Copy link
Member

Yeah, I was wondering about that. I think for now, just display a message that tells you how to paste your code into gist - as I guess you'll need a username to actually put code in yourself.

I guess if you've got such a big bit of code you probably know what you're doing anyway :)

@mattbrailsford
Copy link
Contributor Author

maybe just experiment first with how much you can get into a URL, then decide from there?

@mattbrailsford
Copy link
Contributor Author

yea, so maybe compress the code, check then length, and alert them saying it's too long, and they should try adding it to a gist with a link to documentation.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants