web-maker icon indicating copy to clipboard operation
web-maker copied to clipboard

Permanent URL support

Open MrCoder opened this issue 7 years ago • 15 comments

It would nice if I can click a perm-link to open a page. For example - https://webmakerapp.com/item/asdfasdfasdfasdfasdf.

MrCoder avatar May 19 '18 04:05 MrCoder

I get the point, but curious if in your case you need the URL for yourself or to share with someone else?

chinchang avatar May 19 '18 13:05 chinchang

It's for sharing. In my mind is something like what codesandbox.io or jsfiddle has. One may share it on stackoverflow for example.

MrCoder avatar May 21 '18 11:05 MrCoder

I'd like the URL available just for personal use paired with the local-only saves.

ajvsol avatar Jun 21 '18 21:06 ajvsol

do you have the plan for this feature?

vanloc0301 avatar Oct 01 '18 20:10 vanloc0301

This would also be useful for us, for teaching purposes . Cf. the clone features on jsbin and other code sandbox projects, which gives unique URL's for projects owned by different users, and also provides snaphsot URL's that preserve project history.

titaniumbones avatar Nov 13 '18 00:11 titaniumbones

I am starting thought process on this to figure out the implementation details and if this can land in 4.0 itself. Would love to have inputs from everyone. Here are some initial points on top of my head:

  • Currently Web Maker, being offline first, caches all assets locally and serves them from service worker. This can continue to work as it is on share-able urls.
  • But once share-able urls land, people would want to embed the creations on other web pages. This case would be quite different because 1) Internet can be assumed there 2) It should not require to cache all assets first and then generate client side preview through service worker. It should be quick and any preprocessing shouldn't require loading the transpilers on browser. A lightweight version of the app would be suitable for embeds.
  • App uses firebase module to fetch data from database. But if the firebase libraries are loaded on browser for the embeds also, it would be too heavy. We might needs some API endpoint to fetch creations, possibily precompiled code.

chinchang avatar Nov 16 '18 08:11 chinchang

Re the last point, firebase libraries are cached the first time they are loaded and should be fast enough from then on. It is important that same process is followed for App and Embedded from my point of view.

MrCoder avatar Mar 02 '19 11:03 MrCoder

My previous response is not very clear. Let me rephrase it. I think embedding and permanent link are two related functionalities. For example, on WordPress, there are sharable links and no embedding. From my point of view, point two and three are not valid. Just my two cents.

MrCoder avatar Sep 04 '19 09:09 MrCoder

I think links could share data like the TS playground does, by encoding it in base64 or something in the url: https://www.typescriptlang.org/play?#code/PTAEBEEMDcEsBNQHdIGdQAsCmAnLQ

I might play around with a PR for this 👀

david-shortman avatar Mar 05 '21 01:03 david-shortman

@david-shortman That is definitely not base64 :) I think it is a usual ID generated to associate to some code stored in the backend. Also, storing code in the URL will have limit on the number of characters we can have in the URL.

chinchang avatar Mar 05 '21 04:03 chinchang

@chinchang Whoops my bad, I don't know what kind of encoding it is.

However, it is some type of encoded data, as the URL increases in size the more code I put in:

