Experimental load_metadata() hook, refs #357

This commit is contained in:
Simon Willison 2019-11-25 20:57:52 -08:00
commit d11fd2cbaa
5 changed files with 20 additions and 8 deletions

View file

@ -17,7 +17,8 @@ Options:
--cors Enable CORS by serving Access-Control-Allow-Origin: *
--load-extension PATH Path to a SQLite extension to load
--inspect-file TEXT Path to JSON file created using "datasette inspect"
-m, --metadata FILENAME Path to JSON file containing license/source metadata
-m, --metadata TEXT Path to JSON file containing license/source metadata, or
input to a metadata plugin
--template-dir DIRECTORY Path to directory containing custom templates
--plugins-dir DIRECTORY Path to directory containing custom plugins
--static MOUNT:DIRECTORY Serve static files from this directory at /MOUNT/...

View file

@ -813,3 +813,12 @@ This example plugin adds a ``x-databases`` HTTP header listing the currently att
await app(scope, recieve, wrapped_send)
return add_x_databases_header
return wrap_with_databases_header
.. _plugin_load_metadata:
load_metadata(metadata_value)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Return a Python dictionary of metadata configuration values. The ``metadata_value`` argument will be the value passed to the ``-m`` or ``--metadata`` argument to ``datasette serve``.
Only one plugin can implement this at a time. The first registered plugin will get to provide the metadata dictionary, while all other plugins will be ignored.