{"html_url": "https://github.com/simonw/datasette/releases/tag/0.14", "id": 8841695, "node_id": "MDc6UmVsZWFzZTg4NDE2OTU=", "tag_name": "0.14", "target_commitish": "main", "name": "Datasette 0.14: customization edition", "draft": 0, "author": {"value": 9599, "label": "simonw"}, "prerelease": 0, "created_at": "2017-12-10T01:33:24Z", "published_at": "2017-12-10T01:41:14Z", "body": "The theme of this release is customization: Datasette now allows every aspect of its presentation [to be customized](http://datasette.readthedocs.io/en/latest/custom_templates.html) either using additional CSS or by providing entirely new templates.\r\n\r\nDatasette's [metadata.json format](http://datasette.readthedocs.io/en/latest/metadata.html) has also been expanded, to allow per-database and per-table metadata. A new `datasette skeleton` command can be used to generate a skeleton JSON file ready to be filled in with per-database and per-table details.\r\n\r\nThe `metadata.json` file can also be used to define [canned queries](http://datasette.readthedocs.io/en/latest/sql_queries.html#canned-queries), as a more powerful alternative to SQL views.\r\n\r\n - `extra_css_urls`/`extra_js_urls` in metadata\r\n \r\n A mechanism in the `metadata.json` format for adding custom CSS and JS urls.\r\n \r\n Create a `metadata.json` file that looks like this:\r\n \r\n {\r\n \"extra_css_urls\": [\r\n \"https://simonwillison.net/static/css/all.bf8cd891642c.css\"\r\n ],\r\n \"extra_js_urls\": [\r\n \"https://code.jquery.com/jquery-3.2.1.slim.min.js\"\r\n ]\r\n }\r\n \r\n Then start datasette like this:\r\n \r\n datasette mydb.db --metadata=metadata.json\r\n \r\n The CSS and JavaScript files will be linked in the `
` of every page.\r\n \r\n You can also specify a SRI (subresource integrity hash) for these assets:\r\n \r\n {\r\n \"extra_css_urls\": [\r\n {\r\n \"url\": \"https://simonwillison.net/static/css/all.bf8cd891642c.css\",\r\n \"sri\": \"sha384-9qIZekWUyjCyDIf2YK1FRoKiPJq4PHt6tp/ulnuuyRBvazd0hG7pWbE99zvwSznI\"\r\n }\r\n ],\r\n \"extra_js_urls\": [\r\n {\r\n \"url\": \"https://code.jquery.com/jquery-3.2.1.slim.min.js\",\r\n \"sri\": \"sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g=\"\r\n }\r\n ]\r\n }\r\n \r\n Modern browsers will only execute the stylesheet or JavaScript if the SRI hash matches the content served. You can generate hashes usingThis line renders the original block:
\r\n {{ super() }}\r\n {% endblock %}\r\n\r\n - `--static` option for datasette serve ([\\#160](https://github.com/simonw/datasette/issues/160))\r\n \r\n You can now tell Datasette to serve static files from a specific location at a specific mountpoint.\r\n \r\n For example:\r\n \r\n datasette serve mydb.db --static extra-css:/tmp/static/css\r\n \r\n Now if you visit this URL:\r\n \r\n http://localhost:8001/extra-css/blah.css\r\n \r\n The following file will be served:\r\n \r\n /tmp/static/css/blah.css\r\n\r\n - Canned query support.\r\n \r\n Named canned queries can now be defined in `metadata.json` like this:\r\n \r\n {\r\n \"databases\": {\r\n \"timezones\": {\r\n \"queries\": {\r\n \"timezone_for_point\": \"select tzid from timezones ...\"\r\n }\r\n }\r\n }\r\n }\r\n \r\n These will be shown in a new \"Queries\" section beneath \"Views\" on the database page.\r\n\r\n - New `datasette skeleton` command for generating `metadata.json` ([\\#164](https://github.com/simonw/datasette/issues/164))\r\n\r\n - `metadata.json` support for per-table/per-database metadata ([\\#165](https://github.com/simonw/datasette/issues/165))\r\n \r\n Also added support for descriptions and HTML descriptions.\r\n \r\n Here's an example metadata.json file illustrating custom per-database and per-table metadata:\r\n \r\n {\r\n \"title\": \"Overall datasette title\",\r\n \"description_html\": \"This is a description with HTML.\",\r\n \"databases\": {\r\n \"db1\": {\r\n \"title\": \"First database\",\r\n \"description\": \"This is a string description & has no HTML\",\r\n \"license_url\": \"http://example.com/\",\r\n \"license\": \"The example license\",\r\n \"queries\": {\r\n \"canned_query\": \"select * from table1 limit 3;\"\r\n },\r\n \"tables\": {\r\n \"table1\": {\r\n \"title\": \"Custom title for table1\",\r\n \"description\": \"Tables can have descriptions too\",\r\n \"source\": \"This has a custom source\",\r\n \"source_url\": \"http://example.com/\"\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n - Renamed `datasette build` command to `datasette inspect` ([\\#130](https://github.com/simonw/datasette/issues/130))\r\n\r\n - Upgrade to Sanic 0.7.0 ([\\#168](https://github.com/simonw/datasette/issues/168))\r\n \r\n