Ejemplo n.º 1
0
    def test_encode_html(self):
        self.assertEquals('abc', encode.encode_html('abc'))
        self.assertEquals('&lt;h1&gt;', encode.encode_html('<h1>'))
        self.assertEquals('A&amp;B&amp;C', encode.encode_html('A&B&C'))
        self.assertEquals('&quot;Hi!&quot;', encode.encode_html('"Hi!"'))

        self.assertEquals('abc', encode.encode_html(u'abc'))
        self.assertEquals('&lt;h1&gt;', encode.encode_html(u'<h1>'))
        self.assertEquals('A&amp;B&amp;C', encode.encode_html(u'A&B&C'))
        self.assertEquals('&quot;Hi!&quot;', encode.encode_html(u'"Hi!"'))
Ejemplo n.º 2
0
    def test_encode_html(self):
        self.assertEquals('abc', encode.encode_html('abc'))
        self.assertEquals('&lt;h1&gt;', encode.encode_html('<h1>'))
        self.assertEquals('A&amp;B&amp;C', encode.encode_html('A&B&C'))
        self.assertEquals('&quot;Hi!&quot;', encode.encode_html('"Hi!"'))

        self.assertEquals('abc', encode.encode_html(u'abc'))
        self.assertEquals('&lt;h1&gt;', encode.encode_html(u'<h1>'))
        self.assertEquals('A&amp;B&amp;C', encode.encode_html(u'A&B&C'))
        self.assertEquals('&quot;Hi!&quot;', encode.encode_html(u'"Hi!"'))
Ejemplo n.º 3
0
def __json_result(add, post):
    return r'json:{"add":%s,"id":"%s","static":%s,"title":"%s","state":%s,"url":"/blog/%s"}' \
            % ( add and 'true' or 'false', \
                post.id, \
                post.static and 'true' or 'false', \
                encode_html(post.title), \
                post.state, \
                post.url() \
            )
Ejemplo n.º 4
0
def __json_result(add, post):
    return r'json:{"add":%s,"id":"%s","static":%s,"title":"%s","state":%s,"url":"/blog/%s"}' \
            % ( add and 'true' or 'false', \
                post.id, \
                post.static and 'true' or 'false', \
                encode_html(post.title), \
                post.state, \
                post.url() \
            )
Ejemplo n.º 5
0
def _add_page(user, app, context):
    if context.method=='get':
        return {
                '__view__' : 'manage_editor',
                'post' : __empty_post(user, True),
        }
    if context.method=='post':
        title = context.get_argument('title')
        content = context.get_argument('content')
        draft = context.get_argument('draft')=='True'
        allow_comment = context.get_argument('allow_comment')=='True'
        state = model.POST_PUBLISHED
        if draft:
            state = model.POST_DRAFT
        elif user.role>=store.ROLE_AUTHOR:
            state = model.POST_PENDING
        p = model.create_page(user, state, title, content, allow_comment)
        return r'json:{"add":true,"id":"%s","static":%s,"title":"%s","state":%s,"url":"/blog/%s"}' \
                % (p.id, p.static and 'true' or 'false', encode_html(p.title), state, p.url())
Ejemplo n.º 6
0
def _add_page(user, app, context):
    if context.method == 'get':
        return {
            '__view__': 'manage_editor',
            'post': __empty_post(user, True),
        }
    if context.method == 'post':
        title = context.get_argument('title')
        content = context.get_argument('content')
        draft = context.get_argument('draft') == 'True'
        allow_comment = context.get_argument('allow_comment') == 'True'
        state = model.POST_PUBLISHED
        if draft:
            state = model.POST_DRAFT
        elif user.role >= store.ROLE_AUTHOR:
            state = model.POST_PENDING
        p = model.create_page(user, state, title, content, allow_comment)
        return r'json:{"add":true,"id":"%s","static":%s,"title":"%s","state":%s,"url":"/blog/%s"}' \
                % (p.id, p.static and 'true' or 'false', encode_html(p.title), state, p.url())