(start, total, cur, show_max)
return ps
returns a list of pages to be linked for navigation in a paginated view

    >>> get_page_list(1, 100, 1, 10)
    [1, 2, 3, 4, 5, 6, '...', 98, 99, 100]

    >>> get_page_list(1, 995/10, 1, 10)
    [1, 2, 3, 4, 5, 6, '...', 98, 99, 100]

    >>> get_page_list(1, 100, 50, 10)
    [1, '...', 48, 49, 50, 51, '...', 98, 99, 100]

    >>> get_page_list(1, 100, 99, 10)
    [1, '...', 97, 98, 99, 100]

    >>> get_page_list(1, 3, 2, 10)
    [1, 2, 3]
returns a list of pages to be linked for navigation in a paginated view
returns a list of pages to be linked for navigation in a paginated view
def get_page_list(start, total, cur, show_max):
    """
    returns a list of pages to be linked for navigation in a paginated view

    >>> get_page_list(1, 100, 1, 10)
    [1, 2, 3, 4, 5, 6, '...', 98, 99, 100]

    >>> get_page_list(1, 995/10, 1, 10)
    [1, 2, 3, 4, 5, 6, '...', 98, 99, 100]

    >>> get_page_list(1, 100, 50, 10)
    [1, '...', 48, 49, 50, 51, '...', 98, 99, 100]

    >>> get_page_list(1, 100, 99, 10)
    [1, '...', 97, 98, 99, 100]

    >>> get_page_list(1, 3, 2, 10)
    [1, 2, 3]
    """

    # if we get "total" as a float (eg from total_entries / entries_per_page)
    # we round up
    total = math.ceil(total)

    if show_max >= (total - start):
        return list(range(start, total + 1))

    ps = []
    if (cur - start) > show_max / 2:
        ps.extend(list(range(start, int(show_max / 4))))
        ps.append("...")
        ps.extend(list(range(cur - int(show_max / 4), cur)))

    else:
        ps.extend(list(range(start, cur)))

    ps.append(cur)

    if (total - cur) > show_max / 2:
        # for the first pages, show more pages at the beginning
        add = math.ceil(show_max / 2 - len(ps))
        ps.extend(list(range(cur + 1, cur + int(show_max / 4) + add)))
        ps.append("...")
        ps.extend(list(range(total - int(show_max / 4), total + 1)))

    else:
        ps.extend(list(range(cur + 1, total + 1)))

    return ps
def get_page_list ( start , total , cur , show_max ) : # if we get "total" as a float (eg from total_entries / entries_per_page) # we round up total = math . ceil ( total ) if show_max >= ( total - start ) : return list ( range ( start , total + 1 ) ) ps = [ ] if ( cur - start ) > show_max / 2 : ps . extend ( list ( range ( start , int ( show_max / 4 ) ) ) ) ps . append ( "..." ) ps . extend ( list ( range ( cur - int ( show_max / 4 ) , cur ) ) ) else : ps . extend ( list ( range ( start , cur ) ) ) ps . append ( cur ) if ( total - cur ) > show_max / 2 : # for the first pages, show more pages at the beginning add = math . ceil ( show_max / 2 - len ( ps ) ) ps . extend ( list ( range ( cur + 1 , cur + int ( show_max / 4 ) + add ) ) ) ps . append ( "..." ) ps . extend ( list ( range ( total - int ( show_max / 4 ) , total + 1 ) ) ) else : ps . extend ( list ( range ( cur + 1 , total + 1 ) ) ) return ps