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('/search', controller='blog', action='search')
map.connect('/tag/{id}', controller='blog', action='tag') map.connect('/tag/{id}', controller='blog', action='tag')
map.connect('/calendar/{year}/{month}', controller='blog', action='calendar') 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}')
map.connect('/{controller}/{action}') map.connect('/{controller}/{action}')
map.connect('/{controller}/{action}/{id}') map.connect('/{controller}/{action}/{id}')
map.connect('/{url}', controller='page', action='view')
map.connect('/', controller='blog', action='index') map.connect('/', controller='blog', action='index')
return map return map

View File

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

View File

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

View File

@ -3,7 +3,7 @@
<div class="page"> <div class="page">
<h2 class="title">New Page</h2> <h2 class="title">New Page</h2>
<%include file="/errors.mako"/> <%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> <fieldset>
<div class="form-item"> <div class="form-item">
<!-- <label for="page-title">Title:</label> --> <!-- <label for="page-title">Title:</label> -->
@ -14,8 +14,7 @@
<textarea name="page-body" id="page-body" class="form-textarea"></textarea> <textarea name="page-body" id="page-body" class="form-textarea"></textarea>
</div> </div>
<div class="form-item"> <div class="form-item">
<input type="submit" name="page-action" value="Save Draft" class="form-button"/> <input type="submit" name="page-action" value="Save" class="form-button"/>
<input type="submit" name="page-action" value="Save &amp; Publish" class="form-button"/>
</div> </div>
</fieldset> </fieldset>
</form> </form>

View File

@ -1,11 +1,7 @@
<%inherit file="/base.mako"/> <%inherit file="/base.mako"/>
<%include file="/flash.mako"/> <%include file="/flash.mako"/>
<div class="page"> <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> <h2 class="title">${c.page.title}</h2>
% endif
<div class="entry"> <div class="entry">
${h.literal(c.page.body)} ${h.literal(c.page.body)}
</div> </div>