{"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-709633823", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 709633823, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTYzMzgyMw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T23:01:13Z", "updated_at": "2020-10-15T23:01:13Z", "author_association": "OWNER", "body": "Tracking ticket: #1023", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-709634261", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 709634261, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTYzNDI2MQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T23:02:43Z", "updated_at": "2020-10-15T23:02:43Z", "author_association": "OWNER", "body": "Here's the current implementation of `database_url` - on the `BaseView` class, but only because it needs access to a `datasette` instance (to read `base_url`):\r\nhttps://github.com/simonw/datasette/blob/8f97b9b58e77f82fef1f10e9c9f6754b993544b6/datasette/views/base.py#L102-L108", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-709635021", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 709635021, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTYzNTAyMQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T23:05:11Z", "updated_at": "2020-10-15T23:05:11Z", "author_association": "OWNER", "body": "I think this should be a family of functions:\r\n\r\n- `instance_url()` - the root URL of the instance (usually `/` unless `base_url` is set)\r\n- `database_url(database_name)` - already got this\r\n- `table_url(database_name, table_name)`\r\n- `row_url(database_name, table_name, row)` - not sure about this one. The idea would be for `row` to be correctly turned into a URL by introspecting the primary keys for that table, then pulling those values out of the SQLite `row` object. Might not be necessary though.\r\n\r\nI also need a way for plugins to link to e.g. `/-/configure-fts` - or even `/-/configure-fts/database-name/table-name`. What should that look like?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-709635276", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 709635276, "node_id": "MDEyOklzc3VlQ29tbWVudDcwOTYzNTI3Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-15T23:05:54Z", "updated_at": "2020-10-15T23:05:54Z", "author_association": "OWNER", "body": "Could have `instance_url()` take an optional path argument which is then turned into the correct path.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-710487083", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 710487083, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDQ4NzA4Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T19:34:10Z", "updated_at": "2020-10-19T17:39:04Z", "author_association": "OWNER", "body": "Alternatively, I could expose a single object that knows how to construct all kinds of URLs. Something like this:\r\n```\r\n{{ urls.instance() }}\r\n{{ urls.database(database_name) }}\r\n{{ urls.table(database_name, table_name) }}\r\netc\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-712324077", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 712324077, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjMyNDA3Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-19T17:39:38Z", "updated_at": "2020-10-19T17:39:38Z", "author_association": "OWNER", "body": "If I do these methods I think this should be available on the `datasette` object too, as an internal API for plugins to use to construct redirects and suchlike.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-712354600", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 712354600, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjM1NDYwMA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-19T18:15:03Z", "updated_at": "2020-10-19T18:15:39Z", "author_association": "OWNER", "body": "Related: #1026 (How should datasette.client interact with base_url)\r\n\r\nAlso this comment from https://github.com/simonw/datasette/issues/943#issuecomment-675752436\r\n\r\n> One thing to consider here: Datasette's table and database name escaping rules can be a little bit convoluted.\r\n> \r\n> If a plugin wants to get back the first five rows of a table, it will need to construct a URL `/dbname/tablename?_size=5` - but it will need to know how to turn the database and table names into the correctly escaped `dbname` and `tablename` values.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-712355706", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 712355706, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjM1NTcwNg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-19T18:17:03Z", "updated_at": "2020-10-19T18:17:03Z", "author_association": "OWNER", "body": "Options:\r\n- `datasette.urls.instance()` (or `datasette.urls.root()`), `datasette.urls.table()` etc\r\n- `datasette.url_for.instance()`...\r\n- `datasette.url.instance()`...\r\n- `datasette.root_url()`, `datasette.table_url()`...", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-712355877", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 712355877, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjM1NTg3Nw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-19T18:17:22Z", "updated_at": "2020-10-19T18:17:22Z", "author_association": "OWNER", "body": "I quite like `datasette.urls.table()` but I'm not sure why.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-712483066", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 712483066, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjQ4MzA2Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-19T22:46:48Z", "updated_at": "2020-10-19T22:46:48Z", "author_association": "OWNER", "body": "OK, I'm committing to `datasette.urls.table()` and friends, which will be available to (and documented for use in) plugins and will be exposed to templates as `{{ urls.table(...) }}`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/904#issuecomment-712524699", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/904", "id": 712524699, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMjUyNDY5OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-20T01:04:12Z", "updated_at": "2020-10-20T01:04:12Z", "author_association": "OWNER", "body": "Documentation is https://docs.datasette.io/en/latest/writing_plugins.html#building-urls-within-plugins and https://docs.datasette.io/en/latest/internals.html#internals-datasette-urls", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 663228985, "label": "datasette.urls.table() / .instance() / .database() methods for constructing URLs, also exposed to templates"}, "performed_via_github_app": null}