max pages reflects the max number of pages with diary entries on them; diary nav only goes up to max pages

small-nav
chimchooree 4 years ago
parent d3f23965f3
commit 4b0957f165

@ -3,7 +3,9 @@
<div class="dir-row"> </div> <div class="dir-row"> </div>
<div class="diary-dir"> <div class="diary-dir">
<center> <center>
% max_pages = int(total - 1 / limit) % max_pages = int((total - 1) / limit)
% cluster = 3
<% <%
if page <= 0: if page <= 0:
page = 0 page = 0
@ -20,7 +22,7 @@
<a href=/diary/{{page - 1}}><</a> <a href=/diary/{{page - 1}}><</a>
% end % end
% for i in range(max(0,page - limit), min(total,page + limit + 1)): % for i in range(max(0,page - cluster), min(max_pages + 1,page + cluster + 1)):
% if i == page: % if i == page:
<b>{{i}}</b> <b>{{i}}</b>
% else: % else:
@ -28,19 +30,19 @@
% end % end
% end % end
% if page <= 2: % if page <= 2 and max_pages > page + 3:
% for j in range(3 - page): % for j in range(cluster - page):
<a href=/diary/{{page + j + 3}}>{{page + j + 3}}</a> <a href=/diary/{{page + j + 3}}>{{page + j + 3}}</a>
% end % end
% end % end
% if page >= total - limit: % if page >= max_pages:
<a href=/diary/{{total -1}}>></a> <a href=/diary/{{max_pages}}>></a>
% else: % else:
<a href=/diary/{{page + 1}}>></a> <a href=/diary/{{page + 1}}>></a>
% end % end
<a href=/diary/{{total - 1}}>>></a> <a href=/diary/{{max_pages}}>>></a>
</center> </center>
</div> </div>

Loading…
Cancel
Save