Browse Source

Add hooks for pages to know more about their context

pull/2/head
Noah Petherbridge 8 years ago
parent
commit
c9b9799589
  1. 2
      rophako/__init__.py
  2. 3
      rophako/modules/blog.py

2
rophako/__init__.py

@ -64,7 +64,7 @@ def before_request():
"author": "Noah Petherbridge",
"photo_url": config.PHOTO_ROOT_PUBLIC,
},
"uri": request.path.split("/")[1:],
"uri": request.path,
"session": {
"login": False, # Not logged in, until proven otherwise.
"username": "guest",

3
rophako/modules/blog.py

@ -356,6 +356,7 @@ def partial_index():
selected = []
stop = offset + BLOG_ENTRIES_PER_PAGE
if stop > len(posts): stop = len(posts)
index = 1 # Let each post know its position on-page.
for i in range(offset, stop):
post_id = posts[i]
post = Blog.get_entry(post_id)
@ -375,6 +376,8 @@ def partial_index():
# Count the comments for this post
post["comment_count"] = Comment.count_comments("blog-{}".format(post_id))
post["position_index"] = index
index += 1
selected.append(post)
g.info["count"] += 1

Loading…
Cancel
Save