commented python diary nav code

small-nav
chimchooree 4 years ago
parent d1cc68c50d
commit b432b674fe

@ -5,43 +5,56 @@
<center> <center>
% max_pages = int((total - 1) / limit) % max_pages = int((total - 1) / limit)
% cluster = 3 % cluster = 3
% # TRY DECIMAL POINT PAGES
<% <%
# page never below 0
if page <= 0: if page <= 0:
page = 0 page = 0
end end
# page never over maximum
if page > max_pages: if page > max_pages:
page = max_pages page = max_pages
end end
%> %>
% # << is always active link pointing to 0
<a href=/diary/0><<</a> <a href=/diary/0><<</a>
% # < points to 0 if page 0 or below
% if page <= 0: % if page <= 0:
<a href=/diary/0><</a> <a href=/diary/0><</a>
% # < points to previous page otherwise
% else: % else:
<a href=/diary/{{page - 1}}><</a> <a href=/diary/{{page - 1}}><</a>
% end % end
% # form cluster of number links around page
% for i in range(max(0,page - cluster), min(max_pages + 1,page + cluster + 1)): % for i in range(max(0,page - cluster), min(max_pages + 1,page + cluster + 1)):
% # bold current page number
% if i == page: % if i == page:
<b>{{i}}</b> <b>{{i}}</b>
% # form neighboring numbers into links
% else: % else:
<a href=/diary/{{i}}>{{i}}</a> <a href=/diary/{{i}}>{{i}}</a>
% end % end
% end % end
% # fill out number cluster to the right when page is low
% if page <= 2 and max_pages > page + 3: % if page <= 2 and max_pages > page + 3:
% for j in range(cluster - page): % for j in range(cluster - page):
<a href=/diary/{{page + j + cluster + 1}}><b>{{page + j + cluster + 1}}</b></a> <a href=/diary/{{page + j + cluster + 1}}><b>{{page + j + cluster + 1}}</b></a>
% end % end
% end % end
% # > points to max if page is at or above maximum
% if page >= max_pages: % if page >= max_pages:
<a href=/diary/{{max_pages}}>></a> <a href=/diary/{{max_pages}}>></a>
% # > point to next page otherwise
% else: % else:
<a href=/diary/{{page + 1}}>></a> <a href=/diary/{{page + 1}}>></a>
% end % end
% # >> is always active link to maximum page
<a href=/diary/{{max_pages}}>>></a> <a href=/diary/{{max_pages}}>>></a>
</center> </center>
</div> </div>

Loading…
Cancel
Save