From c9b9799589ca133a69c27f722e14c7c6a6220c23 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Wed, 9 Apr 2014 15:46:37 -0700 Subject: [PATCH] Add hooks for pages to know more about their context --- rophako/__init__.py | 2 +- rophako/modules/blog.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/rophako/__init__.py b/rophako/__init__.py index ad3f627..b94f75d 100644 --- a/rophako/__init__.py +++ b/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", diff --git a/rophako/modules/blog.py b/rophako/modules/blog.py index accff22..d90d5e6 100644 --- a/rophako/modules/blog.py +++ b/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