Skip to content

Commit

Permalink
Added menu items on admin pages. Fixes #6.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arachnid committed Oct 17, 2009
1 parent 387acfc commit c8d437d
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions generators.py
Expand Up @@ -124,6 +124,7 @@ def generate_resource(cls, post, resource, pagenum=1, start_ts=None):
path_args['pagenum'] = pagenum + 1
next_page = cls.path % path_args
template_vals = {
'generator_class': cls.__name__,
'posts': posts[:config.posts_per_page],
'prev_page': prev_page if pagenum > 1 else None,
'next_page': next_page if more_posts else None,
Expand Down
5 changes: 5 additions & 0 deletions handlers.py
Expand Up @@ -29,6 +29,11 @@ def decorate(self, post_id=None):

class BaseHandler(webapp.RequestHandler):
def render_to_response(self, template_name, template_vals=None, theme=None):
if not template_vals:
template_vals = {}
template_vals.update({
'handler_class': self.__class__.__name__,
})
template_name = os.path.join("admin", template_name)
self.response.out.write(utils.render_template(template_name, template_vals,
theme))
Expand Down
5 changes: 5 additions & 0 deletions themes/default/admin/base.html
@@ -0,0 +1,5 @@
{% extends "../base.html" %}
{% block menu %}
<li{% ifequal handler_class "AdminHandler" %} id="current"{% endifequal %}><a href="/admin/">Posts</a></li>
<li{% ifequal handler_class "PostHandler" %} id="current"{% endifequal %}><a href="/admin/newpost">New Post</a></li>
{% endblock %}
2 changes: 1 addition & 1 deletion themes/default/admin/edit.html
@@ -1,4 +1,4 @@
{% extends "../base.html" %}
{% extends "base.html" %}
{% block title %}{% if form.instance %}Edit{% else %}New{% endif %} Post{% endblock %}
{% block body %}
<h2>{% if form.instance %}Edit{% else %}New{% endif %} Post</h2>
Expand Down
2 changes: 1 addition & 1 deletion themes/default/admin/index.html
@@ -1,4 +1,4 @@
{% extends "../base.html" %}
{% extends "base.html" %}
{% block title %}All Posts{% endblock %}
{% block body %}
<h2>All Posts</h2>
Expand Down
2 changes: 1 addition & 1 deletion themes/default/admin/published.html
@@ -1,4 +1,4 @@
{% extends "../base.html" %}
{% extends "base.html" %}
{% block title %}Post published{% endblock %}
{% block body %}
<p>Your post has been published!</p>
Expand Down
5 changes: 3 additions & 2 deletions themes/default/base.html
Expand Up @@ -12,8 +12,9 @@ <h1 id="logo-text"><a href="/" title="">{{config.blog_name}}</a></h1>
<p id="intro">{{config.slogan}}</p>
<div id="nav">
<ul>
<li id="current"><a href="/">Home</a></li>
</ul>
<li{% ifequal generator_class "IndexContentGenerator" %} id="current"{% endifequal %}><a href="/">Home</a></li>
{% block menu %}{% endblock %}
</ul>
</div>
<div id="header-image"></div>
<form id="quick-search" action="/search" method="get">
Expand Down
1 change: 1 addition & 0 deletions utils.py
Expand Up @@ -29,6 +29,7 @@ def render_template(template_name, template_vals=None, theme=None):
if not template_vals:
template_vals = {}
template_vals.update({
'template_name': template_name,
'config': config,
'devel': os.environ['SERVER_SOFTWARE'].startswith('Devel'),
})
Expand Down

0 comments on commit c8d437d

Please sign in to comment.