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

Make it all configurable. #3

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 4 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
py
node_modules
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
node_modules/
**/node_modules/
server.com
package-lock.json
31 changes: 7 additions & 24 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,20 @@ 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`, run `./build.sh`
and push it to a new repository.

# Credits

Expand Down
Loading