Factory for record links generation.

def default_links_pagination_factory(page, urlkwargs):
    """Factory for record links generation."""
    endpoint = '.communities_list'

    links = {
        'self': url_for(endpoint, page=page.page, _external=True, **urlkwargs),
    }

    if page.has_prev:
        links['prev'] = url_for(endpoint, page=page.prev_num, _external=True,
                                **urlkwargs)
    if page.has_next:
        links['next'] = url_for(endpoint, page=page.next_num, _external=True,
                                **urlkwargs)

    return links