datasette-edit-templates


Namedatasette-edit-templates JSON
Version 0.4.3 PyPI version JSON
download
home_pagehttps://github.com/simonw/datasette-edit-templates
SummaryPlugin allowing Datasette templates to be edited within Datasette
upload_time2024-01-17 00:40:26
maintainer
docs_urlNone
authorSimon Willison
requires_python>=3.8
licenseApache License, Version 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # datasette-edit-templates

[![PyPI](https://img.shields.io/pypi/v/datasette-edit-templates.svg)](https://pypi.org/project/datasette-edit-templates/)
[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-edit-templates?include_prereleases&label=changelog)](https://github.com/simonw/datasette-edit-templates/releases)
[![Tests](https://github.com/simonw/datasette-edit-templates/workflows/Test/badge.svg)](https://github.com/simonw/datasette-edit-templates/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-edit-templates/blob/main/LICENSE)

Plugin allowing Datasette templates to be edited within Datasette.

## Installation

Install this plugin in the same environment as Datasette.
```bash
datasette install datasette-edit-templates
```
## Usage

On startup. a `_templates_` table will be created in the database you are running Datasette against.

Use the app menu to navigate to the `/-/edit-templates` page, and edit templates there.

Changes should become visible instantly, and will be persisted to your database.

The interface is only available to users with the `edit-templates` permission.

The `root` user is granted this permission by default. You can sign in as the root user using `datasette mydb.db --root`.

## Configuration

To put the `_templates_` table in a specific database, set the `datasette-edit-templates: database` plugin configuration option:

```json
{
    "plugins": {
        "datasette-edit-templates": {
            "database": "some_database"
        }
    }
}
```
On Datasette [1.0a5](https://docs.datasette.io/en/latest/changelog.html#a5-2023-08-29) or higher you can use the [internal database](https://docs.datasette.io/en/latest/internals.html#internals-internal) with `"internal_db: true":`

```json
{
    "plugins": {
        "datasette-edit-templates": {
            "internal_db": true
        }
    }
}
```

By default the [prepare_jinja2_environment()](https://docs.datasette.io/en/stable/plugin_hooks.html#prepare-jinja2-environment-env-datasette) hook will be used to load the custom templates.

You can disable this behavior using the `skip_prepare_jinja2_environment` plugin configuration option:

```json
{
    "plugins": {
        "datasette-edit-templates": {
            "skip_prepare_jinja2_environment": true
        }
    }
}
```
Set this option if you want to further customize how the templates are loaded using another plugin.

The menu item used to access this plugin is labeled "Edit templates" by default. You can customize this using the `menu_label` plugin configuration option:

```json
{
    "plugins": {
        "datasette-edit-templates": {
            "menu_label": "Custom templates"
        }
    }
}
```
Set that to `null` to hide the menu option entirely.

## Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:
```bash
cd datasette-edit-templates
python3 -mvenv venv
source venv/bin/activate
```
Or if you are using `pipenv`:
```bash
pipenv shell
```
Now install the dependencies and tests:
```bash
pip install -e '.[test]'
```
To run the tests:
```bash
pytest
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/simonw/datasette-edit-templates",
    "name": "datasette-edit-templates",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "Simon Willison",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/9e/8b/eb6de2d0dfb711e4374b6af88e2e371714c02ebc6b147a2f939a2f5447dc/datasette-edit-templates-0.4.3.tar.gz",
    "platform": null,
    "description": "# datasette-edit-templates\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-edit-templates.svg)](https://pypi.org/project/datasette-edit-templates/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/datasette-edit-templates?include_prereleases&label=changelog)](https://github.com/simonw/datasette-edit-templates/releases)\n[![Tests](https://github.com/simonw/datasette-edit-templates/workflows/Test/badge.svg)](https://github.com/simonw/datasette-edit-templates/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-edit-templates/blob/main/LICENSE)\n\nPlugin allowing Datasette templates to be edited within Datasette.\n\n## Installation\n\nInstall this plugin in the same environment as Datasette.\n```bash\ndatasette install datasette-edit-templates\n```\n## Usage\n\nOn startup. a `_templates_` table will be created in the database you are running Datasette against.\n\nUse the app menu to navigate to the `/-/edit-templates` page, and edit templates there.\n\nChanges should become visible instantly, and will be persisted to your database.\n\nThe interface is only available to users with the `edit-templates` permission.\n\nThe `root` user is granted this permission by default. You can sign in as the root user using `datasette mydb.db --root`.\n\n## Configuration\n\nTo put the `_templates_` table in a specific database, set the `datasette-edit-templates: database` plugin configuration option:\n\n```json\n{\n    \"plugins\": {\n        \"datasette-edit-templates\": {\n            \"database\": \"some_database\"\n        }\n    }\n}\n```\nOn Datasette [1.0a5](https://docs.datasette.io/en/latest/changelog.html#a5-2023-08-29) or higher you can use the [internal database](https://docs.datasette.io/en/latest/internals.html#internals-internal) with `\"internal_db: true\":`\n\n```json\n{\n    \"plugins\": {\n        \"datasette-edit-templates\": {\n            \"internal_db\": true\n        }\n    }\n}\n```\n\nBy default the [prepare_jinja2_environment()](https://docs.datasette.io/en/stable/plugin_hooks.html#prepare-jinja2-environment-env-datasette) hook will be used to load the custom templates.\n\nYou can disable this behavior using the `skip_prepare_jinja2_environment` plugin configuration option:\n\n```json\n{\n    \"plugins\": {\n        \"datasette-edit-templates\": {\n            \"skip_prepare_jinja2_environment\": true\n        }\n    }\n}\n```\nSet this option if you want to further customize how the templates are loaded using another plugin.\n\nThe menu item used to access this plugin is labeled \"Edit templates\" by default. You can customize this using the `menu_label` plugin configuration option:\n\n```json\n{\n    \"plugins\": {\n        \"datasette-edit-templates\": {\n            \"menu_label\": \"Custom templates\"\n        }\n    }\n}\n```\nSet that to `null` to hide the menu option entirely.\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n```bash\ncd datasette-edit-templates\npython3 -mvenv venv\nsource venv/bin/activate\n```\nOr if you are using `pipenv`:\n```bash\npipenv shell\n```\nNow install the dependencies and tests:\n```bash\npip install -e '.[test]'\n```\nTo run the tests:\n```bash\npytest\n```\n",
    "bugtrack_url": null,
    "license": "Apache License, Version 2.0",
    "summary": "Plugin allowing Datasette templates to be edited within Datasette",
    "version": "0.4.3",
    "project_urls": {
        "CI": "https://github.com/simonw/datasette-edit-templates/actions",
        "Changelog": "https://github.com/simonw/datasette-edit-templates/releases",
        "Homepage": "https://github.com/simonw/datasette-edit-templates",
        "Issues": "https://github.com/simonw/datasette-edit-templates/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "82d17c8ecd3d4f96c0637894ab64f363987c5b0533e336b5dcb328ab7f1c24d3",
                "md5": "0538d8f2ea346bc7f66f25f9e0d4ba33",
                "sha256": "6fcb5b400d8f8cde0eba2781bfab8ba444a457fed32176fed5d62dece7ed2e8e"
            },
            "downloads": -1,
            "filename": "datasette_edit_templates-0.4.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0538d8f2ea346bc7f66f25f9e0d4ba33",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 82925,
            "upload_time": "2024-01-17T00:40:24",
            "upload_time_iso_8601": "2024-01-17T00:40:24.239384Z",
            "url": "https://files.pythonhosted.org/packages/82/d1/7c8ecd3d4f96c0637894ab64f363987c5b0533e336b5dcb328ab7f1c24d3/datasette_edit_templates-0.4.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9e8beb6de2d0dfb711e4374b6af88e2e371714c02ebc6b147a2f939a2f5447dc",
                "md5": "35806850c488d3dfa6ccec2ce4b56fbd",
                "sha256": "ad34eb90235e08b9883ce4262875d1d07d7564119e1fb9321ef595b9fd484157"
            },
            "downloads": -1,
            "filename": "datasette-edit-templates-0.4.3.tar.gz",
            "has_sig": false,
            "md5_digest": "35806850c488d3dfa6ccec2ce4b56fbd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 84332,
            "upload_time": "2024-01-17T00:40:26",
            "upload_time_iso_8601": "2024-01-17T00:40:26.094444Z",
            "url": "https://files.pythonhosted.org/packages/9e/8b/eb6de2d0dfb711e4374b6af88e2e371714c02ebc6b147a2f939a2f5447dc/datasette-edit-templates-0.4.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-17 00:40:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "simonw",
    "github_project": "datasette-edit-templates",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "datasette-edit-templates"
}
        
Elapsed time: 0.24179s