{"html_url": "https://github.com/simonw/datasette/issues/2112#issuecomment-1652722208", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2112", "id": 1652722208, "node_id": "IC_kwDOBm6k_c5igoog", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-07-27T00:24:50Z", "updated_at": "2023-07-27T00:25:16Z", "author_association": "OWNER", "body": "I changed my mind, I'm not going to do this with a format hook.\r\n\r\nAlso: https://github.com/simonw/datasette/issues/2109#issuecomment-1652715823\r\n\r\nI've decided to let HTML have its own special context. I'm going to try formalizing that as a `@dataclass` with fields with `metadata={\"help\": ...}` to see what that looks like.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1822938661, "label": "Build HTML version of /content?sql=..."}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2112#issuecomment-1652723029", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2112", "id": 1652723029, "node_id": "IC_kwDOBm6k_c5igo1V", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-07-27T00:25:49Z", "updated_at": "2023-07-27T00:25:49Z", "author_association": "OWNER", "body": "Getting the query page working with all of the necessary HTML context variables is a slog.\r\n\r\nI uploaded `query.html` to Claude and asked it \"List of every template context variable with a detailed description of each one\":\r\n\r\n\"image\"\r\n\r\n> Based on the template code provided, here is a list of the template context variables and a description of each one:\r\n> \r\n> - `database` - The name of the database being queried.\r\n> - `query` - The SQL query object containing the `sql` string.\r\n> - `canned_query` - The name of the canned query if this is a canned query. \r\n> - `private` - Boolean indicating if this is a private database.\r\n> - `urls` - Object containing URL helpers like `database()`.\r\n> - `canned_write` - Boolean indicating if this canned query allows writes.\r\n> - `db_is_immutable` - Boolean indicating if this database is immutable. \r\n> - `error` - Any query error message.\r\n> - `hide_sql` - Boolean indicating if the SQL should be hidden. \r\n> - `show_hide_link` - The URL to toggle showing/hiding the SQL.\r\n> - `show_hide_text` - The text for the show/hide SQL link. \r\n> - `editable` - Boolean indicating if the SQL can be edited.\r\n> - `allow_execute_sql` - Boolean indicating if custom SQL can be executed.\r\n> - `tables` - List of table objects in the database.\r\n> - `named_parameter_values` - Dictionary of parameter names/values.\r\n> - `csrftoken()` - Function to generate a CSRF token.\r\n> - `edit_sql_url` - URL to edit the SQL for a canned query.\r\n> - `display_rows` - List of result rows to display.\r\n> - `columns` - List of column names. \r\n> - `renderers` - Dictionary of renderer name to URL.\r\n> - `url_csv` - URL for CSV export.\r\n> - `metadata` - Metadata about the query/database.\r\n> - `crumbs` - Breadcrumb navigation object.\r\n> \r\n> So in summary, it includes variables for the database, query, results, URLs, permissions, and metadata to power the template.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1822938661, "label": "Build HTML version of /content?sql=..."}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2112#issuecomment-1652746185", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2112", "id": 1652746185, "node_id": "IC_kwDOBm6k_c5igufJ", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-07-27T00:46:37Z", "updated_at": "2023-07-27T00:46:37Z", "author_association": "OWNER", "body": "Got Claude to generate this code:\r\n```python\r\nfrom dataclasses import dataclass, field\r\n\r\n@dataclass\r\nclass QueryContext:\r\n database: str = field(metadata={\"help\": \"The name of the database being queried\"})\r\n query: dict = field(metadata={\"help\": \"The SQL query object containing the `sql` string\"})\r\n canned_query: str = field(metadata={\"help\": \"The name of the canned query if this is a canned query\"})\r\n private: bool = field(metadata={\"help\": \"Boolean indicating if this is a private database\"})\r\n urls: dict = field(metadata={\"help\": \"Object containing URL helpers like `database()`\"})\r\n canned_write: bool = field(metadata={\"help\": \"Boolean indicating if this canned query allows writes\"})\r\n db_is_immutable: bool = field(metadata={\"help\": \"Boolean indicating if this database is immutable\"})\r\n error: str = field(metadata={\"help\": \"Any query error message\"})\r\n hide_sql: bool = field(metadata={\"help\": \"Boolean indicating if the SQL should be hidden\"})\r\n show_hide_link: str = field(metadata={\"help\": \"The URL to toggle showing/hiding the SQL\"})\r\n show_hide_text: str = field(metadata={\"help\": \"The text for the show/hide SQL link\"})\r\n editable: bool = field(metadata={\"help\": \"Boolean indicating if the SQL can be edited\"})\r\n allow_execute_sql: bool = field(metadata={\"help\": \"Boolean indicating if custom SQL can be executed\"})\r\n tables: list = field(metadata={\"help\": \"List of table objects in the database\"})\r\n named_parameter_values: dict = field(metadata={\"help\": \"Dictionary of parameter names/values\"})\r\n csrftoken: callable = field(metadata={\"help\": \"Function to generate a CSRF token\"})\r\n edit_sql_url: str = field(metadata={\"help\": \"URL to edit the SQL for a canned query\"})\r\n display_rows: list = field(metadata={\"help\": \"List of result rows to display\"})\r\n columns: list = field(metadata={\"help\": \"List of column names\"})\r\n renderers: dict = field(metadata={\"help\": \"Dictionary of renderer name to URL\"})\r\n url_csv: str = field(metadata={\"help\": \"URL for CSV export\"})\r\n metadata: dict = field(metadata={\"help\": \"Metadata about the query/database\"})\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1822938661, "label": "Build HTML version of /content?sql=..."}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2112#issuecomment-1652751140", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2112", "id": 1652751140, "node_id": "IC_kwDOBm6k_c5igvsk", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-07-27T00:52:53Z", "updated_at": "2023-07-27T00:52:53Z", "author_association": "OWNER", "body": "Maybe I teach `datasette.render_template()` to take a dataclass instance as an optional alternative to a dictionary, and if it gets one it turns it into something that works well in the template context.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1822938661, "label": "Build HTML version of /content?sql=..."}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/2112#issuecomment-1668798642", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/2112", "id": 1668798642, "node_id": "IC_kwDOBm6k_c5jd9iy", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-08-08T02:01:01Z", "updated_at": "2023-08-08T02:01:01Z", "author_association": "OWNER", "body": "Shipped: https://latest.datasette.io/fixtures?sql=select+*+from+facetable", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1822938661, "label": "Build HTML version of /content?sql=..."}, "performed_via_github_app": null}