Wykres commitów

468 Commity (ed631e690b81e34fcaeaba1f16c9166f1c505990)

Autor SHA1 Wiadomość Data
Simon Willison 67ad77a307
Re-ordered docs index page 2017-12-06 10:27:50 -08:00
Simon Willison f9c32e717f
Linked to csvs-to-sqlite 2017-12-06 07:09:56 -08:00
Simon Willison f2dece01db
Documented _sql_time_limit_ms querystring argument
Closes #163
2017-12-06 07:06:56 -08:00
Simon Willison 7a4da7e5ae
Documentation for custom SQL queries
http://datasette.readthedocs.io/en/latest/sql_queries.html

Closes #20
2017-12-05 09:43:59 -08:00
Simon Willison b7b590b414
Docs for query.html CSS/template, refs #20 2017-12-05 08:35:14 -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 0cfd7ce59d
Allow WITH query (previously we required SELECT at start)
Fixes #161
2017-12-03 20:51:31 -08:00
Simon Willison e981ac7d4d
--static option for datasette serve
You can now tell Datasette to serve static files from a specific location at a
specific mountpoint.

For example:

	datasette serve mydb.db --static extra-css:/tmp/static/css

Now if you visit this URL:

	http://localhost:8001/extra-css/blah.css

The following file will be served:

	/tmp/static/css/blah.css

Refs #160
2017-12-03 08:33:36 -08:00
Simon Willison 1ecac1a438
Fix display of select boxes in Firefox 2017-12-02 12:53:08 -08:00
Simon Willison 1feb5735da
Moved getting started into separate docs page 2017-11-30 10:27:00 -08:00
Simon Willison 601934936c
Documentation for custom CSS/JavaScript/Templates
Will go live at http://datasette.readthedocs.io/en/latest/custom_templates.html

Closes #156
2017-11-30 09:09:48 -08:00
Simon Willison cf46b86cf7
Switch to sphinx_rtd_theme 2017-11-30 08:56:20 -08:00
Simon Willison 3cd06729f4
Ability to over-ride templates for individual tables/databases
It is now possible to over-ride templates on a per-database / per-row or per-
table basis.

When you access e.g. /mydatabase/mytable Datasette will look for the following:

    - table-mydatabase-mytable.html
    - table.html

If you provided a --template-dir argument to datasette serve it will look in
that directory first.

The lookup rules are as follows:

    Index page (/):
        index.html

    Database page (/mydatabase):
        database-mydatabase.html
        database.html

    Table page (/mydatabase/mytable):
        table-mydatabase-mytable.html
        table.html

    Row page (/mydatabase/mytable/id):
        row-mydatabase-mytable.html
        row.html

If a table name has spaces or other unexpected characters in it, the template
filename will follow the same rules as our custom <body> CSS classes
introduced in 8ab3a169d4 - for example, a table called "Food Trucks"
will attempt to load the following templates:

    table-mydatabase-Food-Trucks-399138.html
    table.html

It is possible to extend the default templates using Jinja template
inheritance. If you want to customize EVERY row template with some additional
content you can do so by creating a row.html template like this:

    {% extends "default:row.html" %}

    {% block content %}
    <h1>EXTRA HTML AT THE TOP OF THE CONTENT BLOCK</h1>
    <p>This line renders the original block:</p>
    {{ super() }}
    {% endblock %}

Closes #12, refs #153
2017-11-30 08:38:16 -08:00
Simon Willison 7ff51598c4
git commit -m "datasette --template-dir=mytemplates/" argument
You can now pass an additional argument specifying a directory to look for
custom templates in.

Datasette will fall back on the default templates if a template is not
found in that directory.

Refs #12, #153
2017-11-30 08:05:01 -08:00
Simon Willison ffa77f62b4
Removed dependency on sanic-jinja2
I wasn't using any of the functionality it adds on top of raw Jinja2.

