Commit graph

82 commits

Author SHA1 Message Date
Simon Willison
fe15032462
Clarified relationship between metadata and _facet= facets, updated docs - refs @255 2018-05-16 08:15:23 -07:00
Simon Willison
3ba8a10ed1
Reliable sort order for facets in Python 3.5, fixing test - refs #255 2018-05-16 07:43:13 -07:00
Simon Willison
436dd11949
Hide facet button is now a ✖ - refs #255 2018-05-16 07:37:15 -07:00
Simon Willison
b5bf3dadb8
class="suggested-facets" 2018-05-15 22:08:58 -07:00
Simon Willison
3b885d3124
Show enabled facets in flexbox columns, refs #255 2018-05-15 22:06:05 -07:00
Simon Willison
6293c34209
Foreign key facets are now expanded to labels, refs #255 2018-05-15 10:52:02 -05:00
Simon Willison
0a02517eac
1,442 format for facet counts, refs #255 2018-05-15 09:14:19 -03:00
Simon Willison
9b376551ed
_facet selections persist through table form, refs #255 2018-05-15 07:28:48 -03:00
Simon Willison
5b2afb7310
Facets can now be toggled off again, refs #255 2018-05-15 07:11:52 -03:00
Simon Willison
158e7950ec
Facet results now have "truncated" field
To indicate if there was more than 20 distinct values. Refs #255
2018-05-15 06:50:27 -03:00
Simon Willison
590890fc46
_sort/_next links now use new path_with_replaced_args method 2018-05-15 06:39:06 -03:00
Simon Willison
ce84d76fff
Initial implementation of suggested facets
Causes tests to break at the moment
2018-05-14 19:09:42 -03:00
Simon Willison
eaaa3ea149
Initial implementation of facets, plus tests and docs
Refs #255
2018-05-12 19:29:41 -03:00
Simon Willison
db7a57a9a6
Added class=rows-and-columns to custom query results table 2018-04-25 20:24:22 -07:00
Simon Willison
00ab954300
Added CSS class rows-and-columns to main table 2018-04-23 18:31:32 -07:00
Simon Willison
e2750c7cc0
Add col-X classes to HTML table on custom query page 2018-04-19 08:36:14 -07:00
Simon Willison
b55809a1e2
Added /-/metadata /-/plugins /-/inspect, closes #225 2018-04-18 22:25:22 -07:00
Simon Willison
a5792a8c61
<th> now gets class="col-X" - plus added col-X documentation
Refs #209
2018-04-17 19:11:54 -07:00
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
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
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
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
Simon Willison
b13f0986f2 New sortable_columns option in metadata.json to control sort options
You can now explicitly set which columns in a table can be used for sorting
using the _sort and _sort_desc arguments using metadata.json:

    {
        "databases": {
            "database1": {
                "tables": {
                    "example_table": {
                        "sortable_columns": [
                            "height",
                            "weight"
                        ]
                    }
                }
            }
        }
    }

Refs #189
2018-04-08 22:10:22 -07:00
Simon Willison
747a801b50 Column headers now link to sort/desc sort - refs #189 2018-04-08 22:10:22 -07:00
Simon Willison
9f2ec39fbc Current sort order now reflected in human filter description
Plus renamed human_description to human_description_en

