Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Upgrade Datasette #6

Merged
merged 6 commits into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-e git+https://github.com/simonw/csvs-to-sqlite.git@2830a5850cdd018c11247cde08a199aff1255205#egg=csvs_to_sqlite
-e git+https://github.com/simonw/datasette.git@0.14#egg=datasette
-e git+https://github.com/simonw/datasette.git@0.18#egg=datasette
aiofiles==0.3.2
click-default-group==1.2
click==6.7
Expand All @@ -9,6 +9,7 @@ Jinja2==2.10
MarkupSafe==1.0
numpy==1.14.0
pandas==0.20.3
pint==0.8.1
py-lru-cache==0.1.4
python-dateutil==2.6.1
pytz==2017.3
Expand Down
14 changes: 8 additions & 6 deletions templates/error.html → templates/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@
<div style="padding: 1em; margin: 1em 0; border: 3px solid red;">{{ error }}</div>
{% endif %}

<form class="sql" action="/{{ database }}-{{ database_hash }}" method="get">
<h3>Custom SQL query</h3>
{% if database %}
<form class="sql" action="/{{ database }}-{{ database_hash }}" method="get">
<h3>Custom SQL query</h3>

<p><textarea name="sql"></textarea></p>
<p><textarea name="sql"></textarea></p>

<p><input type="submit" value="Run SQL"></p>
</form>
<p><input type="submit" value="Run SQL"></p>
</form>

{% include "_codemirror_foot.html" %}
{% include "_codemirror_foot.html" %}
{% endif %}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error handling was changed in the new Datasette.


{% endblock %}
13 changes: 11 additions & 2 deletions templates/_rows_and_columns.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
<thead title="Click to toggle extra columns">
<tr>
{% for column in display_columns %}
<th scope="col" class="{{ column }}">
{{ col_name[column] | default(column) }}
{% set name = col_name[column.name] | default(column.name) %}
<th scope="col" class="{{ column.name }}">
{% if not column.sortable %}
{{ name }}
{% else %}
{% if column.name == sort %}
<a href="{{ path_with_added_args(request, {'_sort_desc': column.name, '_sort': None, '_next': None}) }}" rel="nofollow">{{ name }}&nbsp;▼</a>
{% else %}
<a href="{{ path_with_added_args(request, {'_sort': column.name, '_sort_desc': None, '_next': None}) }}" rel="nofollow">{{ name }}{% if column.name == sort_desc %}&nbsp;▲{% endif %}</a>
{% endif %}
{% endif %}
Copy link
Contributor Author

@earthboundkid earthboundkid Apr 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this is copy-pasta from Datasette's new default template.

</th>
{% endfor %}
</tr>
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<a href="/salaries/2017+Maryland+state+salaries?organization__like=GENERAL+ASSEMBLY+OF+MARYLAND">General Assembly</a>
<a href="/salaries/2017+Maryland+state+salaries?organization__contains=UNIVERSITY">Public universities</a>
<a href="/salaries/2017+Maryland+state+salaries?organization__like=DEPARTMENT+OF+STATE+POLICE">State police</a>
<a href="/salaries/Top-Earners">Top Earners</a>
<a href="/salaries/2017+Maryland+state+salaries?_sort_desc=ytd_gross_earnings">Top Earners</a>
</span>
<div id="share-tools">
<span class="icon-facebook js-click"></span>
Expand Down
2 changes: 1 addition & 1 deletion templates/database.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<form class="sql" action="/{{ database }}-{{ database_hash }}" method="get">
<h3>Custom SQL query</h3>
<p>Note: Database uses <a href="https://www.sqlite.org/lang.html">SQLite</a> syntax.</p>
<p><textarea name="sql">select * from {{ tables[0].name|escape_table_name }}</textarea></p>
<p><textarea name="sql">select * from {{ tables[0].name|escape_sqlite }}</textarea></p>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

escape_table_name was removed and replaced in the new Datasette.

<p><input type="submit" value="Custom SQL Query"></p>
</form>

Expand Down
2 changes: 1 addition & 1 deletion templates/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ <h2 class="title">{{ canned_query.replace("-", " ") }}</h2>
<form class="sql" action="/{{ database }}-{{ database_hash }}" method="get">
<h3>Custom SQL query{% if rows %} returning {% if truncated %}more than {% endif %}{{ "{:,}".format(rows|length) }} row{% if rows|length == 1 %}{% else %}s{% endif %}{% endif %}</h3>
{% if editable %}
<p><textarea name="sql">{% if query and query.sql %}{{ query.sql }}{% else %}select * from {{ tables[0].name|escape_table_name }}{% endif %}</textarea></p>
<p><textarea name="sql">{% if query and query.sql %}{{ query.sql }}{% else %}select * from {{ tables[0].name|escape_sqlite }}{% endif %}</textarea></p>
{% else %}
<pre>{% if query %}{{ query.sql }}{% endif %}</pre>
{% endif %}
Expand Down