mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
JavaScript Plugin API, providing custom panels and column menu items
Thanks, Cameron Yick. https://github.com/simonw/datasette/pull/2052 Co-authored-by: Simon Willison <swillison@gmail.com>
This commit is contained in:
parent
4b534b89a5
commit
452a587e23
6 changed files with 399 additions and 19 deletions
21
demos/plugins/example_js_manager_plugins.py
Normal file
21
demos/plugins/example_js_manager_plugins.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from datasette import hookimpl
|
||||
|
||||
# Test command:
|
||||
# datasette fixtures.db \ --plugins-dir=demos/plugins/
|
||||
# \ --static static:demos/plugins/static
|
||||
|
||||
# Create a set with view names that qualify for this JS, since plugins won't do anything on other pages
|
||||
# Same pattern as in Nteract data explorer
|
||||
# https://github.com/hydrosquall/datasette-nteract-data-explorer/blob/main/datasette_nteract_data_explorer/__init__.py#L77
|
||||
PERMITTED_VIEWS = {"table", "query", "database"}
|
||||
|
||||
|
||||
@hookimpl
|
||||
def extra_js_urls(view_name):
|
||||
print(view_name)
|
||||
if view_name in PERMITTED_VIEWS:
|
||||
return [
|
||||
{
|
||||
"url": f"/static/table-example-plugins.js",
|
||||
}
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue