From 8da2db4b71096b19e7a9ef1929369b8483d448bf Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 4 Jan 2019 17:34:22 -0800 Subject: [PATCH] WIP --- datasette/app.py | 3 +++ datasette/cli.py | 2 ++ datasette/templates/database.html | 12 ++++++------ datasette/templates/index.html | 4 ++-- datasette/templates/query.html | 4 ++-- datasette/templates/row.html | 4 ++-- datasette/templates/table.html | 4 ++-- datasette/views/base.py | 3 ++- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/datasette/app.py b/datasette/app.py index cdfcb11d..d9b8ac72 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -99,6 +99,9 @@ CONFIG_OPTIONS = ( ConfigOption("force_https_urls", False, """ Force URLs in API output to always use https:// protocol """.strip()), + ConfigOption("url_prefix", "", """ + URLs within Datasette itself should start with this (defaults to auto) + """.strip()), ) DEFAULT_CONFIG = { option.name: option.default diff --git a/datasette/cli.py b/datasette/cli.py index 2cadabbf..90ae137e 100644 --- a/datasette/cli.py +++ b/datasette/cli.py @@ -49,6 +49,8 @@ class Config(click.ParamType): ) return return name, int(value) + elif isinstance(default, str): + return name, value else: # Should never happen: self.fail('Invalid option') diff --git a/datasette/templates/database.html b/datasette/templates/database.html index 05acff84..db6eb0dc 100644 --- a/datasette/templates/database.html +++ b/datasette/templates/database.html @@ -10,7 +10,7 @@ {% block body_class %}db db-{{ database|to_css_class }}{% endblock %} {% block content %} -
home
+
home

{{ metadata.title or database }}

@@ -27,7 +27,7 @@ {% for table in tables %} {% if show_hidden or not table.hidden %}
-

{{ table.name }}{% if table.hidden %} (hidden){% endif %}

+

{{ table.name }}{% if table.hidden %} (hidden){% endif %}

{% for column in table.columns[:9] %}{{ column }}{% if not loop.last %}, {% endif %}{% endfor %}{% if table.columns|length > 9 %}...{% endif %}

{{ "{:,}".format(table.count) }} row{% if table.count == 1 %}{% else %}s{% endif %}

@@ -35,14 +35,14 @@ {% endfor %} {% if hidden_count and not show_hidden %} -

... and {{ "{:,}".format(hidden_count) }} hidden table{% if hidden_count == 1 %}{% else %}s{% endif %}

+

... and {{ "{:,}".format(hidden_count) }} hidden table{% if hidden_count == 1 %}{% else %}s{% endif %}

{% endif %} {% if views %}

Views

{% endif %} @@ -51,13 +51,13 @@

Queries

{% endif %} {% if config.allow_download %} -

Download SQLite DB: {{ database }}.db

+

Download SQLite DB: {{ database }}.db

{% endif %} {% include "_codemirror_foot.html" %} diff --git a/datasette/templates/index.html b/datasette/templates/index.html index cb52740a..bea9c893 100644 --- a/datasette/templates/index.html +++ b/datasette/templates/index.html @@ -10,7 +10,7 @@ {% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %} {% for database in databases %} -

{{ database.name }}

+

{{ database.name }}

{{ "{:,}".format(database.table_rows_sum) }} rows in {{ database.tables_count }} table{% if database.tables_count != 1 %}s{% endif %}{% if database.tables_count and database.hidden_tables_count %}, {% endif %} {% if database.hidden_tables_count %} @@ -21,7 +21,7 @@ {{ "{:,}".format(database.views_count) }} view{% if database.views_count != 1 %}s{% endif %} {% endif %}

-

{% for table in database.tables_truncated %}{{ table.name }}{% if not loop.last %}, {% endif %}{% endfor %}{% if database.tables_more %}, ...{% endif %}

+

{% for table in database.tables_truncated %}{{ table.name }}{% if not loop.last %}, {% endif %}{% endfor %}{% if database.tables_more %}, ...{% endif %}

{% endfor %} {% endblock %} diff --git a/datasette/templates/query.html b/datasette/templates/query.html index b23c67d8..97d3dd58 100644 --- a/datasette/templates/query.html +++ b/datasette/templates/query.html @@ -19,13 +19,13 @@ {% block body_class %}query db-{{ database|to_css_class }}{% endblock %} {% block content %} -
home / {{ database }}
+
home / {{ database }}

{{ metadata.title or database }}

{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %} -
+

Custom SQL query{% if display_rows %} returning {% if truncated %}more than {% endif %}{{ "{:,}".format(display_rows|length) }} row{% if display_rows|length == 1 %}{% else %}s{% endif %}{% endif %}

{% if editable and config.allow_sql %}

diff --git a/datasette/templates/row.html b/datasette/templates/row.html index 4ef0b758..1aa6f80a 100644 --- a/datasette/templates/row.html +++ b/datasette/templates/row.html @@ -16,7 +16,7 @@ {% block body_class %}row db-{{ database|to_css_class }} table-{{ table|to_css_class }}{% endblock %} {% block content %} - +

{{ table }}: {{ ', '.join(primary_key_values) }}

@@ -31,7 +31,7 @@