photo-gallery – HadCoffee Blog

Building the Cafe Photo Gallery Feature

I’ve held off on this for a while, but starting to build it out.

Did phase one today, which was:

  • New DB table for photos, using ulid for non-sequential ids
  • TDD: Writing tests that endpoint returns a list of photos for a cafe, and excludes ones that haven’t been approved yet
  • Creating the model and factory, and adding a global scope to the model so that by default only visible photos are returned.
    Admin interfaces that will need to get all photos for approval can bypass that scope (which is verified by a test).

Next steps could be endpoints and UI to actually upload photos. It’ll be a while before anything is visible on site, because uploading itself has a number of components. I’ll need a form to upload, possibly with Ajax for better UX, a queued job to resize images and maybe create a WebP conversion too, copying to S3 and updating the DB.

Ideally there’d also be a cropping widget in the browser for the thumbnail view.

To begin with only I will be able to add images, but I’d like to open it up to trusted users too.

Will also need tools for deleting (including S3 objects, not just the DB records).