Wykres commitów

49 Commity (69c6e953231078ab18ba0807e5fe2a4e20e84093)

Autor SHA1 Wiadomość Data
Simon Willison 69c6e95323 Fixed a bunch of unused imports spotted with ruff 2024-02-06 17:27:20 -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 4535568f2c Fixed display of database color
Closes #2139, closes #2119
2023-08-10 22:16:19 -07: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 78dad236df
check_visibility can now take multiple permissions into account
Closes #1829
2022-10-23 19:11:33 -07:00
Simon Willison 1a7750eb29 Documented datasette.check_visibility() method, closes #1678 2022-03-21 12:01:37 -07:00
Simon Willison 194e4f6c3f Removed check_permission() from BaseView, closes #1677
Refs #1660
2022-03-21 11:41:56 -07:00
Simon Willison 61419388c1 Rename route match groups for consistency, refs #1667, #1660 2022-03-19 09:52:08 -07:00
Simon Willison d4f60c2388
Remove hashed URL mode
Also simplified how view class routing works.

Refs #1661
2022-03-18 17:12:03 -07:00
Simon Willison 8584993529 --cors Access-Control-Allow-Headers: Authorization
Refs #1467, refs https://github.com/simonw/datasette-auth-tokens/issues/4
2021-10-14 12:03:28 -07:00
Simon Willison dd5ee8e668 Removed some unused imports
I found these with:

    flake8 datasette | grep unus
