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
This commit is contained in:
Simon Willison 2017-12-07 08:42:54 -08:00
commit 80bf3afa43
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
7 changed files with 54 additions and 31 deletions

View file

@ -6,24 +6,8 @@
{% block content %}
<h1>{{ metadata.title or "Datasette" }}</h1>
{% if metadata.license or metadata.source_url %}
<p>
{% if metadata.license %}Data license:
{% if metadata.license_url %}
<a href="{{ metadata.license_url }}">{{ metadata.license }}</a>
{% else %}
{{ metadata.license }}
{% endif %}
{% endif %}
{% if metadata.source_url %}{% if metadata.license %}&middot;{% endif %}
{% if metadata.source %}
Data source: <a href="{{ metadata.source_url }}">{{ metadata.source }}</a>
{% else %}
<a href="{{ metadata.source_url }}">Data source</a>
{% endif %}
{% endif %}
</p>
{% endif %}
{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}
{% for database in databases %}
<h2 style="padding-left: 10px; border-left: 10px solid #{{ database.hash[:6] }}"><a href="{{ database.path }}">{{ database.name }}</a></h2>