-
-
Notifications
You must be signed in to change notification settings - Fork 703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mechanism for adding arbitrary pages like /about #648
Comments
Idea: do this with a simple template naming convention. If you hit |
Alternative idea: a new concept of "pages" which live inside
This only takes effect on 404 errors from core Datasette. |
Stretch goal: it would be neat if these pages could return custom HTTP headers (eg content-type) and maybe even status codes (eg for redirects) somehow. |
The implementation in c5e8cd8 acts as a proof of concept. It has a big flaw though: it doesn't reuse the regular render() mechanism, which means it doesn't register custom template tags from plugins. This is bad because it means that pages rendered in this way cannot take advantage of things like datasette-template-sql. This means this issue is likely dependent on #577 - a documented mechanism to allow plugins to render templates. |
Now that I've closed #577 this should be pretty easy to implement. |
I think I could do that with a custom template function - if that function is called during the render then we follow those instructions instead of returning the rendered HTML. |
The trickiest part here is the 404 logic. It's spread out through a couple of places right now. It's in datasette/datasette/utils/asgi.py Lines 98 to 134 in 227bb3e
Then also in the `DatasetteRouter subclass of that: Lines 736 to 757 in 227bb3e
|
Idea: Lines 748 to 765 in 227bb3e
|
|
https://www.niche-museums.com/about now uses this mechanism. It used to be an empty |
Hi! I'm using datasette on this repository: https://github.com/chekos/RIPA-2018-datasette and on my local machine i can see an /about page i created but when i deploy to heroku i get a 404 (http://ripa-2018-db.herokuapp.com) I bumped datasette in my requirements file to 0.41 so I'm 100% what the issue is 🤔 Do you have any idea what could be the problem? 👀 EDIT: for context, I have a templates directory with a pages/about.html file in https://github.com/chekos/RIPA-2018-datasette/tree/master/datasette/templates |
It seems that heroku wasn't updating to 0.41 on deployment. Had to add and (i think) because the These are the lines that gave me an idea on how to solve it: datasette/datasette/publish/heroku.py Lines 164 to 186 in 182e5c8
|
For www.niche-museums.com I solved this by creating an empty
about.db
database file - see https://simonwillison.net/2019/Nov/25/niche-museums/I want a neater mechanism for this.
The text was updated successfully, but these errors were encountered: