fix pager
This commit is contained in:
		@@ -31,7 +31,7 @@ def thread(slug):
 | 
			
		||||
            ("id", "<=", after_id),
 | 
			
		||||
        ])
 | 
			
		||||
        print(post_position)
 | 
			
		||||
        page = math.floor((post_position + 1) / POSTS_PER_PAGE) + 1
 | 
			
		||||
        page = math.ceil((post_position) / POSTS_PER_PAGE)
 | 
			
		||||
    else:
 | 
			
		||||
        page = max(1, min(page_count, int(request.args.get("page", default = 1))))
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{% macro pager(current_page, page_count) %}
 | 
			
		||||
{% set left_start = (1, current_page - 5) | max %}
 | 
			
		||||
{% set right_end = (page_count, current_page + 5) | min %}
 | 
			
		||||
{% set left_start = [1, current_page - 5] | max %}
 | 
			
		||||
{% set right_end = [page_count, current_page + 5] | min %}
 | 
			
		||||
<div class="pager">
 | 
			
		||||
  <span>Page:</span>
 | 
			
		||||
  {% if current_page > 5 %}
 | 
			
		||||
@@ -9,13 +9,13 @@
 | 
			
		||||
      <span class="currentpage">…</span>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
  {% endif %}
 | 
			
		||||
  {% for i in range(left_start, current_page - 1) %}
 | 
			
		||||
  {% for i in range(left_start, current_page) %}
 | 
			
		||||
    <a href="?page={{i}}" class="pagebutton">{{i}}</a>
 | 
			
		||||
  {% endfor %}
 | 
			
		||||
  {% if page_count > 0 %}
 | 
			
		||||
    <span class="currentpage">{{current_page}}</span>
 | 
			
		||||
  {% endif %}
 | 
			
		||||
  {% for i in range(current_page + 1, right_end) %}
 | 
			
		||||
  {% for i in range(current_page + 1, right_end + 1) %}
 | 
			
		||||
    <a href="?page={{i}}" class="pagebutton">{{i}}</a>
 | 
			
		||||
  {% endfor %}
 | 
			
		||||
  {% if right_end < page_count %}
 | 
			
		||||
 
 | 
			
		||||
@@ -45,7 +45,7 @@
 | 
			
		||||
        </span>
 | 
			
		||||
        <span>
 | 
			
		||||
          Latest post by <a href="{{ url_for("users.page", username=thread['latest_post_username']) }}">{{ thread['latest_post_username'] }}</a>
 | 
			
		||||
          on <a href="{{ url_for("threads.thread", slug=thread['slug']) }}">on {{ timestamp(thread['latest_post_created_at'] )}}</a>:
 | 
			
		||||
          on <a href="{{ url_for("threads.thread", slug=thread['slug']) }}">on {{ timestamp(thread['latest_post_created_at']) }}</a>:
 | 
			
		||||
        </span>
 | 
			
		||||
        <span class="thread-info-post-preview">
 | 
			
		||||
          {{ thread['latest_post_content'] | safe }}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user