Insert pagination utilities from beego/wetalk. Refs #835.

Counterpart is beego/wetalk#38.