Open jperon opened 1 year ago
We're working on this actually!
Really, really great. I don’t know how to thank you for such a great piece of software.
@paulfitz As said here, if I may give some help on that point, it would be with pleasure. Would you have guidelines about it, please?
Thanks @jperon. One useful step might be to document what has already been done? To write up the brief notes I gave in https://community.getgrist.com/t/grist-omnibus-integrate-image-data-in-markdown-html-from-self-hosted-lan/4381/8?u=paul-grist, I needed to poke around in the test I excerpted there, since although technically I wrote this code everything about it has been pushed out of my memory by more recent work :-).
I did a quick experiment to see if I could add an offline widget to the latest version of grist-electron
. First, I ran it and saw this:
2024-03-08 09:47:06.589 - info: No plugins found in directory: /home/paulfitz/.grist/plugins
2024-03-08 09:47:06.595 - info: Found 1 valid plugins on the system
2024-03-08 09:47:06.595 - debug: PLUGIN builtIn/core -- /tmp/.mount_grist-Mnpmmq/resources/app.asar.unpacked/core/plugins/core
That No plugins found in directory: /home/paulfitz/.grist/plugins
line looks useful, it looks like I could try sticking in a widget there. (Pretty sure there is also an environment variable that controls where Grist will look for plugins)
So I added this file in ~/.grist/plugins/extra-widgets/manifest.yml
:
name: My Widgets
components:
widgets: widgets.json
Then I added this file in ~/.grist/plugins/extra-widgets/widgets.json
:
[{
"name": "Paul test",
"url": "./paul.html",
"widgetId": "paulfitz/widget-paul",
"published": true,
"renderAfterReady": false
}]
Then I added this file in ~/.grist/plugins/extra-widgets/paul.html
:
<html>
<body style="background: red;">
Hello this is Paul's test widget
</body>
</html>
Then I restarted grist-electron
, and saw this during startup:
2024-03-08 10:28:03.605 - info: Found 2 valid plugins on the system
2024-03-08 10:28:03.605 - debug: PLUGIN installed/extra-widgets -- /home/paulfitz/.grist/plugins/extra-widgets
2024-03-08 10:28:03.605 - debug: PLUGIN builtIn/core -- /tmp/.mount_grist-3iribT/resources/app.asar.unpacked/core/plugins/core
That extra line about extra-widgets is encouraging. Then in the app when I go to add a widget I see:
However if I add my widget, it doesn't quite work yet, it looks all blank. Checking document.getElementsByTagName('iframe')[0]
gives a URL with plugins.invalid
as the domain name, which isn't good.
Setting GRIST_TRUST_PLUGINS=1
and rerunning grist-electron
gets past this hurdle (but grist-electron should really be tweaked so this isn't necessary, it should be an easy fix):
Most of what I've said applies to grist-core
too I'd expect, since this behavior is implemented there. There's another side to the story where the grist-widget
repo can be used to assemble collections of widgets, but that story is longer.
One of the main features of Grist-electron, IMHO, is the ability to work offline. It would be great if there was a way to integrate custom plugins within it, so that they’re available without needing an internet connection.