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
Working on displaying logged-in-user's reputation next to his/her name in the top nav bar. This is requiring modification of every Handler that renders a page, and passing the User and all Documents to all these handlers (because the reputation-computing function needs that info).
Snap.Snaplet.Auth gives the splice , which is automatically spliced out of every AuthManager'ed template.
Can I possibly do something similar? Snaplet.ReffitUser that automatically handles loggedInUser's reputation printing?
Also, printing the reputations of comment authors and discussion point writers is making for a lot of duplicate code. Is there a way around it?
The text was updated successfully, but these errors were encountered:
We should definitely use a similar model to that used in Snap.Snaplet.Auth by modifying the heist state at startup. This way we keep the Handlers separate from any rendering logic and should be able to just duplicate the tags in the html (which is much nicer than duplicating code within Handlers).
We should probably look to refactor more of the handlers in a similar fashion!
You would need a function i.e addReffitHesitConfig h. Which will be called within the main reffit application initializer function.
Thanks, that helped me think about this. Right now reputation is never stored in the database - it's always recomputed when its needed (every page load). The situation will be different when we move to SQL b/c we don't want to do all those database queries for every page render. So this particular bit of ugliness, I will wait to fix until I see how the integration of Persist shakes out (unless you see a trivial way to get the fix into the current code - which you might).
I'm still trying to understand snaplets & heist better so I can answer questions like: "could I make a spice available by a similar mechanism to Snap.Snaplet.Auth's, throughout the site, even though computing it requires at least one database lookup per page load? Or is it better to accomplish that in Site.hs with something looking like this (prob doesn't compile - just laying out general idea):
"
The alternative under Persistent would look similar, except I would be making some query into a ReffitUsers table, and the reputation would be stored right in that user's row.
Working on displaying logged-in-user's reputation next to his/her name in the top nav bar. This is requiring modification of every Handler that renders a page, and passing the User and all Documents to all these handlers (because the reputation-computing function needs that info).
Snap.Snaplet.Auth gives the splice , which is automatically spliced out of every AuthManager'ed template.
Can I possibly do something similar? Snaplet.ReffitUser that automatically handles loggedInUser's reputation printing?
Also, printing the reputations of comment authors and discussion point writers is making for a lot of duplicate code. Is there a way around it?
The text was updated successfully, but these errors were encountered: