Workbench icon indicating copy to clipboard operation
Workbench copied to clipboard

Support a URI scheme, to open demos from online documentation

Open andyholmes opened this issue 2 years ago • 7 comments

Loading example content from external sources is a complicated topic, and would involve thinking about a lot of security implications and committing to stable file formats.

On the other hand, if we can add support for a URI scheme something like workbench://demo/List View, we can link to interactive demos in Workbench from websites like gjs.guide easily and safely.

andyholmes avatar Jul 20 '23 20:07 andyholmes

Similar https://github.com/sonnyp/Workbench/issues/181

I think there are 2 options

  1. The code is encoded in the uri so it is provided by the website and only requested to be opened in Workbench

  2. The uri is a "link" to a specific demo in Workbench

1 could work if we had multiple Workbench versions workbench44://... otherwise we'll have issues with outdated code and breaking changes in Workbench / GNOME

2 works too but it makes the tutorials somewhat depend on Workbench

wdyt?

sonnyp avatar Jul 31 '23 15:07 sonnyp

  1. The code is encoded in the uri so it is provided by the website and only requested to be opened in Workbench

Possible, but I think there's fairly small upper-limit and multiple files might be a problem.

  1. The uri is a "link" to a specific demo in Workbench

This is more what I was thinking, especially considering security implications of importing arbitrary code.

It's possible to define a set of trusted domains like gjs.guide, vala.dev, developer.gnome.org. Maybe that's a more maintainable way to go?

andyholmes avatar Aug 01 '23 21:08 andyholmes

We might want to support both

1st for small snippets and 2nd for well-defined examples

Probably makes more sense to start with 2nd. Maybe the HIG is a good starting place ?

It's possible to define a set of trusted domains like gjs.guide, vala.dev, developer.gnome.org. Maybe that's a more maintainable way to go?

Workbench doesn't know the origin. We would have to implement some complex token thingy.

sonnyp avatar Aug 01 '23 22:08 sonnyp

Workbench doesn't know the origin. We would have to implement some complex token thingy.

I think we could just handle workbench://vala.dev/something, then rewrite it to https://vala.dev/something before downloading. Then we're just using well-known domains and tested encryption.

But we can also just start with workbench://hig/patterns/controls/buttons. That should be easy to map to built-in demos, and we can later add support for parsing the first path element as a known domain later.

andyholmes avatar Aug 01 '23 22:08 andyholmes

Ha ok so Workbench would download the example from the website, interesting.

sonnyp avatar Aug 01 '23 22:08 sonnyp

See also: https://gitlab.gnome.org/ewlsh/gjs-guide/-/issues/40

andyholmes avatar Aug 04 '23 03:08 andyholmes

Postponed for now:

https://matrix.to/#/!kDBZrVKCdhrVuWxbGe:matrix.org/$18474sTznVydhYZCugb1JxYtAWRQ02NaNUg3O37yYDo?via=gnome.org&via=matrix.org&via=fedora.im

sonnyp avatar Sep 25 '23 18:09 sonnyp