Refs #189
2018-04-08 22:10:22 -07:00
Ryan Pitts
446d47fdb0 make html title more readable in query template (#180)
tiny tweak to make this easier to visually parse—I think it matches your style in other templates
2018-04-03 08:24:04 -07:00
Simon Willison
0abd3abacb
New ?_shape=objects/object/lists param for JSON API (#192)
New _shape= parameter replacing old .jsono extension

Now instead of this:

	/database/table.jsono

We use the _shape parameter like this:

	/database/table.json?_shape=objects

Also introduced a new _shape called 'object' which looks like this:

	/database/table.json?_shape=object

Returning an object for the rows key:

	...
	"rows": {
		"pk1": {
			...
		},
		"pk2": {
			...
		}
	}

Refs #122
2018-04-03 07:52:54 -07:00
Simon Willison
8f0d44d646
escape_sqlite_table_name => escape_sqlite, handles reserved words
It can be used for column names as well as table names.

Reserved word list from https://www.sqlite.org/lang_keywords.html
2018-04-03 06:40:49 -07:00
Simon Willison
3f2fed1093
Fixed bug with HTML labels
loop.counter is incorrect - loop.index outputs the correct loop value.
2017-12-09 13:57:36 -08:00
Simon Willison
7126d08f10
HTML comment showing which templates were considered for a page
Closes #171
2017-12-09 13:47:32 -08:00
Simon Willison
16dfccb1c5
Include sha1 hash in /static/app.css URL
This means that when Datasette's CSS changes the new CSS will be loaded
even though browsers may have cached the previous version.

Closes #154
2017-12-08 19:10:09 -08:00
Simon Willison
80bf3afa43
metadata.json support for per-table/per-database metadata
Also added support for descriptions and HTML descriptions.

Here's an example metadata.json file illustrating custom per-database and per-
table metadata:

    {
        "title": "Overall datasette title",
        "description_html": "This is a <em>description with HTML</em>.",
        "databases": {
            "db1": {
                "title": "First database",
                "description": "This is a string description & has no HTML",
                "license_url": "http://example.com/",
        		"license": "The example license",
                "queries": {
                	"canned_query": "select * from table1 limit 3;"
                },
                "tables": {
                    "table1": {
                        "title": "Custom title for table1",
                        "description": "Tables can have descriptions too",
                        "source": "This has a custom source",
                        "source_url": "http://example.com/"
                    }
                }
            }
        }
    }

Closes #165, Refs #164
2017-12-07 08:47:07 -08:00
Simon Willison
7e1ba161ec
Ability to easily customize _rows_and_columns.html per database table
Also added documentation for this.

Refs #158, Closes #159.
2017-12-06 22:11:22 -08:00
Simon Willison
afbda9e210
All extra_head blocks now call super
This means you can provide a custom base.html template that populates
extra_head and any of the default child templates will still render content
you included in that block.

Refs #158
2017-12-06 21:58:42 -08:00
Simon Willison
52a5e95d21
Fixed bug with filter columns
Closes #162
2017-12-06 21:05:53 -08:00
Simon Willison
a743cdeafc
Canned query support + database/query template refactor
Named canned queries can now be defined in metadata.json like this:

    {
        "databases": {
            "timezones": {
                "queries": {
                    "timezone_for_point": "select tzid from timezones ..."
                }
            }
        }
    }

These will be shown in a new "Queries" section beneath "Views" on the database page.

As part of this, I refactored the logic for the database index page. It used
to combine the functionality for listing available tables and the
functionality for executing custom SQL queries in a single template and view.
I have split that template out into database.html and query.html and reworked
the view to more clearly separate the custom SQL executing code.

Refs #20
2017-12-05 08:17:02 -08:00
Simon Willison
8ab3a169d4
CSS styling hooks as classes on the body
Refs #153

Every template now gets CSS classes in the body designed to support custom
styling.

The index template (the top level page at /) gets this:

    <body class="index">

The database template (/dbname/) gets this:

    <body class="db db-dbname">

The table template (/dbname/tablename) gets:

    <body class="table db-dbname table-tablename">

The row template (/dbname/tablename/rowid) gets:

    <body class="row db-dbname table-tablename">

The db-x and table-x classes use the database or table names themselves IF
they are valid CSS identifiers. If they aren't, we strip any invalid
characters out and append a 6 character md5 digest of the original name, in
order to ensure that multiple tables which resolve to the same stripped
character version still have different CSS classes.

Some examples (extracted from the unit tests):

    "simple" => "simple"
    "MixedCase" => "MixedCase"
    "-no-leading-hyphens" => "no-leading-hyphens-65bea6"
    "_no-leading-underscores" => "no-leading-underscores-b921bc"
    "no spaces" => "no-spaces-7088d7"
    "-" => "336d5e"
    "no $ characters" => "no--characters-59e024"
2017-11-29 23:09:54 -08:00
Simon Willison
0120c24927
extra_css_urls/extra_js_urls in metadata, refs #153
A mechanism in the metadata.json format for adding custom CSS and JS urls.

Create a metadata.json file that looks like this:

    {
        "extra_css_urls": [
            "https://simonwillison.net/static/css/all.bf8cd891642c.css"
        ],
        "extra_js_urls": [
            "https://code.jquery.com/jquery-3.2.1.slim.min.js"
        ]
    }

Then start datasette like this:

    datasette mydb.db --metadata=metadata.json

The CSS and JavaScript files will be linked in the <head> of every page.

You can also specify a SRI (subresource integrity hash) for these assets:

    {
        "extra_css_urls": [
            {
                "url": "https://simonwillison.net/static/css/all.bf8cd891642c.css",
                "sri": "sha384-9qIZekWUyjCyDIf2YK1FRoKiPJq4PHt6tp/ulnuuyRBvazd0hG7pWbE99zvwSznI"
            }
        ],
        "extra_js_urls": [
            {
                "url": "https://code.jquery.com/jquery-3.2.1.slim.min.js",
                "sri": "sha256-k2WSCIexGzOj3Euiig+TlR8gA0EmPjuc79OEeY5L45g="
            }
        ]
    }

Modern browsers will only execute the stylsheet or JavaScript if the SRI hash
matches the content served. You can generate hashes using www.srihash.org
2017-11-28 18:38:15 -08:00
Simon Willison
a81c62d848
Tweaked custom SQL results display
Closes #149
2017-11-24 14:41:31 -08:00
Simon Willison
a802cbee74
Search now applies to current filters
Combined search into the same form as filters.

Closes #133
2017-11-24 14:29:54 -08:00
Simon Willison
8a37baba14
Much tidier design for table view header
Closes #147
2017-11-24 14:02:39 -08:00
Simon Willison
4b7596ee5c
Row page now resolves foreign keys
Closes #132
2017-11-23 13:51:16 -08:00
Simon Willison
ef3eacf622
Select option for removing filters 2017-11-23 12:32:54 -08:00
Simon Willison
22b91dd95b
Further tweaks to select/input filter styling
Refs #86 - thanks for the help, @natbat!
2017-11-23 12:05:51 -08:00
Simon Willison
a74e455ced
Custom styled select boxes for filters
Refs #86
2017-11-23 07:58:55 -08:00
Simon Willison
82c20ea36e
Added '- pick a column -' as first option 2017-11-22 20:39:53 -08:00
Simon Willison
0071b5d6f5
Added UI for editing table filters
Refs #86
2017-11-22 20:33:55 -08:00
Simon Willison
1c8638c30a
Hide FTS-created tables on index pages
Closes #129
2017-11-22 12:18:57 -08:00