Source

django-simplepagination / simplepagination / backends / filmfeed.py

Full commit
class FilmfeedPaginator(object):
    def paginate(self, frame_size, pages, page_num):
        output = {}
        if pages < frame_size:
            output['page_numbers'] = range(1, pages + 1)
        elif page_num < (frame_size / 2) + 1:
            output['page_numbers'] = range(1, frame_size + 1)
        elif page_num >= (frame_size / 2) + 1 and pages - (frame_size / 2) <= page_num:
            output['page_numbers'] = range(pages - frame_size + 1, pages + 1)
        elif page_num >= (frame_size / 2) + 1:
            start = page_num - (frame_size / 2)
            end = page_num + (frame_size / 2)
            output['page_numbers'] = range(start, end + 1)
        return output