2021-07-15 23:26:12 -07:00
Guy Freeman 0f41db1ba8
Avoid error sorting by relationships if related tables are not allowed
Refs #1306
2021-06-01 21:25:27 -07:00
Simon Willison 5a15197960
/db/table/-/blob/pk/column.blob download URL, refs #1036 2020-10-24 16:09:18 -07:00
Simon Willison 310c3a3e05 New datasette.urls URL builders, refs #904 2020-10-19 17:33:59 -07:00
Simon Willison a648bb82ba Upgrade to Black 20.8b1, closes #958 2020-09-02 15:24:55 -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 5598c5de01 Database list on index page respects table/view permissions, refs #811 2020-06-08 11:34:14 -07:00
Simon Willison ab14b20b24 Get tests working again 2020-06-08 10:16:24 -07:00
Simon Willison 177059284d New request.actor property, refs #811 2020-06-08 10:05:32 -07:00
Simon Willison 1cf86e5ecc Show padlock on private index page, refs #811 2020-06-08 07:18:47 -07:00
Simon Willison e18f8c3f87 New check_visibility() utility function, refs #811 2020-06-08 06:49:55 -07:00
Simon Willison 9b42e1a4f5 view-database permission
Also now using 🔒 to indicate private resources - resources that
would not be available to the anonymous user. Refs #811
2020-06-07 20:50:37 -07:00
Simon Willison 4340845754 Nested permission checks for all views, refs #811 2020-06-07 13:03:08 -07:00
Simon Willison 86dec9e8ff Added permission check to every view, closes #808 2020-06-06 22:30:36 -07:00
Simon Willison 7f5a330377
Don't count rows on homepage for DBs > 100MB (#688)
Closes #649.
2020-02-28 17:08:29 -08:00
Tobias Kunze 908fc3999e Sort databases on homepage by argument order - #591
Closes #585 - thanks, @rixx!
2019-10-13 20:52:33 -07: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 ba8db9679f
Port Datasette from Sanic to ASGI + Uvicorn (#518)
Datasette now uses ASGI internally, and no longer depends on Sanic.

It now uses Uvicorn as the underlying HTTP server.

This was thirteen months in the making... for full details see the issue:

https://github.com/simonw/datasette/issues/272

And for a full sequence of commits plus commentary, see the pull request:

https://github.com/simonw/datasette/pull/518
2019-06-23 20:13:09 -07:00
Simon Willison d4df640d18 Refactored view class hierarchy, refs #272
See https://github.com/simonw/datasette/issues/272#issuecomment-502393107
2019-06-15 12:41:34 -07:00
Simon Willison 20f98c3e20 Databse.primary_keys(table) / fts_table(table) refactor, closes #488
Also cleaned up some unused imports spotted by the linter.
2019-05-27 11:27:42 -07:00
Simon Willison 026c84db30 Refactor Datasette methods to ConnectedDatabase
Refs #487
2019-05-26 21:56:43 -07:00
Simon Willison faf33515b2 Sometimes sort tables by number of relationships, closes #460 2019-05-15 20:23:33 -07:00
Simon Willison 689cf9c139 Index page only shows row counts for smaller databases
The index page now only shows row counts for immutable databases OR for
databases with less than 30 tables provided it could get a count for
each of those tables in less than 10ms.

Closes #467, Refs #460
2019-05-15 20:02:33 -07:00
Simon Willison 79303163b2 Row count fix + sort index page databases alphabetically
Sorting alphabetically should fix a test failure in Python 3.5

Refs #460
2019-05-15 17:40:10 -07:00
Simon Willison 5d6b2c30f1 Include views on homepage, fix table counts
If we have less than 5 tables we now also show one or more views in the
summary on the homepage.

Also corrected the logic for the row counts - we now count hidden and
visible tables separately.

Closes #373, Refs #460
2019-05-15 17:28:07 -07:00
Simon Willison e04511410f Don't show hidden tables on index page, closes #455
Refs #460. Also bulked out HTML index page unit tests.
2019-05-14 08:46:57 -07:00
Simon Willison de005b9b7d Fixed 500 error on homepage 2019-05-09 22:28:16 -07:00
Simon Willison 35d6ee2790
Apply black to everything, enforce via unit tests (#449)
I've run the black code formatting tool against everything:

    black tests datasette setup.py

I also added a new unit test, in tests/test_black.py, which will fail if the code does not
conform to black's exacting standards.

This unit test only runs on Python 3.6 or higher, because black itself doesn't run on 3.5.
2019-05-03 22:15:14 -04:00
Simon Willison 50d2d1aac9 Fixed bug where metadata.json hidden tables were ignored 2019-05-01 17:54:48 -07:00
Simon Willison e7151ccccf Index page no longer uses inspect data - refs #420
Also introduced a mechanism whereby table counts are calculated against a time limit
but immutable databases have their table counts calculated on server startup.
2019-05-01 17:39:39 -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 6f6d0ff2b4
URL hashing is now off by default - closes #418
Prior to this commit Datasette would calculate the content hash of every
database and redirect to a URL containing that hash, like so:

    https://v0-27.datasette.io/fixtures => https://v0-27.datasette.io/fixtures-dd88475

This assumed that all databases were opened in immutable mode and were not
expected to change.

This will be changing as a result of #419 - so this commit takes the first step
in implementing that change by changing this default behaviour. Datasette will
now only redirect hash-free URLs under two circumstances:

* The new `hash_urls` config option is set to true (it defaults to false).
* The user passes `?_hash=1` in the URL
2019-03-17 15:55:04 -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 1905c03364
New ds.metadata() method 2018-08-28 00:45:39 -07:00
Simon Willison 71b46fd9f5
Cleaned up view constructors to accept just a datasette instance 2018-07-07 19:58:11 -07:00
Simon Willison 3a79ad98ea
Basic CSV export, refs #266
Tables and custom SQL query results can now be exported as CSV.

The easiest way to do this is to use the .csv extension, e.g.

	/test_tables/facet_cities.csv

By default this is served as Content-Type: text/plain so you can see it in
your browser. If you want to download the file (using text/csv and with an
appropriate Content-Disposition: attachment header) you can do so like this:

	/test_tables/facet_cities.csv?_dl=1

We link to the CSV and downloadable CSV URLs from the table and query pages.

The links use ?_size=max and so by default will return 1,000 rows.

Also fixes #303 - table names ending in .json or .csv are now detected and
URLs are generated that look like this instead:

	/test_tables/table%2Fwith%2Fslashes.csv?_format=csv

The ?_format= option is available for everything else too, but we link to the
.csv / .json versions in most cases because they are aesthetically pleasing.
2018-06-14 23:51:23 -07:00
Simon Willison cf1fe693e5 Used isort to re-order my imports 2018-05-14 00:04:23 -03:00
Simon Willison 3686385551 Ran black source formatting tool against new views/ and app.py 2018-05-14 00:04:23 -03:00
Simon Willison 1f69269fe9 Refactored views into new views/ modules, refs #256 2018-05-14 00:04:23 -03:00