BIN-3 Object Visibility for Browsers
In this third Bovine Implementation Note, I will discuss how I am handling what to show to an user viewing an object from Bovine in a web browser. This is mainly so I have a specification to refer to from writing the tests for Bovine. There will be two types of behavior, first for objects having an
url property, i.e. objects having a known web representation, second objects without the url property.
First, Bovine stores objects by their
id. This means that the typical Create Activity and Note Object consisting a post, get stored as two objects. I’m unsure how one would display a Create Activity. Instead of trying to display it, I have written a fallback page, one can view here. As this is already good enough behavior, I will use it for the display of any object.
The second case are objects with a known web representation. These are for example given by the posts on this blog. If one opens the Article object, corresponding to BIN-2, one gets redirected to it. You can observer this by clicking here.
Mastodon links to the url followed by the id, if the url is unavailable, in its Open original page option. Speaking of Mastodon as far as I can tell its solution is to show 404 not found when trying to access say a Follow request in the browser.
Checking the definition of url, I have realized that my original implementation is to naive. So, here is a fairly decent algorithm. Assume that a user is making a GET request for an object with accept header
text/html and no special authorization. Then the following algorithm should take place
- Lookup the object. If it doesn’t exist, return 404 not found.
- Check if the object is public. If not, return 401 unauthorized.
- Check if object has an
url. If not, return a fallback page.
- Check if
urlis a single link. If yes, redirect to it and you are done.
- Check if
urlhas a link matching the accept header. If yes, redirect to it and you are done.
- Return the fallback page.
I’ve already written about this issue here and think that this might not be the final time that I will have something to say about it. Furthermore, I plan on using this as a reference for my tests in Bovine. So if you are interested on how this can be used to write tests, check Specification.md.
Note the above file is automatically generated from its template, so the links to the tests should stay up to date.