publiclab / Leaflet.DistortableImage

A Leaflet extension to distort or "rubber sheet" images
https://publiclab.github.io/Leaflet.DistortableImage/examples/
BSD 2-Clause "Simplified" License
265 stars 284 forks source link

?k= parameter for shorter shareable URLs? #1355

Closed jywarren closed 1 year ago

jywarren commented 1 year ago

Currently, and excitingly, we can now share maps like this:

https://publiclab.github.io/Leaflet.DistortableImage/examples/archive?json=https://ia601609.us.archive.org/33/items/empire-st-chinatown-providence/mapknitter-1676395083251.json

What if we also allowed sharing maps using only an Archive.org key? The URL could be much shorter:

https://publiclab.github.io/Leaflet.DistortableImage/examples/archive?k=empire-st-chinatown-providence

If we started serving this from a new repository or URL we could even do this maybe:

https://lite.mapknitter.org?k=empire-st-chinatown-providence

It would then act as if you'd entered the collection URL but would auto-load.

What do you all think?

segun-codes commented 1 year ago

Hi @jywarren, this URL https://lite.mapknitter.org?k=empire-st-chinatown-providence is quite simple and user-friendly too but it appears we could have this https://publiclab.github.io/Leaflet.DistortableImage/examples/archive?k=empire-st-chinatown-providence in the interim if lite.mapknitter.org is a long term plan. What do you say?

You know I could work to realize this https://publiclab.github.io/Leaflet.DistortableImage/examples/archive?k=empire-st-chinatown-providence if you think it makes sense in the context of what the long term plan is.

jywarren commented 1 year ago

That does make sense. If you can implement the k= parameter, then I can work on getting the subdomain set up! Thanks!

On Wed, Feb 22, 2023 at 11:11 AM Segun @.***> wrote:

Hi @jywarren https://github.com/jywarren, this URL https://lite.mapknitter.org?k=empire-st-chinatown-providence is quite simple and user-friendly too but it appears we could have this https://publiclab.github.io/Leaflet.DistortableImage/examples/archive?k=empire-st-chinatown-providence in the interim if lite.mapknitter.org is a long term plan. What do you say?

You know I could work to realize this https://publiclab.github.io/Leaflet.DistortableImage/examples/archive?k=empire-st-chinatown-providence if you think it makes sense in the context of what the long term plan is.

— Reply to this email directly, view it on GitHub https://github.com/publiclab/Leaflet.DistortableImage/issues/1355#issuecomment-1440327378, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF6J6XHSJ5ACVFIHQPL6TWYY3CPANCNFSM6AAAAAAU33NLCI . You are receiving this because you were mentioned.Message ID: @.***>

segun-codes commented 1 year ago

Please clarify, do you mean I could implement k=parameter for https://lite.mapknitter.org?k=empire-st-chinatown-providence? Many thanks!

jywarren commented 1 year ago

I thought if it's implemented for GitHub pages, it will also work for the subdomain as well, right? Thanks!

On Wed, Feb 22, 2023, 8:52 PM Segun @.***> wrote:

Please clarify, do you mean I could implement k=parameter for https://lite.mapknitter.org?k=empire-st-chinatown-providence? Many thanks!

— Reply to this email directly, view it on GitHub https://github.com/publiclab/Leaflet.DistortableImage/issues/1355#issuecomment-1441122701, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF6J4YKOXYCLDWXE7QZZDWY27FBANCNFSM6AAAAAAU33NLCI . You are receiving this because you were mentioned.Message ID: @.***>

segun-codes commented 1 year ago

Oh! yeah, sure it will. Okay, I will begin work on this.

segun-codes commented 1 year ago

Shorten URL-Type 1: https://publiclab.github.io/Leaflet.DistortableImage/examples/archive.html?k=empire-st-chinatown-providence (for legacy json files) Shorten URL-Type 2: https://publiclab.github.io/Leaflet.DistortableImage/examples/archive.html?k=mkl-2-2 (for mk-lite generated json files)

For shorten URL-Type 1 to work:

  1. "empire-st-chinatown-providence" must be the name of the json file;
  2. then URL is transformed into the download URL 'https://archive.org/download/mapknitter/empire-st-chinatown-providence.json';
  3. since all legacy json files are uploaded under the identifier "mapknitter".
  4. IA blocks this URL 'https://archive.org/download/mapknitter/', we can't fetch multiple json files in a request as we do with images.

For shorten URL-Type 2 to work:

  1. provide indicator suggesting map should be reconstructed from mk-lite generated json file (e.g., ...?k=mkl-2-2&i=mapknitter-0002.json or ...?k=mkl-2-2&i=mapknitter-001.json).
  2. "mkl-2-2" is the identifier and "mapknitter-0002.json"/"mapknitter-0001.json" is the json file to be downloaded.
  3. then the URL is transformed into the download URL 'https://archive.org/download/mkl-2-2/mapknitter-0002.json' or 'https://archive.org/download/mkl-2-2/mapknitter-0001.json'.
  4. IA blocks this URL https://archive.org/download/mkl-2-2/', we can't fetch multiple json files in a request as we do with images.

What do you think about this?

jywarren commented 1 year ago

Hmm, I actually hadn't thought about the legacy MapKnitter files related to this, but that is an interesting idea!

I was just thinking of scenario 2, where k = the key of an Archive.org collection, like: https://archive.org/details/empire-st-chinatown-providence

Since we already can load those directly like:

https://publiclab.github.io/Leaflet.DistortableImage/examples/archive?json=https://archive.org/download/empire-st-chinatown-providence/mapknitter-1676395083251.json

all we have to do is to find the name of the JSON file, which I think we already do because of #1351. So for this PR, I believe we just need to read the k=KEYNAME parameter, and begin using it the same way as if you'd pasted it in, then auto-detect the JSON file, which should already work. How does that sound?

Separately the idea of a short URL for legacy mapknitter maps is interesting, and we could open a second issue for that if you want! But I think maybe it's lower priority than some of the other things on our list, like code modularity and tests.

segun-codes commented 1 year ago

Okay, this approach sounds good.