Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Ability to import code samples into Sandcastle #3702

Closed
pjcozzi opened this issue Mar 11, 2016 · 6 comments
Closed

Ability to import code samples into Sandcastle #3702

pjcozzi opened this issue Mar 11, 2016 · 6 comments

Comments

@pjcozzi
Copy link
Contributor

pjcozzi commented Mar 11, 2016

Perhaps using

  • (shortened) encoded urls (for import and export), or
  • GitHub gists

as discussed offline with @mramato.

Does anyone want to mentor @TomPed on this?

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Mar 22, 2016

@kring any chance you have time to provide @TomPed some guidance here based on your experience with TerriaJS?

@kring
Copy link
Member

kring commented Mar 23, 2016

I'm not sure if our experiences with TerriaJS will be much help, but I'll tell you what I know...

Our "share" function (go to nationalmap.gov.au, turn on some datasets, and press the Share button) works by encoding the state of the application in the URL. That makes for some giant URLs, so we also use the Google URL Shortener to make them short.

But actually we use it in a weird way, so that the web browser never actually sees the long URL. The code is here:
https://github.com/TerriaJS/terriajs/blob/master/lib/Models/GoogleUrlShortener.js

Our application uses the API to look up a shortened URL by key, and then decodes that URL and uses the data stored within it. The browser never actually visits the long URL. So in effect, we're just using the URL shortener as a simple data store. In theory we could use any other data store - gists or whatever.

I can't really say we did a ton of analysis before choosing the URL shortener versus something else. URLs were politically easier than something like gists, so that was probably the main reason. The Google shortener API also had pretty high free usage limits, so that helped. And when we originally tested it out, there didn't seem to be a practical limit on the length of the pre-shortened URL. However, I think we have now noticed a limit with some of our longer URLs, so test it out for yourself before you go that way.

I'd suggest the following desirable characteristics:

  • No or high limits on the number of things that can be saved and the number of times that saved things can be accessed.
  • No updating allowed. New share links / Sandcastle examples can be created, but existing ones can never be changed. This is important if you're not going to do any kind of authentication.
  • Not prone to abuse, or abuse is someone else's problem. It's trivial to set up a database on AWS or elsewhere with the desired no-updates-allowed behavior, but then what stops a malicious person from filling it up with garbage? Presumably services like the Google URL Shortener have anti-abuse logic already.

@kring
Copy link
Member

kring commented Mar 23, 2016

Here's the code that interprets the expanded URL (without visiting it):
https://github.com/TerriaJS/terriajs/blob/master/lib/Models/Terria.js#L508

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Mar 23, 2016

Thanks @kring. @TomPed can you research this approach and look into how much code can be included? Also evaluate compared to gists.

@TomPed
Copy link
Contributor

TomPed commented Mar 23, 2016

@pjcozzi will do. Thanks again @kring.

@pjcozzi
Copy link
Contributor Author

pjcozzi commented Apr 1, 2016

CC #2152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants