On Wed, Mar 02, 2016 at 01:46:41AM +0200, fr33domlover wrote: > From: fr33domlover <fr33domlo...@rel4tion.org> > > A URL path like `/u/wolftune` is much more convenient than `/u/3`, > and most websites seem to use the former indeed. This is a (mostly, > see below) non-breaking change which: > > 1. Adds a new handler for `/u/<username>` which returns the usual > user page > 2. Makes `/u/<userid>` be a simple redirect to the new route > > Hopefully this is the beginning of moving to `/u/<username>` being > the primary path and `/u/<userid>` being secondary or even not > existing at all.
This is superb. I would like confirmation from the UI/UX team, but I'm going to move forward assuming they agree it's a good idea. If nothing else, it is a good *technology* decision that shields implementation details from the UI. > NOTE: If the current production database has a user whose > `userIdent` contains only digits, this change may create a problem. > This is unlikely, but worth checking just in case. This does bring up additional concerns we must address. I agree we should move towards /u/<username> being the default, and thus it should be reflected in the names. ** Tech action items - UserHandle should be redefined to Text - The existing route should be renamed getUserByIdR and should use UserId instead of UserHandle - The new route should get the original name UserR Additionally we need to safeguard ourselves against ambiguity. I just confirmed that no existing ident is all digits, so we have no existing problem. For the future, however, perhaps we should disallow all-digit usernames? ** Questions for other teams - Move forward with /u/<username>? - Disallow all-digit usernames to avoid future ambiguity? fr33, if you don't mind, can you be in charge of representing the development team in discussing this plan with the other teams? Thanks again either way. This is definitely a good idea. > --- > config/routes | 3 ++- > src/Handler/NewDesign.hs | 8 +++++++- > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/config/routes b/config/routes > index 999f36b..575cff3 100644 > --- a/config/routes > +++ b/config/routes > @@ -74,7 +74,8 @@ > -- ## Browsing a particular user (may need fleshing out?) > -- > > -/u/#UserHandle UserR GET > +/u/!#UserHandle UserR GET > +/u/#Text UserByIdentR GET > > -- Yesod jibber jabber > /static StaticR Static appStatic > diff --git a/src/Handler/NewDesign.hs b/src/Handler/NewDesign.hs > index 05829ab..dcfd060 100644 > --- a/src/Handler/NewDesign.hs > +++ b/src/Handler/NewDesign.hs > @@ -212,9 +212,15 @@ postCreateAccountR = do > -- | Public profile for a user. > getUserR :: UserId -> Handler Html > getUserR user_id = do > + user <- runYDB $ get404 user_id > + redirect $ UserByIdentR $ userIdent user > + > +-- | Public profile for a user. > +getUserByIdentR :: Text -> Handler Html > +getUserByIdentR user_ident = do > mviewer_id <- maybeAuthId > > - user <- runYDB $ get404 user_id > + Entity user_id user <- runYDB $ getBy404 $ UniqueUser user_ident > > projects_and_roles <- runDB (fetchUserProjectsAndRolesDB user_id) > when ( Just user_id == mviewer_id > -- > 1.9.1 > > _______________________________________________ > Dev mailing list > Dev@lists.snowdrift.coop > https://lists.snowdrift.coop/mailman/listinfo/dev
signature.asc
Description: Digital signature
_______________________________________________ Dev mailing list Dev@lists.snowdrift.coop https://lists.snowdrift.coop/mailman/listinfo/dev