Refs #12 and #153
2017-11-30 07:51:40 -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 b67890d15d
Auto-link column values that look like URLs
Refs #153
2017-11-29 09:05:24 -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 36701c8592
datasette build now takes --load-extension 2017-11-26 15:02:01 -08:00
Simon Willison de6c62ed9a
Load SQLite extensions inside .inspect() too 2017-11-26 15:02:00 -08:00
Simon Willison 23a4575818
Added News section to Readme 2017-11-25 13:40:43 -08:00
Simon Willison efb82da927
datasette => Datasette 2017-11-24 19:46:24 -08:00
Simon Willison c160f15c39
Release version 0.13 2017-11-24 19:33:39 -08:00
Simon Willison 17fee0cc14
Automatically deploy tags as PyPI releases
https://docs.travis-ci.com/user/deployment/pypi/
2017-11-24 19:32:47 -08:00
Simon Willison 0d3479ba32
Release notes for 0.13 2017-11-24 19:32:24 -08:00
Simon Willison e3dd2483bb
Fixed quoting on foreign-key links to tables with spaces in name 2017-11-24 16:05:28 -08:00
Simon Willison c5c923d93c
Don't incorrectly detect VIEWs as supporting FTS 2017-11-24 14:51:00 -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 a53d09d919
Show count of matching rows on table view
Closes #127
2017-11-24 14:01:53 -08:00
Simon Willison ab32bd6427
Fixed bug with params other than p0
p1 and upwards were not correctly extracted.
2017-11-24 13:55:00 -08:00
Simon Willison b450778391
Added column__not=blah filter
Closes #148
2017-11-23 14:09:50 -08:00
Simon Willison 4b7596ee5c
Row page now resolves foreign keys
Closes #132
2017-11-23 13:51:16 -08:00
Simon Willison a30c5b220c
Fixed bug on rows page, added unit test
Rows page for rows that linked to the same table in more
than one columns were display incorrectly. Fixed that and added a test.

Also introduced /db/table/row-pk.json?_extras=foreign_key_tables

This is used by the new unit test, but is the first example of a new
?_extras=comma-separated-list pattern I am introducing.
2017-11-23 13:09:45 -08:00
Simon Willison 7708887681
Tweaked styling of submit buttons and search box 2017-11-23 12:39:26 -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 2f97834d0e
NBSP before ID display 2017-11-22 20:45:04 -08:00
Simon Willison 38dc1ef73b
Show linked foreign key in table cells 2017-11-22 20:43:27 -08:00
Simon Willison 72e328dccf
Removed rogue print statement 2017-11-22 20:40:15 -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 53534b6e9d
Even more complicated redirect scheme
This:

    ?_filter_column_1=name&_filter_op_1=contains&_filter_value_1=hello
    &_filter_column_2=age&_filter_op_2=gte&_filter_value_2=12

Now redirects to this:

    ?name__contains=hello&age__gte=12

This is needed for the filter editing interface, refs #86
2017-11-22 20:03:46 -08:00
Simon Willison c8e7c85fd3
Updated test_database_page test 2017-11-22 12:25:51 -08:00
Simon Willison 1c8638c30a
Hide FTS-created tables on index pages
Closes #129
2017-11-22 12:18:57 -08:00
Simon Willison f96e55bce5 Fix pytest version conflict
https://travis-ci.org/simonw/datasette/jobs/305929426

    pkg_resources.VersionConflict: (pytest 3.2.1 (/home/travis/virtualenv/python3.5.3/lib/python3.5/site-packages), 
    Requirement.parse('pytest==3.2.3'))
2017-11-22 12:17:51 -08:00
Simon Willison fa8eb0bf1b
Run unit tests against both Python 3.5 and 3.6 2017-11-22 09:43:52 -08:00
Simon Willison fb505de11c
Back-ported format strings for compatibility with Py 3.5
Also fixed a encoding error where Heroku --json return needs to be treated as UTF8
2017-11-22 09:42:29 -08:00