From ba9bfa583179c25aaef94b1f44da7eba74620b9a Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 16 Apr 2018 19:12:21 -0700 Subject: [PATCH] Datasette 0.19: plugin preview (with release notes) --- README.md | 1 + datasette/version.py | 2 +- docs/changelog.rst | 55 ++++++++++++++++++++++++++++++++++++++++++++ docs/plugins.rst | 8 +++++-- 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 956391c2..08e71cf9 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Some examples: https://github.com/simonw/datasette/wiki/Datasettes ## News +* 16th April 2018: [Datasette 0.19: plugins preview](https://github.com/simonw/datasette/releases/tag/0.19) * 14th April 2018: [Datasette 0.18: units](https://github.com/simonw/datasette/releases/tag/0.18) * 9th April 2018: [Datasette 0.15: sort by column](https://github.com/simonw/datasette/releases/tag/0.15) * 28th March 2018: [Baltimore Sun Public Salary Records](https://simonwillison.net/2018/Mar/28/datasette-in-the-wild/) - a data journalism project from the Baltimore Sun powered by Datasette - source code [is available here](https://github.com/baltimore-sun-data/salaries-datasette) diff --git a/datasette/version.py b/datasette/version.py index 514c36de..b5572ed6 100644 --- a/datasette/version.py +++ b/datasette/version.py @@ -1,2 +1,2 @@ -__version_info__ = (0, 18) +__version_info__ = (0, 19) __version__ = '.'.join(map(str, __version_info__)) diff --git a/docs/changelog.rst b/docs/changelog.rst index f5284f8a..96700e1f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,61 @@ Changelog ========= +0.19 (2018-04-16) +----------------- + +This is the first preview of the new Datasette plugins mechanism. Only two +plugin hooks are available so far - for custom SQL functions and custom template +filters. There's plenty more to come - read `the documentation +`_ and get involved in +`the tracking ticket `_ if you +have feedback on the direction so far. + +- Fix for ``_sort_desc=sortable_with_nulls`` test, refs `#216 `_ + +- Fixed `#216 `_ - paginate correctly when sorting by nullable column + +- Initial documentation for plugins, closes `#213 `_ + + https://datasette.readthedocs.io/en/latest/plugins.html + +- New ``--plugins-dir=plugins/`` option (`#212 `_) + + New option causing Datasette to load and evaluate all of the Python files in + the specified directory and register any plugins that are defined in those + files. + + This new option is available for the following commands:: + + datasette serve mydb.db --plugins-dir=plugins/ + datasette publish now/heroku mydb.db --plugins-dir=plugins/ + datasette package mydb.db --plugins-dir=plugins/ + +- Start of the plugin system, based on pluggy (`#210 `_) + + Uses https://pluggy.readthedocs.io/ originally created for the py.test project + + We're starting with two plugin hooks: + + ``prepare_connection(conn)`` + + This is called when a new SQLite connection is created. It can be used to register custom SQL functions. + + ``prepare_jinja2_environment(env)`` + + This is called with the Jinja2 environment. It can be used to register custom template tags and filters. + + An example plugin which uses these two hooks can be found at https://github.com/simonw/datasette-plugin-demos or installed using ``pip install datasette-plugin-demos`` + + Refs `#14 `_ + +- Return HTTP 405 on InvalidUsage rather than 500. [Russ Garrett] + + This also stops it filling up the logs. This happens for HEAD requests + at the moment - which perhaps should be handled better, but that's a + different issue. + + 0.18 (2018-04-14) ----------------- diff --git a/docs/plugins.rst b/docs/plugins.rst index b0056793..aae5ad51 100644 --- a/docs/plugins.rst +++ b/docs/plugins.rst @@ -3,7 +3,8 @@ Plugins Datasette's plugin system is currently under active development. It allows additional features to be implemented as Python code (or, soon, JavaScript) -which can be wrapped up in a separate Python package. +which can be wrapped up in a separate Python package. The underlying mechanism +uses `pluggy `_. You can follow the development of plugins in `issue #14 `_. @@ -110,7 +111,6 @@ To learn how to upload your plugin to `PyPI `_ for use by other people, read the PyPA guide to `Packaging and distributing projects `_. - Plugin hooks ------------ @@ -154,3 +154,7 @@ example: @hookimpl def prepare_jinja2_environment(env): env.filters['uppercase'] = lambda u: u.upper() + +You can now use this filter in your custom templates like so:: + + Table name: {{ table|uppercase }}