A pagination extension for Chrome

The Good

I have created a simple pagination extension for chrome. Although I have zero interest in pagination and I prefer scrolling, I decided to make this extension as a proof of concept.

The extension adds five buttons below the timeline, one for the first and last page, one for the next and previous pages and a button with the current page. This is the github repo for the extension:

https://github.com/meredoth/Unity-Discourse-Pagination

It is under GPL v3, so you can change the code as you see fit.

The Bad

Discourse is not designed to support traditional pagination. By examining Discourse’s code and its API, the best approach is to create an extension like this one, which links to specific posts in a topic and treats a set number of posts as a “page.” In this extension, each “page” contains 20 posts, but this can easily be adjusted in the extension’s code.

This is not traditional pagination, as users can continue scrolling down on any page. The extension updates the current page number button even when the user scrolls and stops, and the next and previous buttons are evaluated lazily. This means that when clicked, these buttons will navigate to the next or previous “page” from the current position, not from the original “page” where the user started scrolling when the buttons were first created. This functionality is possible because the extension uses the new navigation events API. Unfortunately, this API is not yet supported in Firefox and Safari, so anyone wanting to adapt this script for these browsers will have to wait or use a more complex solution.

While having both scrolling and pagination might seem beneficial to some users, I believe implementing such a feature server-side, could significantly hinder the forum’s performance.

The Ugly

I am always amazed by programming communities that constantly complain about certain functionalities, argue about how easy they would be to implement, and offer opinions on their implementation. These users often spend their time writing critical posts instead of actually creating the solutions themselves.

I can understand non-programmers complaining about the lack of pagination. However, if you are a programmer who has been complaining about this on the forums instead of spending three hours to read the Discourse API and write a simple script of fewer than a hundred lines, you might need to reconsider your approach to programming.

Especially if you belong to the camp of “Unity is not open source, so I cannot make changes to the engine”, wanted pagination functionality, and have not taken the time to write a simple script like this for Discourse, which is open-source with a great API for extensions and plugins, then maybe programming isn’t for you.

As I mentioned at the beginning of this post, I have zero interest in pagination, so I will not be making any changes to this script. Use it as a starting point for your own needs. I don’t intend to maintain or support this extension as it is not useful to me and I strongly dislike frontend work, so any changes or improvements you might need — such as modifying the buttons to suit your preferences, because they are too old, too fat or too blond — should be done by you.

3 Likes

We should not have to do this to the forum software. It makes sense to want to extend the Unity editor because it is extremely tool heavy and requires specialization per project, and honestly has APIs that are better than this than Discourse is anyway. This attitude is worse than anyone complaining about the poor functionality and transition to this new forum software.

2 Likes

I am working on a userscript of my own for improvements on here though hadn’t got to adding pagination (was planning to add numbered pages for the topic views) as I was adding a few bits there already so did look into and seems you’ve done what I was thinking about though that way of doing it causes a page reload when you are already on the post view where as there does seem to be an internal method of moving to a particular post number ie via hotkey ‘#’ which allows for a numbered post jump without triggering a whole refresh of site which is alot better and faster to use, though what I’ve tried so far to tap into that hasn’t worked… but then I hate javascrap and I don’t think much of a discourse as vendor beyond overrated and over valued in market value… who knows why anyone would use this software for a forum, to think this junk has been around for almost a decade and the idea of them adding pagination or having signature support built in instead of some basic rubbish plugin is pretty lame among other ux failures.