You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When lookup finds a close-but-not-exact match, it redirects to the thing it found and displays a flash message to let you know (for example, treeecko).
The flash is currently implemented by setting a variable containing the message in the user session, which sets a session cookie. The session is checked on every page load, and if there is a pending message, it is displayed. This is a fairly common way to implement flashes.
It would be nice to get rid of all our uses of the session (there aren't many) and make veekun completely stateless.
I propose changing lookup to pass this information through a query parameter instead of a session cookie. Specifically, if you lookup up "treeecko" and we find a single close match, the lookup would redirect to /dex/pokemon/treecko?from_lookup=treeecko. Every resource page would check for this parameter and, if present, plug its value into an appropriate flash message. We could even include a bit of javascript that uses history.replaceState() to hide the parameter after the page loads.
This parameter would also be helpful if we ever implement autocorrection of 404s. If someone navigates to /dex/pokemon/treeecko, it would be nice to automatically do a lookup and redirect them to /dex/pokemon/treecko. But i'm paranoid about accidentally causing redirect loops if we do that. We could use the from_lookup parameter to detect loops.
Indisciminately calling session.save() in flash.pop_messages() was
causing us to save the session on practically every page load,
regardless of whether there were any messages to display.
Somewhat related to veekun/spline-pokedex#119, which was causing a
similar problem.
When lookup finds a close-but-not-exact match, it redirects to the thing it found and displays a flash message to let you know (for example, treeecko).
The flash is currently implemented by setting a variable containing the message in the user session, which sets a session cookie. The session is checked on every page load, and if there is a pending message, it is displayed. This is a fairly common way to implement flashes.
It would be nice to get rid of all our uses of the session (there aren't many) and make veekun completely stateless.
I propose changing lookup to pass this information through a query parameter instead of a session cookie. Specifically, if you lookup up "treeecko" and we find a single close match, the lookup would redirect to
/dex/pokemon/treecko?from_lookup=treeecko
. Every resource page would check for this parameter and, if present, plug its value into an appropriate flash message. We could even include a bit of javascript that uses history.replaceState() to hide the parameter after the page loads.This parameter would also be helpful if we ever implement autocorrection of 404s. If someone navigates to
/dex/pokemon/treeecko
, it would be nice to automatically do a lookup and redirect them to/dex/pokemon/treecko
. But i'm paranoid about accidentally causing redirect loops if we do that. We could use thefrom_lookup
parameter to detect loops.Related to #115
The text was updated successfully, but these errors were encountered: