increpare / PuzzleScript

Open Source HTML5 Puzzle Game Engine
MIT License
903 stars 159 forks source link

Load scripts into play.html from arbitrary URLs #545

Closed Brinsky closed 3 years ago

Brinsky commented 4 years ago

Alongside loading from gists, allow reading scripts from an arbitrary URL. My use case is to keep my scripts in a proper Github project (e.g. https://github.com/Brinsky/pware-skeg) and not have to worry about updating a corresponding gist when making changes. I can imagine others wanting to host scripts on their own site or on an alternative VCS host.

My initial thought is to supply a URL via a (encoded) param to play.html, so that an author can link players to it directly, e.g. https://www.puzzlescript.net/play.html?s=https%3A%2F%2Fraw.githubusercontent.com%2FBrinsky%2Fpware-skeg%2Fmaster%2Fscript.txt.

Other thoughts:

Happy to contribute this if it seems valuable.

increpare commented 4 years ago

Hi,

thanks for the not unreasonable suggestion and thoughtful writeup of it. This sounds pretty niche to me, and I worry about running into scary CORS\caching-related tech support issues if I do try to support it.

I do understand wanting to have projects nicely organised. Hmmm....I'm going to let the suggestion stew a bit...it seems a bit, even best-case scenario, not a very elegant way of working...

Happy to contribute this if it seems valuable. Thank you for the offer! Right now I'd probably not be into supporting it, but let's see. I'll leave the issue open for the time being.

S

Am Mo., 13. Juli 2020 um 23:11 Uhr schrieb Brian Stottler < notifications@github.com>:

Alongside loading from gists, allow reading scripts from an arbitrary URL. My use case is to keep my scripts in a proper Github project (e.g. https://github.com/Brinsky/pware-skeg) and not have to worry about updating a corresponding gist when making changes. I can imagine others wanting to host scripts on their own site or on alternative VCS host.

My initial thought is to supply a URL via a (encoded) param to play.html, so that an author can link players to it directly, e.g. https://www.puzzlescript.net/play.html?s=https%3A%2F%2Fraw.githubusercontent.com%2FBrinsky%2Fpware-skeg%2Fmaster%2Fscript.txt .

Other thoughts:

  • Shouldn't have auth or API support of any kind
  • Using this URL param alongside the one for gists (p) should throw an error or at least have well-defined behavior
  • Should also support loading scripts this way into editor.html (with no change in the supported sharing/exporting options)
    • The "hack" button in play.html should be updated accordingly to point to the correct editor link
  • Documentation https://github.com/increpare/PuzzleScript/blob/master/Documentation/permanent_urls.html should be updated
  • Ideally there would be a button somewhere to create these links, but I haven't thought of a good place for it - putting it in the editor seems to confusing
    • People who really care about this feature can probably be bothered to encode the URLs themselves

Happy to contribute this if it seems valuable.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/increpare/PuzzleScript/issues/545, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADRVYELXJO5LVQOBBBMYR3R3N2A5ANCNFSM4OY3Y7OA .

Brinsky commented 4 years ago

Right now I'd probably not be into supporting it, but let's see. I'll leave the issue open for the time being.

Sounds good.

I worry about running into scary CORS\caching-related tech support issues

Good point. As far as I know CORS policy is up to individual server owners, but that doesn't mean people won't complain about it e.g. to you instead. As a cursory experiment, I used www.test-cors.org to confirm that www.github.com refuses cross origin requests but that raw.githubusercontent.com (which can be used to access raw files in GitHub repos) allows them.

increpare commented 3 years ago

I have decided this is too hairy for me to look into in terms of potential long-term maintenance burden. The gist scheme is relatively simple, and is unlikely to break, and if it does break it's one thing for me to fix.

It's on the user side a fair suggestion though, and if I were more comfortable with corsy things I'd likely not have such worry about it. Thanks for the suggestion and offer of help again.

Brinsky commented 3 years ago

Wanted to mention that I found a decent alternative approach - using a Github Action that automatically updates a Gist when a corresponding repository is pushed.

See https://github.com/Brinsky/Upstairs-Downstairs/blob/main/.github/workflows/deploy.yml