DevLog 3: Pagination, Fixes, and Refactor
Published on:
Features
Pagination
One of thing that was lacking in my website was proper pagination. It was never a necessity. But now, the users of the Ownet might publish posts and reactions every day.
Pagination for Posts
I added pagination support for posts and related pages. It will appear on the bottom of the posts page. The pagination is fixed to 20 posts per page, it could be made dynamic, I need to think of a non-confusing way to implement this later.
Pagination for Users
The users page is currently visible publicly, I can change that, but it’s not something I am concerned with right now, but it does lack pagination support if more many people register on the site. It will be a feature less used, but I also added a user search option in the users page.
Upload Search
I added search functionality to the “Manage Uploads” page, allowing users to filter images by filename or description.
While I am at it, I renamed “Manage Uploads” to “Manage Images” because it currently only support images, I will probably need to revert it one day though.
Added the original filename to the image details because we update it with a UUID on upload, we should still be able to search images by their original file name now.
Refactor
I renamed the /account route to /profile to avoid confusion with the “Account” dropdown in the navigation and improve clarity. It took a while to update all associated links, redirects and route handlers, I have the gut feeling that I missed a few of them, but that’s a problem for tomorrows me.
Breaking Changes
The primary keys were all over the place, where some using UUID, some strings, and some using serial integers. That would be a big problem later, so I decided to update the existing migration to use UUID while nobody is using the project.
This is not something I am proud of, and will break all my test sites, but nothing important is stored there anyway, so I guess it is fine.
- All primary key columns have been changed from
SERIALtoUUID. - The
upload_dirin theaccountstable now uses the account’sUUIDinstead of username. - The application code has been updated to use
Uuidinstead ofi32for all IDs. - Added error handling to all routes that accept a
UUIDas a parameter. - Updated the function signatures to return a
Resultwith astatus::BadRequestorstatus::NotFound.
Well, that’s a lot of things for the day. There wasn’t much real code changes unlike last time, apart from the Modal search feature, everything else were just find/replace. But the codebase is now much easier to look at.
Interactions
No interactions yet.