+
+ def find_near_blog_posts(self):
+ if not self.path.startswith("/Russian/blog/"):
+ return None, None, None, None
+ dirs = self.path.split('/')
+ # blog post is ['', 'Russian', 'blog', year, month, day, filename]
+ if len(dirs) != 7: # Not a blog post
+ return None, None, None, None
+ ymd = tuple(dirs[3:-1])
+ filename = self._fileBaseName
+
+ prev_key = prev_blog_post = current_key = current_blog_post = \
+ next_key = next_blog_post = None
+ old_blog = load_blog()
+ for key in sorted(old_blog):
+ for blog_post in sorted(old_blog[key]):
+ if current_blog_post:
+ prev_key, prev_blog_post = current_key, current_blog_post
+ if next_blog_post:
+ current_key, current_blog_post = next_key, next_blog_post
+ next_key = key
+ next_blog_post = blog_post
+ if current_blog_post and (current_key == ymd) and \
+ (current_blog_post[0] == filename): # Found!
+ return prev_key, prev_blog_post, next_key, next_blog_post
+ return current_key, current_blog_post, None, None
+
+