Database/Table views inherit source/license/source_url/license_url metadata

If you set the source_url/license_url/source/license fields in your root
metadata those values will now be inherited all the way down to the database
and table templates.

The title/description are NOT inherited.

Also added unit tests for the HTML generated by the metadata.

Refs #185
This commit is contained in:
Simon Willison 2018-03-27 09:18:32 -07:00
commit 89d9fbb91b
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
4 changed files with 94 additions and 6 deletions

View file

@ -16,6 +16,7 @@ def app_client():
page_size=50,
max_returned_rows=100,
sql_time_limit_ms=20,
metadata=METADATA,
)
ds.sqlite_functions.append(
('sleep', 1, lambda n: time.sleep(float(n))),
@ -23,6 +24,27 @@ def app_client():
yield ds.app().test_client
METADATA = {
'title': 'Datasette Title',
'description': 'Datasette Description',
'license': 'License',
'license_url': 'http://www.example.com/license',
'source': 'Source',
'source_url': 'http://www.example.com/source',
'databases': {
'test_tables': {
'description': 'Test tables description',
'tables': {
'simple_primary_key': {
'description_html': 'Simple <em>primary</em> key',
'title': 'This <em>HTML</em> is escaped',
}
}
}
}
}
TABLES = '''
CREATE TABLE simple_primary_key (
pk varchar(30) primary key,