Example #1
0
def admin_edit(name):
    try:
        Validator.check_name(name)
        p = Page(name)
        return template('admin_edit', page=p)
    except PageError, e:
        pass
Example #2
0
def admin_new():
    if request.method == 'POST':
        name = request.forms.name.lower().strip()
        try:
            Validator.check_name(name)
            name = urllib.quote_plus(name)
            d = datetime.now()
            name = d.strftime('%Y-%m-%d-') + name
            p = Page(name)
            p.new(d)
            redirect('/admin/edit/%s' % name)
        except PageError, e:
            return template('admin_new', msg=str(e))
Example #3
0
def admin_ajax(action):
    name = request.forms.name
    try:
        Validator.check_name(name)
        p = Page(name)
        if action == 'save':
            p.content = request.forms.content
            p.save()
        elif action == 'publish':
            p.publish()
        elif action == 'remove':
            delall = bool(request.forms.delall)
            p.remove(delall)
        else:
            raise PageError('No such action')
    except PageError, e:
        return {'status': 'fail', 'data': str(e)}