Open simonw opened 3 years ago
An optional path
argument to https://docs.datasette.io/en/stable/plugin_hooks.html#register-output-renderer-datasette which shows the path WITHOUT the .Notebook
extension would be useful here.
This parameter will return the URL path, with querystring arguments, to the HTML version of the page - e.g. /github/issue_comments
or /github/issue_comments?_sort_desc=created_at
Open questions:
path
could be misleading since it also includes the querystring.url
or full_url
version which includes https://blah.com/...
?Django calls this HttpRequest.get_full_path()
- for the path plus the querystring.
I think I'll call this full_path
for consistency with Django.
In that case maybe there are three new arguments: path
, full_path
and url
.
I'll also add request.full_path
for consistency with these: https://github.com/simonw/datasette/blob/97fb10c17dd007a275ab743742e93e932335ad67/datasette/utils/asgi.py#L77-L90
I'm just going to do path
and full_path
(which includes the querystring). The
datasette.absolute_url()` method can be used by plugins that need the full URL.
The challenge here is figuring out what the original path, without the .format
, actually was - while taking into account that Datasette has a special case for tables that themselves end in a .something
.
The path_with_format()
function nearly does what we need here:
It can be called with replace_format="csv"
to REMOVE the .csv
format and replace it with something else.
Problem is, we want to use it to get rid of the format entirely.
We could update path_with_format()
to accept format=''
to mean "remove the format entirely", but it's a bit messy. It may be better to reconsider the design of path_with_format()
and related utility functions entirely.
https://github.com/simonw/datasette-export-notebook/blob/0.1/datasette_export_notebook/__init__.py
This results in https://latest-with-plugins.datasette.io/github/issue_comments.Notebook showing
http://latest-with-plugins.datasette.io/github/issue_comments.Notebook?_format=json&_shape=array