Commit graph

22 commits

Author SHA1 Message Date
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
436b8bc1d1 Datasette 0.27 2019-01-31 19:47:05 -08:00
Simon Willison
909cc8fbdf New 'datasette plugins' command to list installed plugins 2019-01-26 12:01:16 -08:00
Simon Willison
5b02611512
Corrected import path in plugin docs 2019-01-08 16:25:29 -08:00
Simon Willison
57a71377c9
Releasing Datasette 0.25 2018-09-19 19:48:12 +02:00
Simon Willison
1f54e09230
Better docs for publish_subcommand() plugin hook 2018-08-28 11:59:50 +01: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
Simon Willison
72a7ae6859
Datasette 0.20: static assets and templates for plugins 2018-04-20 07:32:02 -07:00
Simon Willison
b52171db1e
Plugins can now bundle custom templates, closes #224
Refs #14
2018-04-18 22:50:27 -07:00
Simon Willison
6e28ed447f
Thanks to #214 JavaScript is no longer 'soon' 2018-04-18 08:17:20 -07:00
Simon Willison
7581320823
Documentation for --install option, refs #223 2018-04-18 08:05:06 -07:00
Simon Willison
f8f818711b
Formatting tweak 2018-04-17 21:30:58 -07:00
Simon Willison
1c36d07dd4
New plugin hooks: extra_css_urls() and extra_js_urls()
Closes #214
2018-04-17 20:12:21 -07:00
Simon Willison
0bb483ca5b
/-/static-plugins/PLUGIN_NAME/ now serves static/ from plugins
Refs #214
2018-04-17 19:32:48 -07:00
Simon Willison
ba9bfa5831
Datasette 0.19: plugin preview (with release notes) 2018-04-16 19:12:21 -07:00
Simon Willison
904f1c75a3
Initial documentation for plugins, closes #213
https://datasette.readthedocs.io/en/latest/plugins.html
2018-04-16 08:12:09 -07:00