https://www.typescriptlang.org/play?#code/MYewdgzgLgBAlhAwgCwE4gLYFMYF4YCEA7nGACYhEDaARAEbpERao0C6MAZJ4QcGpiwBuAFAB6MTAAKqLADMWMKMhwYQsmNACG5LajIwABg0rNUhmHXnqcKdNhgBBKQEkRoSLBNNF+BHcEYAH4YfnscAC4YEnJKWm8zdlEAGyxYYGS4YABraBYAUTAtOlSDfDktZOZREVTYBABlLFTgKDhwAFkQMixC4tK8GAqq4Vq00MyclzAoFgA3SsHkkGBKhqh1LQBzLAA6HagXWYwAChoMrNzZ1ERJ7OnrheSaAEpRODkYE747h-nKl4wADeIhgE0uf1QT0GAGYAAwI0QAX1qKzWG1Q2z2zEOxzOFxyeRuvxm-2eABpwVNSVCATU6lTsiwXGRyaClHBsAAZLTQW6XLCs9nJXlQAASIDmLEF+VS2BmbLBEGQIAArskyAA5LAADyg-JyTRaUEcYFlWHlUEVmmaWFaMrlWBmEAAKiADdlBkCkTUPNAYLbLa7kFooAB1aUAEQQ-UFAHkwFIsVyQFoyjAKMBVZbdnRugBPXYAR1VLHzRrtGMcyWSJ3ZNAAVBEyDGSoKaCI3iIxulMk6oAANSkXfsATUpIugQ5gk6go5qclVYFa7TAMFkailEqlqDFcC2yEyB6gJ0D-cBILBHy+Z5mF-ZYNvUF20HzqVz6h6qCWou30rI5qWgAQp+LCiGCKIoiImbZv2uxpgBUozFyCCzGALBnGoqrMJuWA0JSp5IVAgK4AAfMCwqigOgwjjMA7gTOoqjjRfYzPO7K0YOgxYERuycfRHGsXO3G8Zx7HsteJyN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2NPnJD0BSc0K8TyXMTsHyccfkI4KJgCfkNDpGEKaDvdoSY5EASATWOAakHoNAYIvKSMFSR8fBGQAsMuKbqofCnIQoUoayfaY6cTDHqoVyQqXCYsbyV8Zhg0C6HGFIEcWKWcS4JqKsYaapPLmyuUD-qdHAQPggc8QGbacqZ8RhvyS6BqaKeibGfGWukma2vgO1KvmWk0SPpmf6TaUqcsSGTQCiU9i9miecWGdicDpqI4EBNdsCXhkNhADLnzlmU2UGbmXye2V2WcT2ZqYgI4IgGKN9g9prgJtiaOAmUqGrvHmbvriANCaRjUJ7uoTbpiHbgcNoeIVcCwAnq8BlG6WAUoReQ3teVuniHeUSI+S8AUkAA

david-shortman avatar Mar 05 '21 05:03 david-shortman

A random StackOverflow answer says to keep URLs under 2000 characters, and my above example breaks that (over 4000 characters), but still works on my up-to-date Chrome.

Probably for any sufficiently large code, a URL won't cut it for cross-browser compatibility, but for sharing snippets that are only a few hundred lines of code, it may work.

david-shortman avatar Mar 05 '21 05:03 david-shortman

Probably more sharing use cases could be covered by https://github.com/chinchang/web-maker/issues/292, so I'll look at that, too

david-shortman avatar Mar 05 '21 05:03 david-shortman

You are right! We can at least have this for small snippets! Looking forward to your PR. This reminds me, I did a similar thing in another project where I compressed the content first before putting in the URL...that can gets us more code. You can refer that here -> https://github.com/chinchang/picssel-art/blob/master/picssel.js#L354

chinchang avatar Mar 05 '21 07:03 chinchang

First, I'd like to thank you for such a great and inspiring project.

I have recently implemented a similar feature in my project LocalPen. It was indeed similar to typescript playground sharing feature.

You can try it on the development build here (settings menu > share): https://dev.localpen.io/

An object representing the current state of the code is compressed using LZString and added to the URL as hash preceded by the string code/. The URL is copied to clipboard to be ready for sharing. When the URL is loaded, if a hash containing the string code/ is found, the following hash is decompressed and loaded as the state object.

share: https://github.com/hatemhosny/localpen/blob/32c15e4c8fdfef8df306bddc529e52540bdf614a/src/localpen/app.ts#L548

load: https://github.com/hatemhosny/localpen/blob/32c15e4c8fdfef8df306bddc529e52540bdf614a/src/localpen/import/code.ts

compress/decompress https://github.com/hatemhosny/localpen/blob/32c15e4c8fdfef8df306bddc529e52540bdf614a/src/localpen/utils.ts#L93

hatemhosny avatar Mar 05 '21 09:03 hatemhosny