Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate custom plugins #13

Open
jperon opened this issue Sep 25, 2023 · 4 comments
Open

Integrate custom plugins #13

jperon opened this issue Sep 25, 2023 · 4 comments

Comments

@jperon
Copy link

jperon commented Sep 25, 2023

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.

@paulfitz
Copy link
Member

We're working on this actually!

@jperon
Copy link
Author

jperon commented Sep 25, 2023

Really, really great. I don’t know how to thank you for such a great piece of software.

@jperon
Copy link
Author

jperon commented Mar 8, 2024

@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?

@paulfitz
Copy link
Member

paulfitz commented Mar 8, 2024

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:
Screenshot from 2024-03-08 10-29-30

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):

Screenshot from 2024-03-08 10-39-00

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants