Added pages to the mix.

This commit is contained in:
Raoul Snyman 2010-03-24 07:51:32 +02:00
parent 462d1e6130
commit 3e37dff1b8
5 changed files with 8 additions and 13 deletions

View File

@ -50,13 +50,13 @@ def make_map():
map.connect('/search', controller='blog', action='search')
map.connect('/tag/{id}', controller='blog', action='tag')
map.connect('/calendar/{year}/{month}', controller='blog', action='calendar')
map.connect('/page/new', controller='page', action='new')
map.connect('/{url}', controller='page', action='view')
map.connect('/{controller}')
map.connect('/{controller}/{action}')
map.connect('/{controller}/{action}/{id}')
map.connect('/{url}', controller='page', action='view')
map.connect('/', controller='blog', action='index')
return map

View File

@ -39,8 +39,8 @@ class PageController(BaseController):
def view(self, url):
c.page = Session.query(Page)\
.filter_by(url=url)\
.filter_by(status=u'published')\
.first()
#.filter_by(status=u'published')\
c.page_title = c.page.title
return render(u'/page/view.mako')
@ -67,8 +67,8 @@ class PageController(BaseController):
else:
page = Session.query(Page).get(id)
page.modified = datetime.now()
page.title = c.form_values[u'post-title']
page.body = c.form_values[u'post-body']
page.title = c.form_values[u'page-title']
page.body = c.form_values[u'page-body']
page.url = url
Session.add(page)
Session.commit()

View File

@ -29,7 +29,7 @@
<ul>
<li><a href="${h.url_for('/')}">Home</a></li>
% for page in c.pages:
<li><a href="${page.url}">${page.name}</a></li>
<li><a href="${page.url}">${page.title}</a></li>
% endfor
% if c.current_user:
<li>Logged in as <em>${c.current_user.nick}</em></li>

View File

@ -3,7 +3,7 @@
<div class="page">
<h2 class="title">New Page</h2>
<%include file="/errors.mako"/>
<form id="page-new" action="${h.url_for('/page/edit')}" method="page">
<form id="page-new" action="${h.url_for('/page/edit')}" method="post">
<fieldset>
<div class="form-item">
<!-- <label for="page-title">Title:</label> -->
@ -14,8 +14,7 @@
<textarea name="page-body" id="page-body" class="form-textarea"></textarea>
</div>
<div class="form-item">
<input type="submit" name="page-action" value="Save Draft" class="form-button"/>
<input type="submit" name="page-action" value="Save &amp; Publish" class="form-button"/>
<input type="submit" name="page-action" value="Save" class="form-button"/>
</div>
</fieldset>
</form>

View File

@ -1,11 +1,7 @@
<%inherit file="/base.mako"/>
<%include file="/flash.mako"/>
<div class="page">
% if c.current_user and c.current_user.id == c.page.user.id and c.current_user.has_permission(u'Edit My Pages'):
<h2 class="title">${c.page.title} <span class="page-edit">[<a href="${h.url_for(controller=u'page', action=u'edit', id=c.page.id)}">Edit</a>]</span></h2>
% else:
<h2 class="title">${c.page.title}</h2>
% endif
<div class="entry">
${h.literal(c.page.body)}
</div>