Wykres commitów

52 Commity (909c85cd2b64646edaaa8e3c19f5cd4e51a13fad)

Autor SHA1 Wiadomość Data
Simon Willison 909c85cd2b view_actions plugin hook, closes #2297 2024-03-12 14:25:28 -07:00
Simon Willison daf5ca02ca homepage_actions() plugin hook, closes #2298 2024-03-12 13:46:06 -07:00
Simon Willison 6ec0081f5d
`query_actions` plugin hook
* New query_actions plugin hook, closes #2283
2024-02-27 21:55:16 -08:00
Simon Willison bcc4f6bf1f
track_event() mechanism for analytics and plugins
* Closes #2240
* Documentation for event plugin hooks, refs #2240
* Include example track_event plugin in docs, refs #2240
* Tests for track_event() and register_events() hooks, refs #2240
* Initial documentation for core events, refs #2240
* Internals documentation for datasette.track_event()
2024-01-31 15:21:40 -08:00
Simon Willison c3caf36af7
Template slot family of plugin hooks - top_homepage() and others
New plugin hooks:

top_homepage
top_database
top_table
top_row
top_query
top_canned_query

New datasette.utils.make_slot_function()

Closes #1191
2024-01-30 19:54:03 -08:00
Simon Willison c7a4706bcc
jinja2_environment_from_request() plugin hook
Closes #2225
2024-01-05 14:33:23 -08:00
Simon Willison b645174271
actors_from_ids plugin hook and datasette.actors_from_ids() method (#2181)
* Prototype of actors_from_ids plugin hook, refs #2180
* datasette-remote-actors example plugin, refs #2180
2023-09-07 21:23:59 -07:00
Simon Willison 0b4a286914 render_cell(..., request) argument, closes #2007 2023-01-27 19:34:14 -08:00
Simon Willison 8bf06a76b5
register_permissions() plugin hook (#1940)
* Docs for permissions: in metadata, refs #1636
* Refactor default_permissions.py to help with implementation of #1636
* register_permissions() plugin hook, closes #1939 - also refs #1938
* Tests for register_permissions() hook, refs #1939
* Documentation for datasette.permissions, refs #1939
* permission_allowed() falls back on Permission.default, refs #1939
* Raise StartupError on duplicate permissions
* Allow dupe permisisons if exact matches
2022-12-12 18:05:54 -08:00
Simon Willison b40872f5e5 prepare_jinja2_environment(datasette) argument, refs #1809 2022-09-14 14:31:54 -07:00
Simon Willison c09c53f345 New handle_exception plugin hook, refs #1770
Also refs:
- https://github.com/simonw/datasette-sentry/issues/1
- https://github.com/simonw/datasette-show-errors/issues/2
2022-07-17 16:24:39 -07:00
Simon Willison 6373bb3414 Expose current SQLite row to render_cell hook, closes #1300 2022-07-07 09:30:49 -07:00
Simon Willison aa7f0037a4
filters_from_request plugin hook, now used in TableView
- New `filters_from_request` plugin hook, closes #473
- Used it to extract the logic from TableView that handles `_search` and
`_through` and `_where` - refs #1518

Also needed for this plugin work: https://github.com/simonw/datasette-leaflet-freedraw/issues/7
2021-12-17 11:02:14 -08:00
Simon Willison 30c18576d6 register_commands() plugin hook, closes #1449 2021-08-27 18:39:42 -07:00
Simon Willison a390bdf9ce Stop using firstresult=True on render_cell, refs #1425
See https://github.com/simonw/datasette/issues/1425#issuecomment-894883664
2021-08-08 17:38:42 -07:00
Simon Willison cd8b7bee8f Run codespell against datasette source code too, refs #1417 2021-08-03 10:03:48 -07:00
Simon Willison eccfeb0871 register_routes() plugin hook datasette argument, closes #1404 2021-07-26 16:16:46 -07:00
Simon Willison ea627baccf Removed fallback parameter from get_metadata, refs #1384 2021-06-26 17:02:42 -07:00
Brandon Roberts baf986c871
New get_metadata() plugin hook for dynamic metadata
The following hook is added:

    get_metadata(
      datasette=self, key=key, database=database, table=table,
      fallback=fallback
    )

This gets called when we're building our metdata for the rest
of the system to use. We merge whatever the plugins return
with any local metadata (from metadata.yml/yaml/json) allowing
for a live-editable dynamic Datasette.

As a security precation, local meta is *not* overwritable by
plugin hooks. The workflow for transitioning to live-meta would
be to load the plugin with the full metadata.yaml and save.
Then remove the parts of the metadata that you want to be able
to change from the file.

* Avoid race condition: don't mutate databases list

This avoids the nasty "RuntimeError: OrderedDict mutated during
iteration" error that randomly happens when a plugin adds a
new database to Datasette, using `add_database`. This change
makes the add and remove database functions more expensive, but
it prevents the random explosion race conditions that make for
confusing user experience when importing live databases.

Thanks, @brandonrobertz
2021-06-26 15:24:54 -07:00
Simon Willison b1fd24ac9f skip_csrf(datasette, scope) plugin hook, refs #1377 2021-06-23 15:40:09 -07:00
Simon Willison d23a267138 Make request available to menu plugin hooks, closes #1371 2021-06-09 21:45:24 -07:00
Miroslav Šedivý a882d67962
Modernize code to Python 3.6+ (#1158)
* Compact dict and set building
* Remove redundant parentheses
* Simplify chained conditions
* Change method name to lowercase
* Use triple double quotes for docstrings

Thanks, @eumiro!
2020-12-23 09:04:32 -08:00
Simon Willison 7b19492070 database_actions() plugin hook, closes #1077 2020-11-02 10:27:25 -08:00
Simon Willison f0a740ac21 Remove load_plugin hook - closes #1073
Refs #1042

This reverts commit 81dea4b07a.
2020-10-31 09:21:22 -07:00
Simon Willison 81dea4b07a
load_template() plugin hook
Closes #1042
2020-10-30 10:47:18 -07:00
Simon Willison 2f7731e9e5 table_actions() plugin hook plus menu, closes #1066
Refs #690
2020-10-29 22:16:41 -07:00
Simon Willison 18a64fbb29
Navigation menu plus menu_links() hook
Closes #1064, refs #690.
2020-10-29 20:45:15 -07:00
Simon Willison 3a4c8ed36a Added columns argument to various extra_ plugin hooks, closes #938 2020-08-16 11:09:53 -07:00
Simon Willison e3639247cd Standard arguments for extra_ plugin hooks, closes #939 2020-08-16 09:50:23 -07:00
Simon Willison 549b1c2063 New forbidden() plugin hook, closes #812 2020-06-30 21:17:38 -07:00
Simon Willison 563f5a2d3a
Magic parameters for canned queries
Closes #842

Includes a new plugin hook, register_magic_parameters()
2020-06-27 19:58:16 -07:00
Simon Willison 6c26345836 New plugin hook: canned_queries(), refs #852 2020-06-18 16:35:15 -07:00
Simon Willison 09a3479a54 New "startup" plugin hook, closes #834 2020-06-13 10:55:41 -07:00
Simon Willison f5e79adf26
register_routes() plugin hook (#819)
Fixes #215
2020-06-08 20:12:06 -07:00
Simon Willison 799c5d5357 Renamed resource_identifier to resource, refs #817 2020-06-08 11:59:53 -07:00
Simon Willison c9f1ec616e Removed resource_type from permissions system, closes #817
Refs #811, #699
2020-06-08 11:51:03 -07:00
Simon Willison 461c82838d Implemented actor_from_request with tests, refs #699
Also added datasette argument to permission_allowed hook
2020-05-31 18:16:42 -07:00
Simon Willison 060a56735c actor_from_request and permission_allowed hookspecs, refs #699 2020-05-31 18:16:42 -07:00
Simon Willison 6303ea5048 prepare_connection() now takes datasette and database args, refs #678 2020-02-21 17:32:40 -08:00
Simon Willison fcfcae21e6
extra_template_vars plugin hook (#542)
* extra_template_vars plugin hook

Closes #541

* Workaround for cwd bug

Based on https://github.com/pytest-dev/pytest/issues/1235#issuecomment-175295691
2019-07-05 17:05:56 -07:00
Simon Willison 4d2fdafe39 Added asgi_wrapper plugin hook, closes #520 2019-07-02 21:06:25 -07:00
Russ Garrett bf229c9bd8 Pass view_name to extra_body_script hook (#443)
At the moment it's not easy to tell whether the hook is being called
in (for example) the row or table view, as in both cases the
`database` and `table` parameters are provided.

This passes the `view_name` added in #441 to the `extra_body_script`
hook.
2019-05-03 09:12:19 -04:00
Simon Willison ea66c45df9
Extract facet code out into a new plugin hook, closes #427 (#445)
Datasette previously only supported one type of faceting: exact column value counting.

With this change, faceting logic is extracted out into one or more separate classes which can implement other patterns of faceting - this is discussed in #427, but potential upcoming facet types include facet-by-date, facet-by-JSON-array, facet-by-many-2-many and more.

A new plugin hook, register_facet_classes, can be used by plugins to add in additional facet classes.

Each class must implement two methods: suggest(), which scans columns in the table to decide if they might be worth suggesting for faceting, and facet_results(), which executes the facet operation and returns results ready to be displayed in the UI.
2019-05-02 17:11:26 -07:00
Russ Garrett cf406c0754 New plugin hook: register_output_renderer hook (#441)
Thanks @russss!

* Add register_output_renderer hook

This changeset refactors out the JSON renderer and then adds a hook and
dispatcher system to allow custom output renderers to be registered.

The CSV output renderer is untouched because supporting streaming
renderers through this system would be significantly more complex, and
probably not worthwhile.

We can't simply allow hooks to be called at request time because we need
a list of supported file extensions when the request is being routed in
order to resolve ambiguous database/table names. So, renderers need to
be registered at startup.

I've tried to make this API independent of Sanic's request/response
objects so that this can remain stable during the switch to ASGI. I'm
using dictionaries to keep it simple and to make adding additional
options in the future easy.

Fixes #440
2019-05-01 16:01:56 -07:00
Simon Willison b7c6a9f9bd
extra_css_urls(template, database, table, datasette)
The extra_css_urls and extra_js_urls hooks now take additional optional
parameters.

Also refactored them out of the Datasette class and into RenderMixin.

Plus improved plugin documentation to explicitly list parameters.
2018-08-28 11:56:57 +01:00
Simon Willison 2e836f72d9
render_cell(value, column, table, database, datasette)
The render_cell plugin hook previously was only passed value.

It is now passed (value, column, table, database, datasette).
2018-08-28 03:03:01 -07:00
Simon Willison 5cf0c6c91c
New plugin hook: extra_body_script 2018-08-28 02:02:49 -07:00
Simon Willison 0a14a4846b
Added plugin_config() method 2018-08-28 01:35:21 -07:00
Simon Willison 4ac9132240
render_cell(value) plugin hook, closes #352
New plugin hook for customizing the way cells values are rendered in HTML.

The first full example of this hook in use is https://github.com/simonw/datasette-json-html
2018-08-04 17:14:56 -07:00
Simon Willison dbbe707841
publish_subcommand hook + default plugins mechanism, used for publish heroku/now (#349)
This change introduces a new plugin hook, publish_subcommand, which can be
used to implement new subcommands for the "datasette publish" command family.

I've used this new hook to refactor out the "publish now" and "publish heroku"
implementations into separate modules. I've also added unit tests for these
two publishers, mocking the subprocess.call and subprocess.check_output
functions.

As part of this, I introduced a mechanism for loading default plugins. These
are defined in the new "default_plugins" list inside datasette/app.py

Closes #217 (Plugin support for datasette publish)
Closes #348 (Unit tests for "datasette publish")
Refs #14, #59, #102, #103, #146, #236, #347
2018-07-25 22:15:59 -07:00