{"html_url": "https://github.com/simonw/datasette/issues/1767#issuecomment-1175396774", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1767", "id": 1175396774, "node_id": "IC_kwDOBm6k_c5GDyGm", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-05T18:56:43Z", "updated_at": "2022-07-05T18:56:43Z", "author_association": "OWNER", "body": "Based on https://github.com/python/cpython/blob/3.11/Lib/imghdr.py I'm tempted to say that if the file starts with `b'\\211PNG\\r\\n\\032\\n'` then it's a PNG, if it starts with `b'GIF8` then it's a GIF, anything else I assume an ICO.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1294641696, "label": "Ability to set a custom favicon"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1767#issuecomment-1175391899", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1767", "id": 1175391899, "node_id": "IC_kwDOBm6k_c5GDw6b", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-05T18:53:07Z", "updated_at": "2022-07-05T18:53:07Z", "author_association": "OWNER", "body": "https://www.w3.org/2005/10/howto-favicon suggests that it only needs to be able to identify PNG, GIF or ICO.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1294641696, "label": "Ability to set a custom favicon"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1767#issuecomment-1175388492", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1767", "id": 1175388492, "node_id": "IC_kwDOBm6k_c5GDwFM", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-05T18:51:26Z", "updated_at": "2022-07-05T18:51:26Z", "author_association": "OWNER", "body": "I could vendor the necessary parts of `imghdr` - it's pretty tiny: https://github.com/python/cpython/blob/3.11/Lib/imghdr.py", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1294641696, "label": "Ability to set a custom favicon"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1767#issuecomment-1175385249", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1767", "id": 1175385249, "node_id": "IC_kwDOBm6k_c5GDvSh", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-05T18:49:52Z", "updated_at": "2022-07-05T18:49:52Z", "author_association": "OWNER", "body": "I could use the `imghdr` standard library module, but frustratingly it's marked as deprecated in Python 3.11! https://docs.python.org/3/library/imghdr.html", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1294641696, "label": "Ability to set a custom favicon"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1767#issuecomment-1175381896", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1767", "id": 1175381896, "node_id": "IC_kwDOBm6k_c5GDueI", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-05T18:48:14Z", "updated_at": "2022-07-05T18:48:50Z", "author_association": "OWNER", "body": "Annoyingly it looks like the standard library `mimetypes` module only uses filenames as the clue, it doesn't look at the bytes themselves.\r\n\r\nI'm using that here: https://github.com/simonw/datasette/blob/9f1eb0d4eac483b953392157bd9fd6cc4df37de7/datasette/utils/asgi.py#L261-L277\r\n\r\nhttps://pypi.org/project/python-magic/ can inspect files, but I don't want to add a whole new dependency just for this one feature.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1294641696, "label": "Ability to set a custom favicon"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1767#issuecomment-1175378678", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1767", "id": 1175378678, "node_id": "IC_kwDOBm6k_c5GDtr2", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-05T18:45:23Z", "updated_at": "2022-07-05T18:45:23Z", "author_association": "OWNER", "body": "The content type thing is a bit weird because usually I'd base that on the file extension, but here the `favicon.ico` file extension doesn't necessarily reflect if the image itself is a PNG or some other thing.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1294641696, "label": "Ability to set a custom favicon"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1767#issuecomment-1175377618", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1767", "id": 1175377618, "node_id": "IC_kwDOBm6k_c5GDtbS", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-05T18:44:08Z", "updated_at": "2022-07-05T18:44:08Z", "author_association": "OWNER", "body": "Loading it using the existing templating system would be better I think, since that way both custom installations AND plugins could influence the favicon in the same way that they influence the templates.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1294641696, "label": "Ability to set a custom favicon"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1767#issuecomment-1175377125", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1767", "id": 1175377125, "node_id": "IC_kwDOBm6k_c5GDtTl", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-05T18:43:35Z", "updated_at": "2022-07-05T18:43:35Z", "author_association": "OWNER", "body": "I think I want this to be a default feature, not a plugin.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1294641696, "label": "Ability to set a custom favicon"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1767#issuecomment-1175376866", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1767", "id": 1175376866, "node_id": "IC_kwDOBm6k_c5GDtPi", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-05T18:43:12Z", "updated_at": "2022-07-05T18:43:12Z", "author_association": "OWNER", "body": "Some options:\r\n\r\n- Allow `favicon` path to be set in `metadata.yml` somehow, or via a `--setting`\r\n- Teach Datasette to check for `templates/favicon.ico` and fall back to the default `static/favicon.png` if that file does not exist\r\n- Document how to over-ride the favicon using the existing `--static` mechanism (if that's even possible)\r\n- Outsource this to a new plugin\r\n\r\nNote that I need a way to set the `content_type` correctly too.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1294641696, "label": "Ability to set a custom favicon"}, "performed_via_github_app": null}