packages: datasette-json-html

This data as json

package info
datasette-json-html
{
    "info": {
        "author": "Simon Willison",
        "author_email": "",
        "bugtrack_url": null,
        "classifiers": [],
        "description": "# datasette-json-html\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-json-html.svg)](https://pypi.org/project/datasette-json-html/)\n[![Travis CI](https://travis-ci.com/simonw/datasette-json-html.svg?branch=master)](https://travis-ci.com/simonw/datasette-json-html)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/datasette-json-html/blob/master/LICENSE)\n\nDatasette plugin for rendering HTML based on JSON values, using the [render_cell plugin hook](https://datasette.readthedocs.io/en/latest/plugins.html#plugin-hook-render-cell).\n\nThis plugin looks for cell values that match a very specific JSON format and converts them into HTML when they are rendered by the Datasette interface.\n\nSee [russian-ira-facebook-ads-datasette](https://github.com/simonw/russian-ira-facebook-ads-datasette) for an example of this plugin in action.\n\n## Links\n\n    {\n        \"href\": \"https://simonwillison.net/\",\n        \"label\": \"Simon Willison\"\n    }\n\nWill be rendered as an `<a href=\"\">` link:\n\n    <a href=\"https://simonwillison.net/\">Simon Willison</a>\n\n## List of links\n\n    [\n        {\n            \"href\": \"https://simonwillison.net/\",\n            \"label\": \"Simon Willison\"\n        },\n        {\n            \"href\": \"https://github.com/simonw/datasette\",\n            \"label\": \"Datasette\"\n        }\n    ]\n\nWill be rendered as a comma-separated list of `<a href=\"\">` links:\n\n    <a href=\"https://simonwillison.net/\">Simon Willison</a>,\n    <a href=\"https://github.com/simonw/datasette\">Datasette</a>\n\nThe `href` property must begin with `https://` or `http://` or `/`, to avoid potential XSS injection attacks (for example URLs that begin with `javascript:`).\n\n## Images\n\nThe image tag is more complex. The most basic version looks like this:\n\n    {\n        \"img_src\": \"https://placekitten.com/200/300\"\n    }\n\nThis will render as:\n\n    <img src=\"https://placekitten.com/200/300\">\n\nBut you can also include one or more of `alt`, `caption`, `width` and `href`.\n\nIf you include width or alt, they will be added as attributes:\n\n    {\n        \"img_src\": \"https://placekitten.com/200/300\",\n        \"alt\": \"Kitten\",\n        \"width\": 200\n    }\n\nProduces:\n\n    <img src=\"https://placekitten.com/200/300\"\n        alt=\"Kitten\" width=\"200\">\n\nThe `href` key will cause the image to be wrapped in a link:\n\n    {\n        \"img_src\": \"https://placekitten.com/200/300\",\n        \"href\": \"http://www.example.com\"\n    }\n\nProduces:\n\n    <a href=\"http://www.example.com\">\n        <img src=\"https://placekitten.com/200/300\">\n    </a>\n\nThe `caption` key wraps everything in a fancy figure/figcaption block:\n\n    {\n        \"img_src\": \"https://placekitten.com/200/300\",\n        \"caption\": \"Kitten caption\"\n    }\n\nProduces:\n\n    <figure>\n        <img src=\"https://placekitten.com/200/300\"></a>\n        <figcaption>Kitten caption</figcaption>\n    </figure>\n\n## Preformatted text\n\nYou can use `{\"pre\": \"text\"}` to render text in a `<pre>` HTML tag:\n\n    {\n        \"pre\": \"This\\nhas\\nnewlines\"\n    }\n\nProduces:\n\n    <pre>This\n    has\n    newlines</pre>\n\nIf the value attached to the `\"pre\"` key is itself a JSON object, that JSON will be pretty-printed:\n\n    {\n        \"pre\": {\n            \"this\": {\n                \"object\": [\"is\", \"nested\"]\n            }\n        }\n    }\n\nProduces:\n\n    <pre>{\n      &#34;this&#34;: {\n        &#34;object&#34;: [\n          &#34;is&#34;,\n          &#34;nested&#34;\n        ]\n      }\n    }</pre>\n\n## Using these with SQLite JSON functions\n\nThe most powerful way to make use of this plugin is in conjunction with SQLite's [JSON functions](https://www.sqlite.org/json1.html). For example:\n\n    select json_object(\n        \"href\", \"https://simonwillison.net/\",\n        \"label\", \"Simon Willison\"\n    );\n\nYou can use these functions to construct JSON objects that work with the plugin from data in a table:\n\n    select id, json_object(\n        \"href\", url, \"label\", text\n    ) from mytable;\n\n## The `urllib_quote_plus()` SQL function\n\nSince this plugin is designed to be used with SQL that constructs the underlying JSON structure, it is likely you will need to construct dynamic URLs from results returned by a SQL query.\n\nThis plugin registers a custom SQLite function called `urllib_quote_plus()` to help you do that. It lets you use Python's [urllib.parse.quote\\_plus() function](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.quote_plus) from within a SQL query.\n\nHere's an example of how you might use it:\n\n    select id, json_object(\n        \"href\",\n        \"/mydatabase/other_table?_search=\" || urllib_quote_plus(text),\n        \"label\", text\n    ) from mytable;\n\n\n",
        "description_content_type": "text/markdown",
        "docs_url": null,
        "download_url": "",
        "downloads": {
            "last_day": -1,
            "last_month": -1,
            "last_week": -1
        },
        "home_page": "https://github.com/simonw/datasette-json-html",
        "keywords": "",
        "license": "Apache License, Version 2.0",
        "maintainer": "",
        "maintainer_email": "",
        "name": "datasette-json-html",
        "package_url": "https://pypi.org/project/datasette-json-html/",
        "platform": "",
        "project_url": "https://pypi.org/project/datasette-json-html/",
        "project_urls": {
            "Homepage": "https://github.com/simonw/datasette-json-html"
        },
        "release_url": "https://pypi.org/project/datasette-json-html/0.4.1/",
        "requires_dist": [
            "datasette"
        ],
        "requires_python": "",
        "summary": "Datasette plugin for rendering HTML based on JSON values",
        "version": "0.4.1"
    },
    "last_serial": 4744762,
    "releases": {
        "0.1": [
            {
                "comment_text": "",
                "digests": {
                    "md5": "0cdcb09f9c81a90f0d820fdc173b45bd",
                    "sha256": "275fde7c263584104c7ac080ed0f8e84258b17051d6837119e3cf2b0766064e2"
                },
                "downloads": -1,
                "filename": "datasette_json_html-0.1-py3-none-any.whl",
                "has_sig": false,
                "md5_digest": "0cdcb09f9c81a90f0d820fdc173b45bd",
                "packagetype": "bdist_wheel",
                "python_version": "py3",
                "requires_python": null,
                "size": 3132,
                "upload_time": "2018-07-31T05:51:44",
                "url": "https://files.pythonhosted.org/packages/95/07/b3be843a04a44fa93419aca9556022be234340d0c8aa50e3652eadcf5dcd/datasette_json_html-0.1-py3-none-any.whl"
            }
        ],
        "0.2": [
            {
                "comment_text": "",
                "digests": {
                    "md5": "d158ef70e9826fa1743a5d8f727779b4",
                    "sha256": "e8a5aee9acbab87fdbf4a4b06ea42ed16d832a788fcdd233fca28eb2c555a3ae"
                },
                "downloads": -1,
                "filename": "datasette_json_html-0.2-py3-none-any.whl",
                "has_sig": false,
                "md5_digest": "d158ef70e9826fa1743a5d8f727779b4",
                "packagetype": "bdist_wheel",
                "python_version": "py3",
                "requires_python": null,
                "size": 3356,
                "upload_time": "2018-07-31T06:09:32",
                "url": "https://files.pythonhosted.org/packages/57/dc/0830bc397d506818ee5fd712e7238fa1427eb42784d8aa18673cf98239ad/datasette_json_html-0.2-py3-none-any.whl"
            }
        ],
        "0.3": [
            {
                "comment_text": "",
                "digests": {
                    "md5": "e34f8f78362eb385959383b79df1e1c6",
                    "sha256": "9963101e0986f314b0f9a58a1799411231b6a505b3faca89595466fe8881aa68"
                },
                "downloads": -1,
                "filename": "datasette_json_html-0.3-py3-none-any.whl",
                "has_sig": false,
                "md5_digest": "e34f8f78362eb385959383b79df1e1c6",
                "packagetype": "bdist_wheel",
                "python_version": "py3",
                "requires_python": null,
                "size": 3789,
                "upload_time": "2018-07-31T15:23:17",
                "url": "https://files.pythonhosted.org/packages/6e/3d/5b27d000fd0654f580e20d1487d5f0de9b2fcdc6ed8e6a2708a8e9a214c4/datasette_json_html-0.3-py3-none-any.whl"
            }
        ],
        "0.3.1": [
            {
                "comment_text": "",
                "digests": {
                    "md5": "050b6623807ea067468425522a8a32d3",
                    "sha256": "2bef3c6cdefd89abc2de5cc07e3276c88897ab691b695e67ebfc9c2dfba9e506"
                },
                "downloads": -1,
                "filename": "datasette_json_html-0.3.1-py3-none-any.whl",
                "has_sig": false,
                "md5_digest": "050b6623807ea067468425522a8a32d3",
                "packagetype": "bdist_wheel",
                "python_version": "py3",
                "requires_python": null,
                "size": 3818,
                "upload_time": "2018-08-06T03:47:32",
                "url": "https://files.pythonhosted.org/packages/f8/e7/d11d7980e8220a1603880a3b5b11fc438bf8f0a2dbd384c8d4169f561d4d/datasette_json_html-0.3.1-py3-none-any.whl"
            }
        ],
        "0.3.2": [
            {
                "comment_text": "",
                "digests": {
                    "md5": "56f59add34097e91e78c5dbf8a99998a",
                    "sha256": "8aa135005e2f3995b6adbcd897a53fe357f68f307035481089fb3f489209468d"
                },
                "downloads": -1,
                "filename": "datasette_json_html-0.3.2-py3-none-any.whl",
                "has_sig": false,
                "md5_digest": "56f59add34097e91e78c5dbf8a99998a",
                "packagetype": "bdist_wheel",
                "python_version": "py3",
                "requires_python": null,
                "size": 3946,
                "upload_time": "2018-08-06T03:49:52",
                "url": "https://files.pythonhosted.org/packages/8a/e4/728da78ddebbd65d65127b220cb1cd0f54be428a25fed610b63a888cd34e/datasette_json_html-0.3.2-py3-none-any.whl"
            }
        ],
        "0.3.4": [
            {
                "comment_text": "",
                "digests": {
                    "md5": "13322a3d41dc6cfb6f3b80a2218b5b76",
                    "sha256": "e59cc93f3925620018e5537f227c78735e8d92580e08460d99257dde55c92bc6"
                },
                "downloads": -1,
                "filename": "datasette_json_html-0.3.4-py3-none-any.whl",
                "has_sig": false,
                "md5_digest": "13322a3d41dc6cfb6f3b80a2218b5b76",
                "packagetype": "bdist_wheel",
                "python_version": "py3",
                "requires_python": null,
                "size": 3948,
                "upload_time": "2018-08-06T04:00:55",
                "url": "https://files.pythonhosted.org/packages/e7/6b/849633456eac98eb5e4d61327e4994692300f0c292c98d3744af631b96d7/datasette_json_html-0.3.4-py3-none-any.whl"
            }
        ],
        "0.4.0": [
            {
                "comment_text": "",
                "digests": {
                    "md5": "67b8b60a95c75cf330cc5254301a67b9",
                    "sha256": "31e110862086048f1014da7fd6ad777d432612b51d47ed44599c2aa82c567af2"
                },
                "downloads": -1,
                "filename": "datasette_json_html-0.4.0-py3-none-any.whl",
                "has_sig": false,
                "md5_digest": "67b8b60a95c75cf330cc5254301a67b9",
                "packagetype": "bdist_wheel",
                "python_version": "py3",
                "requires_python": null,
                "size": 8359,
                "upload_time": "2019-01-02T04:18:07",
                "url": "https://files.pythonhosted.org/packages/d7/85/12c208c01e4354089ca8e96be5d0213e79a5d05c44b4b9a63176b66ad59c/datasette_json_html-0.4.0-py3-none-any.whl"
            }
        ],
        "0.4.1": [
            {
                "comment_text": "",
                "digests": {
                    "md5": "f8c652208e59765d8aa64829dce2e24c",
                    "sha256": "d69683d32dc47d3e83b86c04e52e182bffb328a0fc3582cd444bbba453b39f7b"
                },
                "downloads": -1,
                "filename": "datasette_json_html-0.4.1-py3-none-any.whl",
                "has_sig": false,
                "md5_digest": "f8c652208e59765d8aa64829dce2e24c",
                "packagetype": "bdist_wheel",
                "python_version": "py3",
                "requires_python": null,
                "size": 8333,
                "upload_time": "2019-01-26T23:08:12",
                "url": "https://files.pythonhosted.org/packages/5f/b9/d437c2c728a7f14858d55780fac09c7ef3b01f4856fd93ab22bf93787588/datasette_json_html-0.4.1-py3-none-any.whl"
            }
        ]
    },
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "f8c652208e59765d8aa64829dce2e24c",
                "sha256": "d69683d32dc47d3e83b86c04e52e182bffb328a0fc3582cd444bbba453b39f7b"
            },
            "downloads": -1,
            "filename": "datasette_json_html-0.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f8c652208e59765d8aa64829dce2e24c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8333,
            "upload_time": "2019-01-26T23:08:12",
            "url": "https://files.pythonhosted.org/packages/5f/b9/d437c2c728a7f14858d55780fac09c7ef3b01f4856fd93ab22bf93787588/datasette_json_html-0.4.1-py3-none-any.whl"
        }
    ]
}
Powered by Datasette · Query took 1.132ms