{"html_url": "https://github.com/simonw/datasette/issues/214#issuecomment-382048582", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/214", "id": 382048582, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MjA0ODU4Mg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-17T16:04:42Z", "updated_at": "2018-04-18T02:24:46Z", "author_association": "OWNER", "body": "One possible option: let plugins bundle their own `static/` directory and then register themselves with Datasette, then have `/-/static-plugins/name-of-plugin/...` serve files from that directory.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314506446, "label": "Ability for plugins to define extra JavaScript and CSS"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/214#issuecomment-382069980", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/214", "id": 382069980, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MjA2OTk4MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-17T17:08:28Z", "updated_at": "2018-04-17T17:08:28Z", "author_association": "OWNER", "body": "Even if we automatically serve ALL `static/` content from installed plugins, we'll still need them to register which files need to be linked to from `extra_css_urls` and `extra_js_urls`", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314506446, "label": "Ability for plugins to define extra JavaScript and CSS"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/214#issuecomment-382038613", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/214", "id": 382038613, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MjAzODYxMw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-17T15:38:23Z", "updated_at": "2018-04-17T15:38:23Z", "author_association": "OWNER", "body": "I figured out the recipe for bundling static assets in a plugin: https://github.com/simonw/datasette-plugin-demos/commit/26c5548f4ab7c6cc6d398df17767950be50d0edf (and then `python3 setup.py bdist_wheel`)\r\n\r\nHaving done that, I ran `pip install ../datasette-plugin-demos/dist/datasette_plugin_demos-0.2-py3-none-any.whl` from my Datasette virtual environment and then did the following:\r\n\r\n```\r\n>>> import pkg_resources\r\n>>> pkg_resources.resource_stream(\r\n... 'datasette_plugin_demos', 'static/plugin.js'\r\n... ).read()\r\nb\"alert('hello');\\n\"\r\n>>> pkg_resources.resource_filename(\r\n... 'datasette_plugin_demos', 'static/plugin.js'\r\n... )\r\n'..../venv/lib/python3.6/site-packages/datasette_plugin_demos/static/plugin.js'\r\n>>> pkg_resources.resource_string(\r\n... 'datasette_plugin_demos', 'static/plugin.js'\r\n... )\r\nb\"alert('hello');\\n\"\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314506446, "label": "Ability for plugins to define extra JavaScript and CSS"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/214#issuecomment-381612585", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/214", "id": 381612585, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MTYxMjU4NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-16T14:10:16Z", "updated_at": "2018-04-16T14:10:16Z", "author_association": "OWNER", "body": "`resource_stream` returns a file-like object which may be better for serving from Sanic.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314506446, "label": "Ability for plugins to define extra JavaScript and CSS"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/214#issuecomment-381491707", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/214", "id": 381491707, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MTQ5MTcwNw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-16T06:21:23Z", "updated_at": "2018-04-16T06:21:23Z", "author_association": "OWNER", "body": "This looks like a good example: https://github.com/funkey/nyroglancer/commit/d4438ab42171360b2b8e9020f672846dd70c8d80", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314506446, "label": "Ability for plugins to define extra JavaScript and CSS"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/214#issuecomment-381490361", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/214", "id": 381490361, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MTQ5MDM2MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2018-04-16T06:13:02Z", "updated_at": "2018-04-16T06:13:02Z", "author_association": "OWNER", "body": "Packaging JS and CSS in a pip installable wheel is fiddly but possible. http://peak.telecommunity.com/DevCenter/PythonEggs#accessing-package-resources\r\n\r\n from pkg_resources import resource_string\r\n foo_config = resource_string(__name__, 'foo.conf')", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 314506446, "label": "Ability for plugins to define extra JavaScript and CSS"}, "performed_via_github_app": null}