datasette/datasette/templates/_codemirror_foot.html
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

13 lines
349 B
HTML

<script>
var editor = CodeMirror.fromTextArea(document.getElementsByName("sql")[0], {
lineNumbers: true,
mode: "text/x-sql",
lineWrapping: true,
});
editor.setOption("extraKeys", {
"Shift-Enter": function() {
document.getElementsByClassName("sql")[0].submit();
},
Tab: false
});
</script>