<style>
    .paginator a {
        font-weight:bold;
        padding: 2px 4px;
        color: #0088CC;
    }
    .paginator a.selected {
        color: #FFF !important;
        background-color: #0088CC;
    }
    .paginator p {
        margin: 40px;
        text-align:center;
        color: #333;
    }
    .clear {
        clear:both;
    }
</style>
<div class="clear"></div>
<div style="text-align:center;margin-top:2em;" class="paginator">
    {% if not p.total %}
        <p>无内容</p>
    {% else %}
        {% if not p.is_first %}
        <a href="{{url(p.prev)}}">上一页</a> 
        {% end %}

        {% if p.page_num-6>1 %}...{% end %}
        {% for i in range(max(1, p.page_num-6), min(p.page_num+6+1, p.page_total+1)) %}
        {% if i== p.page_num %}
        <a class="selected" href="{{url(i)}}">{{i}}</a>
        {% else %}
        <a href="{{url(i)}}">{{i}}</a>
        {% end %}
        {% end %}
        {% if p.page_num+6<p.page_total %}...{% end %}

        {% if not p.is_last %}
        <a href="{{url(p.next)}}">下一页</a>
        {% end %}
    {% end %}
</div>
