Commit graph

325 commits

Author SHA1 Message Date
Simon Willison
dfb87d012c
Use to_css_class for table cell column classes
This ensures that columns with spaces in the name will still
generate usable CSS class names. Refs #209
2018-04-17 18:19:21 -07:00
Russ Garrett
136a70d887 Add column name classes to <td>s, make PK bold 2018-04-17 18:13:02 -07:00
Russ Garrett
0f782dd8df Additional test asserts 2018-04-17 18:13:02 -07:00
Russ Garrett
4586aa506a Don't duplicate simple primary keys in the link column
When there's a simple (single-column) primary key, it looks weird to
duplicate it in the link column.

This change removes the second PK column and treats the link column as
if it were the PK column from a header/sorting perspective.
2018-04-17 18:13:02 -07:00
Russ Garrett
b231d4243d Correct escaping for HTML display of row links 2018-04-17 18:13:02 -07:00
Simon Willison
aaf59db570
Longer time limit for test_paginate_compound_keys
It was failing intermittently in Travis - see #209
2018-04-17 18:09:48 -07:00
Simon Willison
5ebc7137d7
Use application/octet-stream for downloadable databses
I'd also like to send the Content-Length here but that's not currently
possible in Sanic - see bug report here:

https://github.com/channelcat/sanic/issues/1194
2018-04-17 17:31:54 -07:00
Simon Willison
1f384e662b
Updated PyPI classifiers 2018-04-17 17:30:46 -07:00
Simon Willison
bf5ec2d611
Updated PyPI link to pypi.org 2018-04-16 19:24:36 -07:00
Simon Willison
ba9bfa5831
Datasette 0.19: plugin preview (with release notes) 0.19 2018-04-16 19:12:21 -07:00
Simon Willison
e7c769ef30
Working implementation of #216 which passes the tests
Reverted commit 5364fa7f33 (where I removed the
code that didn't work).

Added primary keys to order-by clause for sorting to get tests to pass
2018-04-16 18:41:55 -07:00
Simon Willison
5364fa7f33
Revert #216 until I can get tests to pass in Travis
Revert "Fix for _sort_desc=sortable_with_nulls test, refs #216"

This reverts commit 07fc2d113e.

Revert "Fixed #216 - paginate correctly when sorting by nullable column"

This reverts commit 2abe539a0f.
2018-04-16 17:53:37 -07:00
Simon Willison
07fc2d113e
Fix for _sort_desc=sortable_with_nulls test, refs #216 2018-04-16 17:05:03 -07:00
Simon Willison
2abe539a0f
Fixed #216 - paginate correctly when sorting by nullable column 2018-04-16 16:52:50 -07:00
Simon Willison
1652a9707e
Apache 2.0 license badge 2018-04-16 16:10:12 -07:00
Simon Willison
10a34f995c
Removed rogue print() call 2018-04-16 08:38:09 -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
Simon Willison
b2955d9065
New --plugins-dir=plugins/ option (#212)
* New --plugins-dir=plugins/ option

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/

* Unit tests for --plugins-dir=plugins/

Closes #211
2018-04-15 22:22:01 -07:00
Simon Willison
92396ae5ba
Better fix for setup.py version 2018-04-15 21:38:04 -07:00
Simon Willison
33c7c53ff8
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
2018-04-15 17:56:15 -07:00
Russ Garrett
efbb4e8337 Return HTTP 405 on InvalidUsage rather than 500
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.
2018-04-14 11:00:38 -07:00
Simon Willison
8d394586f5
Added 0.18 to news 2018-04-14 09:04:38 -07:00
Simon Willison
43ae15c0d1
Releasing v0.18 - support for units! 0.18
Refs #203
2018-04-14 08:36:10 -07:00
Simon Willison
932e0a3f91
Don't attempt to deploy new tags to PyPI
This isn't working through Travis at the moment, so I'm disabling it and switching back to manual deploys.
2018-04-14 08:21:37 -07:00
Simon Willison
c857608738
Merge "Support filtering with units" from #205 2018-04-14 08:17:09 -07:00
Simon Willison
dd4491dd81
Update number of expected tables 2018-04-14 08:16:54 -07:00
Simon Willison
6b15a53cd3
Unit test for unlabelled foreign keys from #207 2018-04-14 08:00:54 -07:00
Russ Garrett
f2b940d602 Link foreign keys which don't have labels
This renders unlabeled FKs as simple links. I can't see why this would
cause any major problems.

Also includes bonus fixes for two minor issues:

* In foreign key link hrefs the primary key was escaped using HTML
  escaping rather than URL escaping. This broke some non-integer PKs.
* Print tracebacks to console when handling 500 errors.
2018-04-14 07:59:59 -07:00
Simon Willison
d72201e883
Added unit test for foreign key links in HTML
Needed to add a further unit test for #207
2018-04-14 07:55:27 -07:00
Russ Garrett
1cc5161089 Fix sqlite error when loading rows with no incoming FKs
This fixes `ERROR: conn=<sqlite3.Connection object at 0x10bbb9f10>, sql
= 'select ', params = {'id': '1'}` caused by an invalid query when
loading incoming FKs.

The error was ignored due to async but it still got printed to the
console.
2018-04-14 07:24:24 -07:00
Russ Garrett
7d5f25dfb3
Add link to pint custom units page to docs 2018-04-14 15:08:20 +01:00
Russ Garrett
ed974417ad
Tests for unit filtering 2018-04-14 15:06:52 +01:00
Russ Garrett
3c985ec271
Allow custom units to be registered with Pint 2018-04-14 12:27:06 +01:00
Russ Garrett
ab85605c61
Support units in filters 2018-04-14 11:43:35 +01:00
Russ Garrett
8bfeb98478
Tidy up units support
* Add units to exported JSON
* Units key in metadata skeleton
* Docs
2018-04-14 11:43:34 +01:00
Russ Garrett
ec6abc81e4 Initial units support
Add support for specifying units for a column in metadata.json and
rendering them on display using
[pint](https://pint.readthedocs.io/en/latest/).

ref #203
2018-04-13 20:32:53 -07:00
Simon Willison
fb988ace7c
Release 0.17 to fix issues with PyPI 0.17
See https://twitter.com/simonw/status/984862976447414272
2018-04-13 12:04:40 -07:00
Simon Willison
b6539ff045
Releasing v0.16 0.16 2018-04-13 11:28:55 -07:00
Simon Willison
6e16ed2a63
Removed pathlib dependency (incompatible with Python 3.5) 2018-04-13 11:22:15 -07:00
Simon Willison
9f28bbe43d
Better mechanism for handling errors; 404s for missing table/database
New error mechanism closes #193

404s for missing tables/databesse closes #184

Makes pull request #202 unnecessary.
2018-04-13 11:17:22 -07:00
Simon Willison
ad6142b67c
long_description in markdown for the new PyPI 2018-04-13 09:04:18 -07:00
Russ Garrett
d08a133140 Hide Spatialite system tables
They were getting on my nerves.
2018-04-12 14:34:47 -07:00
Simon Willison
cca8bf36fe
Allow explain select / explain query plan select
Closes #201
2018-04-12 14:32:47 -07:00
Simon Willison
bfb4e45a7b
Datasette Publish in readme 2018-04-11 07:43:28 -07:00
Simon Willison
46b237c29a
datasette inspect now finds primary_keys
Closes #195
2018-04-09 17:54:12 -07:00
Simon Willison
57b19f09d1
Ability to sort using form fields (for mobile portrait mode)
We now display sort options as a select box plus a descending checkbox, which
means you can apply sort orders even in portrait mode on a mobile phone where
the column headers are hidden.

Closes #199
2018-04-09 17:34:32 -07:00
Simon Willison
67982b6ecb
Added Datasette 0.15 to news 2018-04-09 09:01:03 -07:00
Simon Willison
7706fe0c67
Releasing v0.15 0.15 2018-04-09 08:48:24 -07:00
Simon Willison
a290f28caa
table_rows => table_rows_count, filtered_table_rows => filtered_table_rows_count
Renamed properties. Closes #194
2018-04-08 22:24:24 -07:00
Simon Willison
c1d37fdf2b Fixed bug with human filter description, refs #189
We were showing this:

    201 rows where sorted by sortable_with_nulls

We now show this:

    201 rows sorted by sortable_with_nulls
2018-04-08 22:10:22 -07:00