lorepub/moot

Conferences should have human-friendly slugs

Opened this issue · 3 comments

They should be unique and user defined probably. We can generate initial guesses at them.

I will try to start working on this.

Yesterday, we discussed ability for the admins to change their mind about
conference name used in the URL and application ability to honor old URLs.

My proposal is to introduce a new table (and to not modify any other tables)

ConferenceSlug sql=conf_slugs
  conference ConferenceId
  code ConferenceCode
  UniqueSlugCode code
  isActive Bool

I am not very familiar with Esqueleto/Persistent but I should be able to use
something like derivePersistField on a data/newtype ConferenceCode mapping
it to varchar. At any rate API methods will use it.

This table will hold (possibly several per conference) globally unique codes
used for humanly readable conference URLs.

All routes will use #ConferenceCode instead of #ConferenceId, e.g.

-- old
/conference/#ConferenceId/cfp/submit                     SubmitAbstractR GET POST
-- new 
/conference/#ConferenceCode/cfp/submit                   SubmitAbstractR GET POST

I will add some convenience functions that convert ConferenceCode to ConferenceId
and make handler conversion simple

-- returns conferenceId or active ConferenceCode if old slug is used
conferenceIdFromSlug :: ConferenceCode -> DB (Either ConferenceId (Maybe ConferenceCode))
-- issue redirect if user is using old URL
withSlugOr301or404 :: ConferenceCode -> (ConferenceId -> Handler a) -> Handler a

To reduce merge conflicts and achieve temporary backward compatibility I may end up
keeping existing routes and handlers as deprecated and defining new to start.

Admin views, etc will need to be modified to populate ConferenceSlug table by inserting
record or changing isActive flag (if admin flip-flops to a previously defined code).
UI changes need more thought but maybe we can just start with a text field where
admin enters the code, this will need some URL encoding or validation.

I was contemplating using Network-Wai-Middleware-Rewrite or writing wai
middleware for handling old URLs but this does not give me much (since routes
and handlers need to be modified anyway).

Proof of concept pull request ready