AngryTribble / Star-Trek-Attack-Wing-Utopia

6 stars 4 forks source link

*Future Project* URL Link Size #27

Open AngryTribble opened 1 year ago

AngryTribble commented 1 year ago

Need to figure out a way to minimize the size of the URL that gets created when people make fleets. Currently everyone is using bitly or tinyurl to shrink the active url links down. Here is an example of a fully built fleet url link that has not been run through bitly or tinyurl:

https://angrytribble.github.io/Star-Trek-Attack-Wing-Utopia/staw-utopia/index.html#eyJzaGlwcyI6W3siaWQiOiJzaGlwOlMyNjgiLCJjYXB0YWluIjp7ImlkIjoiY2FwdGFpbjpDYXA4MDQiLCJ1cGdyYWRlU2xvdHMiOlt7fSx7ImlkIjoiY3JldzpDMjg3In1dfSwidXBncmFkZXMiOlt7ImlkIjoidGVjaDpUMTc5In0seyJpZCI6IndlYXBvbjpXMTgzIn0seyJpZCI6ImNyZXc6QzE4OSJ9LHsiaWQiOiJjcmV3OkMyOTAifV19LHsiaWQiOiJzaGlwOlMzNDciLCJjYXB0YWluIjp7ImlkIjoiY2FwdGFpbjpDYXA4MDYiLCJ1cGdyYWRlU2xvdHMiOlt7fSx7fV19LCJ1cGdyYWRlcyI6W3siaWQiOiJ3ZWFwb246VzE2NyJ9LHsiaWQiOiJ3ZWFwb246VzE4MyJ9LHsiaWQiOiJjcmV3OkMxNzQifSx7ImlkIjoiY3JldzpDMzc3In1dfSx7ImlkIjoic2hpcDpTMzUwIiwiY2FwdGFpbiI6eyJpZCI6ImNhcHRhaW46Q2FwNzMwIiwidXBncmFkZVNsb3RzIjpbe31dfSwidXBncmFkZXMiOlt7ImlkIjoidGVjaDpUMjc2In0se30seyJpZCI6IndlYXBvbjpXMTgzIn0se30se31dfV19

catsgotmytongue commented 1 year ago

the part after the '#' character seems to be a string that represents the fleet as built with a base64 encoded json string like this:

{"ships":[{"id":"ship:S268","captain":{"id":"captain:Cap804","upgradeSlots":[{},{"id":"crew:C287"}]},"upgrades":[{"id":"tech:T179"},{"id":"weapon:W183"},{"id":"crew:C189"},{"id":"crew:C290"}]},{"id":"ship:S347","captain":{"id":"captain:Cap806","upgradeSlots":[{},{}]},"upgrades":[{"id":"weapon:W167"},{"id":"weapon:W183"},{"id":"crew:C174"},{"id":"crew:C377"}]},{"id":"ship:S350","captain":{"id":"captain:Cap730","upgradeSlots":[{}]},"upgrades":[{"id":"tech:T276"},{},{"id":"weapon:W183"},{},{}]}]}

this means you would need some kind of data store that would be independent of github pages to store or some other service which could make a tiny url hash and translate it to something utopia could use.

Relequestual commented 1 year ago

I HAVE one set up for my own use on another project. I use a pre compression specifically for JSON data. I can share the code for this and the solution.

I could share the back end, but I currently use it for said other project, and decoupling it later could be tricky (although not impossible).

When I DO eventually move it to a proper data store system of my own design, I'd be happy to allow that to be used. It would practically cost nothing extra and has a minimal cost to maintain.

Here's the code: https://github.com/Relequestual/json-schema-dev/blob/master/src/utilities/shortner.js

The comrpession is something we could use today. The shortURL service is an off the shelf PHP solution, so easy and cheap, but not ideal long term (although it HAS been a few years now).

I did quite a lot of research at the time as I'll need to store longer stuff in the URL and you hit a limit on what will work with all browsers.