Add hooks for pages to know more about their context
This commit is contained in:
parent
c3052c302c
commit
c9b9799589
|
@ -64,7 +64,7 @@ def before_request():
|
||||||
"author": "Noah Petherbridge",
|
"author": "Noah Petherbridge",
|
||||||
"photo_url": config.PHOTO_ROOT_PUBLIC,
|
"photo_url": config.PHOTO_ROOT_PUBLIC,
|
||||||
},
|
},
|
||||||
"uri": request.path.split("/")[1:],
|
"uri": request.path,
|
||||||
"session": {
|
"session": {
|
||||||
"login": False, # Not logged in, until proven otherwise.
|
"login": False, # Not logged in, until proven otherwise.
|
||||||
"username": "guest",
|
"username": "guest",
|
||||||
|
|
|
@ -356,6 +356,7 @@ def partial_index():
|
||||||
selected = []
|
selected = []
|
||||||
stop = offset + BLOG_ENTRIES_PER_PAGE
|
stop = offset + BLOG_ENTRIES_PER_PAGE
|
||||||
if stop > len(posts): stop = len(posts)
|
if stop > len(posts): stop = len(posts)
|
||||||
|
index = 1 # Let each post know its position on-page.
|
||||||
for i in range(offset, stop):
|
for i in range(offset, stop):
|
||||||
post_id = posts[i]
|
post_id = posts[i]
|
||||||
post = Blog.get_entry(post_id)
|
post = Blog.get_entry(post_id)
|
||||||
|
@ -375,6 +376,8 @@ def partial_index():
|
||||||
|
|
||||||
# Count the comments for this post
|
# Count the comments for this post
|
||||||
post["comment_count"] = Comment.count_comments("blog-{}".format(post_id))
|
post["comment_count"] = Comment.count_comments("blog-{}".format(post_id))
|
||||||
|
post["position_index"] = index
|
||||||
|
index += 1
|
||||||
|
|
||||||
selected.append(post)
|
selected.append(post)
|
||||||
g.info["count"] += 1
|
g.info["count"] += 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user