Skip to content

Commit

Permalink
Make it all configurable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jperon committed Mar 2, 2024
1 parent 72623b5 commit 1777905
Show file tree
Hide file tree
Showing 735 changed files with 116,909 additions and 61,214 deletions.
14 changes: 5 additions & 9 deletions .gitignore
@@ -1,9 +1,5 @@
py
node_modules
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
node_modules/
**/node_modules/
server.com
package.json
package-lock.json
30 changes: 6 additions & 24 deletions Readme.md
Expand Up @@ -6,37 +6,19 @@ Grist widget to directly develop custom widgets within Grist’s UI.

Within a Grist document, create a custom widget with url pointing to
`index.html`. For example:
https://jperon.github.io/grist/Grist-pug-py-widget/
https://jperon.github.io/grist/grist-pug-py-widget2/

Then edit the `PUG` and the `PY` parts. The `render_pug` function is
available to `PY`, and will render the `PUG` part with the variables
passed as arguments in a key/value object, for example:

```py
from browser import window
grist, render_pug = window.grist, window.render_pug

def onRecord(rec, *args):
render_pug({{"rec": rec}})

grist.onRecord(onRecord)
```
Then edit the `cfg` and other parts.

Then click on `Preview`, then `Install`. Once installed, the code
may be edited again by clicking on `Open configuration` in the widget's
top-right menu.

# Making changes

Dependencies:

- [Transcrypt](https://www.transcrypt.org/)
- [pug-cli](https://github.com/pugjs/pug-cli)

Building the Dockerfile within docker/ (`docker build -t pug_py docker`)
will make development environment ready: `docker run -it -v $PWD:/src pug_py`.
# Making a new "standalone" widget

Once changes are made to `index.pug` and `api.py`, run `./build.sh`.
This repository may be used as a template to create a new Grist custom widget.
After defining it as explained above, you might save the result within files
(for example below `/widget`), adapt `config.toml`, and push it to a new repository.

# Credits

Expand Down
175 changes: 0 additions & 175 deletions api.py

This file was deleted.

0 comments on commit 1777905

Please sign in to comment.